Skip to content

RangeError: Maximum call stack size exceeded (Safari) #28

Open

Description

@mglaman

It appears that the stack size in WebKit isn't large enough and crashes when executing.

Links

Original report, early prototype

https://x.com/claudiu_cristea/status/1808274872872702302

500: Internal Server Error.
================================================================================

Stacktrace:
<?>.wasm-function[4423]@[wasm code]
<?>.wasm-function[5069]@[wasm code]
<?>.wasm-function[5067]@[wasm code]
<?>.wasm-function[5079]@[wasm code]
<?>.wasm-function[6366]@[wasm code]
<?>.wasm-function[6370]@[wasm code]
<?>.wasm-function[5260]@[wasm code]
<?>.wasm-function[1143]@[wasm code]
<?>.wasm-function[910]@[wasm code]
<?>.wasm-function[2505]@[wasm code]
<?>.wasm-function[2055]@[wasm code]
<?>.wasm-function[608]@[wasm code]
<?>.wasm-function[2172]@[wasm code]
<?>.wasm-function[2171]@[wasm code]
<?>.wasm-function[6300]@[wasm code]
<?>.wasm-function[5260]@[wasm code]
<?>.wasm-function[1143]@[wasm code]
<?>.wasm-function[3409]@[wasm code]
<?>.wasm-function[6680]@[wasm code]
<?>.wasm-function[5260]@[wasm code]
<?>.wasm-function[1143]@[wasm code]
<?>.wasm-function[3408]@[wasm code]
<?>.wasm-function[6679]@[wasm code]
<?>.wasm-function[5260]@[wasm code]
<?>.wasm-function[2500]@[wasm code]
<?>.wasm-function[4644]@[wasm code]
<?>.wasm-function[11897]@[wasm code]
11897@[native code]
@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:380243
invoke_iiiii@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:696811
<?>.wasm-function[4640]@[wasm code]
<?>.wasm-function[11895]@[wasm code]
11895@[native code]
@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:380243
invoke_ii@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:696645
<?>.wasm-function[7666]@[wasm code]
7666@[native code]
@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:380243
@https://wasm-drupal.mglaman.dev/php-cgi-worker.mjs:9:382621

Error on Drupal Core with install script

RangeError: Maximum call stack size exceeded.
php-worker.mjs.wasm.wasm-function[zendparse]
php-worker.mjs.wasm.wasm-function[zend_compile]
php-worker.mjs.wasm.wasm-function[compile_file]
php-worker.mjs.wasm.wasm-function[compile_filename]
php-worker.mjs.wasm.wasm-function[zend_include_or_eval]
php-worker.mjs.wasm.wasm-function[ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER]
php-worker.mjs.wasm.wasm-function[execute_ex]
php-worker.mjs.wasm.wasm-function[zend_call_function]
php-worker.mjs.wasm.wasm-function[zend_call_known_function]
php-worker.mjs.wasm.wasm-function[spl_perform_autoload]
php-worker.mjs.wasm.wasm-function[zend_lookup_class_ex]
php-worker.mjs.wasm.wasm-function[zend_fetch_class]
php-worker.mjs.wasm.wasm-function[ZEND_FETCH_CLASS_SPEC_UNUSED_CV_HANDLER]
php-worker.mjs.wasm.wasm-function[execute_ex]
php-worker.mjs.wasm.wasm-function[zend_execute]
php-worker.mjs.wasm.wasm-function[dynCall_vii]
12024
(anonymous function) — php-worker.mjs:18665
invoke_vii — php-worker.mjs:31578
(anonymous function) — php-worker.mjs:18645
php-worker.mjs.wasm.wasm-function[zend_eval_stringl]
php-worker.mjs.wasm.wasm-function[zend_eval_string]
php-worker.mjs.wasm.wasm-function[dynCall_iiii]
12020
(anonymous function) — php-worker.mjs:18665
invoke_iiii — php-worker.mjs:31512

Error on visiting installed Starshot prototype

Stacktrace:
<?>.wasm-function[4465]@[wasm code] zend_ast_destroy
<?>.wasm-function[5028]@[wasm code] zend_compile
<?>.wasm-function[5026]@[wasm code] zend_set_compiled_filename
<?>.wasm-function[5038]@[wasm code] compile_filename
<?>.wasm-function[6330]@[wasm code] zend_include_or_eval
<?>.wasm-function[6334]@[wasm code] ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER
<?>.wasm-function[5219]@[wasm code] execute_ex
<?>.wasm-function[1165]@[wasm code] zend_array_destroy
<?>.wasm-function[932]@[wasm code] php_file_le_pstream
<?>.wasm-function[2536]@[wasm code] spl_perform_autoload
<?>.wasm-function[2086]@[wasm code] zend_lookup_class_ex
<?>.wasm-function[2260]@[wasm code] zend_fetch_class_by_name
<?>.wasm-function[6291]@[wasm code] ZEND_NEW_SPEC_CONST_UNUSED_HANDLER
<?>.wasm-function[5219]@[wasm code] execute_ex
<?>.wasm-function[2531]@[wasm code] zend_execute
<?>.wasm-function[4603]@[wasm code] php_execute_simple_script
<?>.wasm-function[12055]@[wasm code] legalstub$scalbnl
12055@[native code]
@http://localhost/php-cgi-worker.mjs:9:357148
invoke_iiiii@http://localhost/php-cgi-worker.mjs:9:668972
<?>.wasm-function[4599]@[wasm code] virtual_chdir_file
<?>.wasm-function[12053]@[wasm code] legalstub$exp2l
12053@[native code]
@http://localhost/php-cgi-worker.mjs:9:357148
invoke_ii@http://localhost/php-cgi-worker.mjs:9:668806
<?>.wasm-function[7637]@[wasm code] __syscall_setdomainname
7637@[native code]
@http://localhost/php-cgi-worker.mjs:9:357148
@http://localhost/php-cgi-worker.mjs:9:359526

