I am using libharu library for creating pdf and getting following into system
hPDF error error_no=4117, detail_no=0 which HPDF_FAILD_TO_ALLOC_MEM
My query may I know the reason behind this error. and application got crash. is there way to handle this error as I am not able generate pdf
**Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4133, detail_no=0
***Error: (Report::NextPage) current page is empty
***Fatal: *************************** FATAL ERROR ***************************
***Fatal: /usr/lib64/libc.so.6(+0x35270) [0x7ffff6801270]
***Fatal: HPDF_Page_SetWidth+0x49 [0x596159]
I have tried to written small program and try to reproduce this issue but did not encounter any error.
#include<iostream>
#include "hpdf.h"
using namespace std;
class Report {
public:
HPDF_Doc document;
HPDF_Page currentpage;
void static error_handler (HPDF_STATUS,HPDF_STATUS,void *);
void NextPage();
Report(string, string, int);
~Report();
string m_ReportFilePath;
};
void Report::NextPage()
{
if (document == NULL)
cerr << "(Report::NextPage) document is empty" << endl;
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
cerr << "(Report::NextPage) current page is empty" << endl;
cout<<currentpage<<" "<<std::endl;
HPDF_Page_SetWidth(currentpage, 595.3);
}
Report::Report(string fileName, string booktitle, int marg) {
m_ReportFilePath = fileName;
document = HPDF_New(Report::error_handler, &document);
NextPage(); // Create new page
}
Report::~Report()
{
}
void Report::error_handler(HPDF_STATUS error_no,
HPDF_STATUS detail_no, void *user_data)
{
cout << "hPDF error error_no=" << (HPDF_UINT) error_no <<
", detail_no=" << (HPDF_UINT) detail_no << endl;
}
int main() {
Report r("test.pdf", "test", 50);
return 0;
}
compile command
/depot/gcc-4.8.2/bin/g++ -rdynamic -Wall -I../include -std=c++11 -c lib_haru.cpp -o lib_haru -L../libs -lhpdf
/depot/gcc-4.8.2/bin/g++ -o libh lib_haru.o -rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
OBJECTS=$(addsuffix .o,$(basename $(SRC)))
VERSION=$(USER)
CXXFLAGS=-g -D Version=$(VERSION) -rdynamic -Wall -I../include
LDFLAGS=-rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
#CXX= /usr/bin/g++
CXX= /depot/gcc-4.8.2/bin/g++
issue when I compile on this machine
Linux Machine 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
GDB output
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6852c31 in __strlen_sse2 () from /usr/lib64/libc.so.6
Possible issue
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
logerror << "(Report::NextPage) current page is empty" << endl;
#value of currentpage is 0
The only time I've seen this error was when the PDF became so large it consumed all available memory. In my case, I was creating images using the PDF primitives (like a filled rectangle).
You really haven't given enough information to help diagnose the problem. Version of libHaru, 32 or 64 bit, generally what you are trying to do would be helpful.