You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building cmark-gfm to asm.js with Emscripten I ran into the issue that the cmark library suffers a Javascript stack overflow during loading. It happens in both debug and release builds.
To reproduce:
Install Emscripten SDK (reproduced with 3.1.50 and 3.1.59)
Modify api_test/CMakeLists.txt to make emscripten output an HTML test page (see attached CMakeLists.txt)
Build using the attached batch file
Go to api_test inside the build directory
Double-click api_test.html
Open Developer Tools in your web browser
In the Console tab, there will be a message saying "Uncaught RangeError: Maximum call stack size exceeded"
It appears this error is emitted while loading the cmark-gfm library code, i.e. before any execution has happened.
I tracked it down to the very large switch statement in case_fold_switch.inc. If you look at api_test.js (debug build, for readability) in an editor and search for cmark_utf8proc_case_fold and then scroll down you will see that Emscripten has generated a very deeply nested set of {} blocks - over 1400 levels deep. This evidently exceeds the browser's Javascript stack capacity,
Evidently this is an emscripten code gen issue which the huge switch statement provokes. Tried changing the compiler optimize setting (including -Os) but it didn't help.
I was able to work around it by rearranging the code in utf8.c and case_fold_switch.inc to use if's instead of a switch. The code generated from that is much less deeply nested and loads & runs correctly (console reports all tests passed).
Another alternative might be some sort of lookup table.
The text was updated successfully, but these errors were encountered:
When building cmark-gfm to asm.js with Emscripten I ran into the issue that the cmark library suffers a Javascript stack overflow during loading. It happens in both debug and release builds.
To reproduce:
CMakeLists.txt
build_cmarkgfm_js.bat.txt
It appears this error is emitted while loading the cmark-gfm library code, i.e. before any execution has happened.
I tracked it down to the very large switch statement in case_fold_switch.inc. If you look at api_test.js (debug build, for readability) in an editor and search for cmark_utf8proc_case_fold and then scroll down you will see that Emscripten has generated a very deeply nested set of {} blocks - over 1400 levels deep. This evidently exceeds the browser's Javascript stack capacity,
Evidently this is an emscripten code gen issue which the huge switch statement provokes. Tried changing the compiler optimize setting (including -Os) but it didn't help.
I was able to work around it by rearranging the code in utf8.c and case_fold_switch.inc to use if's instead of a switch. The code generated from that is much less deeply nested and loads & runs correctly (console reports all tests passed).
Another alternative might be some sort of lookup table.
The text was updated successfully, but these errors were encountered: