bblanchon / pdfium-binaries

📰 Binary distribution of PDFium
789 stars 166 forks source link

Compiled pdfium is not available in windows7 #162

Open Haye1213 opened 1 month ago

Haye1213 commented 1 month ago

I would like to ask how you compile pdfium. The chromium6307 version of pdfium I compiled will crash when using FPDF_InitLibrary on windows7 system, but this problem will not occur when using the one you provide I use the command line to compile, enter the command line as follows: gn args out/x64 ninja -C out/x64 pdfium

My args.gn file looks like this: is_component_build = false is_debug = false pdf_enable_v8 = false pdf_enable_xfa = false pdf_is_standalone = true target_cpu = "x86" target_os = "win" treat_warnings_as_errors = false

Now I can't find the problem, I hope to get your reply, thank you

mara004 commented 1 month ago

pdfium-binaries are currently built without PartitionAlloc, which is not Windows-7-compatible according to https://groups.google.com/g/pdfium/c/nvsDYtu1v7c/m/UyCzD2N0AQAJ. I think this explains why a binary compiled with your config crashes whereas pdfium-binaries don't. See also https://github.com/bblanchon/pdfium-binaries/issues/148 for other reasons to disable PartitionAlloc.

Haye1213 commented 1 month ago

Hi!@mara004 , Thank you for your reply. I have learned that we can avoid further problems in windows7 by adding this compilation option, but I also want to know if there will be any bad effects after adding this compilation option

mara004 commented 1 month ago

@Haye1213 We've been using PartitionAlloc-disabled binaries for a while now and so far haven't had any issues. From what I understand, it's a custom memory allocator implementation, i.e. an alternative to the system allocator. In particular, it seems to provide some inherent security features, aiming to limit the exploit scope in case of memory corruption. This may or may not be relevant to your use case. You can read more about PartitionAlloc design goals e.g. here: https://chromium.googlesource.com/chromium/src/+/master/base/allocator/partition_allocator/PartitionAlloc.md

If you are concerned about disabling PartitionAlloc, you could alternatively try to patch the code that does not work on Win7, but supposedly you'd be on your own with this. IMHO the compatibility reasons justify disabling PartitionAlloc, and its advantages might be more theoretical than practical.