Activity

  1. mglaman commented on Jul 3, 2024

    @mglaman
    OwnerAuthor

    I can't even debug this. Safari does not show the registered service worker or the WASM for me to drop a breakpoint, like in Blink based browsers.
    Screenshot 2024-07-03 at 9 12 06 AM

  2. added
    safariIssues specifically with Safari browser
    on Jul 4, 2024
  3. pinned this issue on Jul 4, 2024
  4. mglaman commented on Jul 9, 2024

    @mglaman
    OwnerAuthor

    This will require a custom build of php-wasm, I think, that will name debugging easier. The fix will need to go into that package

  5. added
    php-wasmRequires work in upstream php-wasm package
    on Jul 9, 2024
  6. tekNorah commented on Jul 10, 2024

    @tekNorah

    Not sure if this should be a different issue. But, I am getting this error on my Google ChromeOS Version 126.0.6478.132 (Official Build) (64-bit)

    Screenshot 2024-07-10 1 17 29 PM

  7. mglaman commented on Jul 10, 2024

    @mglaman
    OwnerAuthor

    The banner warning is displayed for everyone, I'm not doing browser checks

  8. mglaman commented on Jul 25, 2024

    @mglaman
    OwnerAuthor

    Requires SYMBOLS=1 in php-wasm build

  9. mglaman commented on Aug 7, 2024

    @mglaman
    OwnerAuthor
    Screenshot 2024-08-07 at 10 42 01 AM

    I just retried with the new setup and it failed during Step 4 of the install (not sure what step task it is named.)

  10. changed the title [-]Errors on Safari with php-cgi-worker and WASM[/-] [+]Errors on Safari with php-wasm[/+] on Aug 7, 2024
  11. mglaman commented on Aug 7, 2024

    @mglaman
    OwnerAuthor

    I was able to get a trace. This build only had ASSERTIONS=1, trying with less optimizations.

    Screenshot 2024-08-07 at 11 47 20 AM
  12. mglaman commented on Aug 7, 2024

    @mglaman
    OwnerAuthor

    Found something!

    Screenshot 2024-08-07 at 12 45 15 PM

    maybe

  13. mglaman commented on Aug 8, 2024

    @mglaman
    OwnerAuthor

    With ASSERTIONS=1, Aborted('ENV' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)) is thrown. The following diff let be build with ASSERTIONS on

    diff --git a/Makefile b/Makefile
    index 2aeca3cd..0676fd42 100755
    --- a/Makefile
    +++ b/Makefile
    @@ -388,7 +388,7 @@ BUILD_FLAGS=-f ../../php.mk \
     	EXTRA_LDFLAGS_PROGRAM='-O${OPTIMIZE} -static \
     		-Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152 -L/src/lib/lib \
     		${SYMBOL_FLAGS} -flto -fPIC \
    -		-s EXPORTED_RUNTIME_METHODS='\''["ccall", "UTF8ToString", "lengthBytesUTF8", "getValue", "FS"]'\'' \
    +		-s EXPORTED_RUNTIME_METHODS='\''["ccall", "UTF8ToString", "lengthBytesUTF8", "getValue", "FS", "ENV"]'\'' \
     		-s ENVIRONMENT=${ENVIRONMENT}            \
     		-s INITIAL_MEMORY=${INITIAL_MEMORY}      \
     		-s MAXIMUM_MEMORY=${MAXIMUM_MEMORY}      \

    Different build notes for myself:

    • ASSERTIONS=1 OPTIMIZE=1 make worker-mjs worker-cgi-mjs fails due to too large of a compilation.
    • ASSERTIONS=1 OPTIMIZE=2 make worker-mjs worker-cgi-mjs builds normal, Blink passed Webkit failed
    • ASSERTIONS=1 OPTIMIZE=3 make worker-mjs worker-cgi-mjs builds normal, Blink passed Webkit failed
    • ASSERTIONS=1 OPTIMIZE=2 WITH_VRZNO=0 SYMBOLS=1 make worker-mjs worker-cgi-mjs same, -g1 doesn't do much per https://emscripten.org/docs/tools_reference/emcc.html#emcc-g0
    • ASSERTIONS=1 OPTIMIZE=2 WITH_VRZNO=0 SYMBOLS=2 make worker-mjs worker-cgi-mjs ✅ visible stack, still broken
    • OPTIMIZE=z WITH_VRZNO=0 SYMBOLS="0 --emit-symbol-map" make worker-mjs worker-cgi-mjs > build.log still broken
    • OPTIMIZE="z -fno-inline-functions" WITH_VRZNO=0 SYMBOLS="0 --emit-symbol-map" make worker-mjs worker-cgi-mjs still broken

    TO TRY

    • SYMBOL_FLAGS=0 --profiling --profiling-funcs possibly same as SYMBOLS=2
    • SYMBOL_FLAGS=0 --emit-symbol-map writes a symbols name file to decode the integers
    • OPTIMIZE="z -fno-inline-functions"
  14. changed the title [-]Errors on Safari with php-wasm[/-] [+]RangeError: Maximum call stack size exceeded (Safari)[/+] on Aug 9, 2024
  15. mglaman commented on Aug 9, 2024

    @mglaman
    OwnerAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingphp-wasmRequires work in upstream php-wasm packagesafariIssues specifically with Safari browser

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions