python-poppler icon indicating copy to clipboard operation
python-poppler copied to clipboard

Segmentation fault with EmbeddedFile class

Open ikreb7 opened this issue 4 years ago • 6 comments

I want to use the EmbeddedFile class. However, I get a segmentation fault.

from poppler import load_from_file

pdf_document = load_from_file("Portfolio.pdf")

for file in pdf_document.embedded_files():
     print(file.name)

What kind of information could you help further? I saw at the TODO file, that EmbeddedFile is not still testet. Does it work yet?

ikreb7 avatar Jul 13 '21 14:07 ikreb7

I did some quick tests, and your example should work... I realized however that there are small errors in the code for is_valid and modification_date.

Did you try with different pdf files? What version of poppler are you using?

cbrunet avatar Jul 15 '21 02:07 cbrunet

Thanks for your response.

I use python-poppler==0.2.2 and tested several pdf files.

ikreb7 avatar Jul 16 '21 07:07 ikreb7

I see there are fixes related to embedded files in Poppler 20.11 (https://poppler.freedesktop.org/releases.html). This could be related.

What poppler version are you compiled with? You can get it using poppler.version() function.

cbrunet avatar Jul 27 '21 02:07 cbrunet

I have a similar issue. It seems that pybind11 is prematurely calling the destructor (and thus, free()) on some Poppler objects (for example, EmbeddedFile* elements of std::vector<EmbeddedFile*> Document::embedded_files()), which results in a double free() and other memory corruption bugs.

bence98 avatar Jul 29 '21 15:07 bence98

This could be related to https://github.com/pybind/pybind11/issues/637.

Could you please try the https://github.com/cbrunet/python-poppler/tree/segfault-with-files branch, and tell me if it solves the problem?

cbrunet avatar Sep 10 '21 18:09 cbrunet

I use the the poppler version (0, 86, 1).

I ran the program with your branch, but it doesn't help.

I created a test file for you. It makes the the debugging for you more simple. And thank you very much for your efforts.

portfolio_0.pdf

ikreb7 avatar Sep 16 '21 08:09 ikreb7