python-poppler
python-poppler copied to clipboard
Segmentation fault with EmbeddedFile class
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?
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?
Thanks for your response.
I use python-poppler==0.2.2 and tested several pdf files.
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.
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.
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?
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.