Segmentation Fault

Hello,
I am using PDFNet SDK. When I am trying to use FreeText annotation on PDF, my app is crashing sometimes, and I am not getting any stack trace. Just getting something like:
" A/libc(4969): Fatal signal 11 (SIGSEGV)"

It crashes for like 4-5 times and after that it starts working. Any help?

Thanks :slight_smile:

Siddharth

You should call IsValid method on any annot before you call other methods on it. For example, a FreeText annot does not have to have a popup, so calling

free_text.GetPopUp().GetContent()

is dangerous.

instead call

`
popup = free_text.GetPopup()
if (popup.IsValid()) {

popup.GetContent();

}

`

Of course a SIGSEGV is bad, and we recently fixed an issue with this regards, but the fix is not yet available for mobile yet, so you need to use the logic above.

If this does not help, that is you get a crash after IsValid returns true, or something similar, please file a bug report, including the code you are calling, and ideally the PDF file for which the issue happens with.
https://www.pdftron.com/support/reportproblem.html

Hey Ryan,
Thanks for the help. I fixed it…it also happens when we don’t handle the locks properly when editing the annotations.
So, it’s working cool.

Now, another problem that I am facing is with the converted pdfs (Which were like jpg/png, we converted them to pdf). The FreeText annotation is not getting placed.
But, for some images it was working. I am attaching two converted pdfs. Please let me know what difference you find while annotating FreeText. If both of them are working good for you, I will send you the code for a review, may be I am missing something.

Thanks :slight_smile:

Regards,
Siddharth

This doesn’t work.pdf (1.41 MB)

This works good.pdf (39.1 KB)

What happens when you try to add the FreeText annotation in the original, unmodified, PDFViewCtrl or CompleteReader sample that came with the PDFNet SDK?

Assuming that is correct, then you need review your changes.

Note, that the page dimensions for the “This doesn’t work” file is much larger then the other document. Perhaps in your changes you made some assumption about dimensions?