pdfium-lib
pdfium-lib copied to clipboard
Get error "Uncaught RuntimeError: unreachable" when initialize
Describe the bug Hi,
Im getting this error:

It happen when i call FPDF.Init().
It start happen only after use recent version of "emscripten". Im using now "2.0.34" (but tested with others) to keep it updated, but need solve this error.
To Reproduce
- Download latest pdfium from my branch: https://www.dropbox.com/s/n1bz12hcvif2h0a/artifact-wasm-4692.zip?dl=1
- Unzip it:
unzip artifact-wasm-4692.zip - Untar it:
tar -xzvf wasm.tgz - Execute:
cd "release/node" - Execute:
python -m http.server - Open in browser:
http://localhost:8000/?debug=1 - Execute on browser console:
FPDF.Init()
Expected behavior
Initialize PDFium without problems.
Screenshots

System (please complete the following information):
- OS: [e.g. macos]
- Version [e.g. bigsur]
Hi,
@cetinsert can you help update to latest version?
I only need solve this problem.
@paulo-coutinho – I am looking into it.
Nice, thanks. Me too.
Im using docker to help compile from mac.
So, with these commands you can make fast tests like me:
docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py run test-wasm
python -m http.server --directory sample-wasm/build
And only need open http://localhost:8000/?debug=1 in your browser.
It compile file main.cpp and you can play with it. I have commented all lines inside main method and the error still happen.
People here https://github.com/emscripten-core/emscripten/issues/9443#issuecomment-594864722 (from the linked comment below) follow the same issue all the way up to LLVM.
Hi,
The problem is in this line FPDF_InitLibraryWithConfig(&config);.
Im trying understand.
Yes, it fails to return.
- try the
--profileflag to produce a better stack trace: https://github.com/emscripten-core/emscripten/issues/9443#issuecomment-594864722 - try different optimization levels
-O1vs ...- https://github.com/emscripten-core/emscripten/issues/9443#issuecomment-821814373
- https://github.com/emscripten-core/emscripten/issues/9443#issuecomment-823029438
I tried all optimization levels, but still failling.
My stacktrace:
index.js:77 Uncaught RuntimeError: unreachable
at pdfium::base::AllocPages(void*, unsigned long, unsigned long, pdfium::base::PageAccessibilityConfiguration, pdfium::base::PageTag, bool) (index.wasm:0x71085)
at pdfium::base::internal::PartitionBucket::SlowPathAlloc(pdfium::base::internal::PartitionRootBase*, int, unsigned long, bool*) (index.wasm:0x72900)
at fxcrt::StringDataTemplate<char>::Create(unsigned long) (index.wasm:0x5628)
at fxcrt::StringDataTemplate<char>::Create(char const*, unsigned long) (index.wasm:0x5695)
at fxcrt::ByteString::ByteString(char const*) (index.wasm:0x886e)
at CLinuxPlatform::CreateDefaultSystemFontInfo() (index.wasm:0xf501)
at CFX_GEModule::Create(char const**) (index.wasm:0x13666)
at FPDF_InitLibraryWithConfig (index.wasm:0x70a9e)
at main (index.wasm:0x367b)
at index.js:1591
$pdfium::base::AllocPages(void*, unsigned long, unsigned long, pdfium::base::PageAccessibilityConfiguration, pdfium::base::PageTag, bool) @ index.wasm:0x71085
$pdfium::base::internal::PartitionBucket::SlowPathAlloc(pdfium::base::internal::PartitionRootBase*, int, unsigned long, bool*) @ index.wasm:0x72900
$fxcrt::StringDataTemplate<char>::Create(unsigned long) @ index.wasm:0x5628
$fxcrt::StringDataTemplate<char>::Create(char const*, unsigned long) @ index.wasm:0x5695
$fxcrt::ByteString::ByteString(char const*) @ index.wasm:0x886e
$CLinuxPlatform::CreateDefaultSystemFontInfo() @ index.wasm:0xf501
$CFX_GEModule::Create(char const**) @ index.wasm:0x13666
$FPDF_InitLibraryWithConfig @ index.wasm:0x70a9e
$main @ index.wasm:0x367b
(anonymous) @ index.js:1591
callMain @ index.js:5933
doRun @ index.js:5990
(anonymous) @ index.js:6001
setTimeout (async)
run @ index.js:5997
runCaller @ index.js:5911
removeRunDependency @ index.js:1520
receiveInstance @ index.js:1680
receiveInstantiationResult @ index.js:1697
Promise.then (async)
(anonymous) @ index.js:1726
Promise.then (async)
instantiateAsync @ index.js:1723
createWasm @ index.js:1754
(anonymous) @ index.js:5465
I change again to "2.0.24" to finish the PR and will open another PR to solve it.
AllocPages is still being a source of suffering it seems o__O. Looking forward to https://github.com/paulo-coutinho/pdfium-lib/pull/55!
I tried the same thing for emscripten 3.0.0 and this problem still :(
I made a new branch only to test it: https://github.com/paulo-coutinho/pdfium-lib/tree/emscripten
I have updated to emscripten 3.1.0 and the same problem happen :(
Hi,
All problems was fixed in new release.
You can check here: https://github.com/paulocoutinhox/pdfium-lib/releases/tag/5407
The demo is here: https://pdfviewer.github.io/
Feel free to donate to help project development.
Thanks.