Skip to content

gh-127503: Improve tracebacks on Emscripten when there is a trap - #131158

Merged
freakboy3742 merged 3 commits into
python:mainfrom
hoodmane:emscripten-better-tracebacks
Mar 13, 2025
Merged

gh-127503: Improve tracebacks on Emscripten when there is a trap#131158
freakboy3742 merged 3 commits into
python:mainfrom
hoodmane:emscripten-better-tracebacks

Conversation

@hoodmane

@hoodmanehoodmane commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

This PR solves two problems:

  1. No Python traceback shown on segfault/trap
  2. The JavaScript source line is shown

The JavaScript source line is super long and completely unenlightening, whereas the Python traceback is very helpful.

This PR solves two problems:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown
The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.
@hoodmane
hoodmaneforce-pushed the emscripten-better-tracebacks branch from f173d1f to 19a197cCompareMarch 12, 2025 16:41
@hoodmane

Copy link
Copy Markdown
ContributorAuthor

After this change a trap in the test suite looks as follows:

Details

Aborted(Assertion failed: callable != NULL, at: ../../../../Include/internal/pycore_call.h,116,_PyVectorcall_FunctionInline)
RuntimeError: Aborted(Assertion failed: callable != NULL, at: ../../../../Include/internal/pycore_call.h,116,_PyVectorcall_FunctionInline). Build with -sASSERTIONS for more info.
at abort (file:///home/rchatham/cpython/cross-build/wasm32-emscripten/build/python/python.mjs:261:15)
at ___assert_fail (file:///home/rchatham/cpython/cross-build/wasm32-emscripten/build/python/python.mjs:1735:7)
at wasm://wasm/02f678e6:wasm-function[787]:0x1c26ed
at wasm://wasm/02f678e6:wasm-function[798]:0x1c35ad
at wasm://wasm/02f678e6:wasm-function[3560]:0x3575f2
at wasm://wasm/02f678e6:wasm-function[3558]:0x30d1f8
at wasm://wasm/02f678e6:wasm-function[3557]:0x30cfca
at wasm://wasm/02f678e6:wasm-function[3519]:0x3084d2
at wasm://wasm/02f678e6:wasm-function[3560]:0x318045
at wasm://wasm/02f678e6:wasm-function[3558]:0x30d1f8
Stack (most recent call first):
File "<frozen __hello__>", line 0 in <module>
File "<frozen importlib._bootstrap>", line 1176 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1339 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1368 in _find_and_load
File "/home/rchatham/cpython/Lib/importlib/util.py", line 90 in find_spec
File "/home/rchatham/cpython/Lib/test/test_ctypes/test_values.py", line 85 in test_frozentable
File "/home/rchatham/cpython/Lib/unittest/case.py", line 606 in _callTestMethod
File "/home/rchatham/cpython/Lib/unittest/case.py", line 660 in run
File "/home/rchatham/cpython/Lib/unittest/case.py", line 716 in __call__
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 122 in run
File "/home/rchatham/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/home/rchatham/cpython/Lib/test/libregrtest/testresult.py", line 148 in run
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 84 in _run_suite
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 42 in run_unittest
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 162 in test_func
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 118 in regrtest_runner
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 165 in _load_run_test
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 210 in _runtest_env_changed_exc
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 319 in _runtest
File "/home/rchatham/cpython/Lib/test/libregrtest/single.py", line 348 in run_single_test
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 378 in run_test
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 408 in run_tests_sequentially
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 550 in _run_tests
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 585 in run_tests
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 757 in main
File "/home/rchatham/cpython/Lib/test/libregrtest/main.py", line 765 in main
File "/home/rchatham/cpython/Lib/test/__main__.py", line 2 in <module>
File "/home/rchatham/cpython/Lib/runpy.py", line 88 in _run_code
File "/home/rchatham/cpython/Lib/runpy.py", line 198 in _run_module_as_main

@freakboy3742freakboy3742 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a nicer stack track than the previous behaviour 👍

@freakboy3742
freakboy3742 merged commit db1e582 into python:mainMar 13, 2025
plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
python#131158)
Modifies the behavior of the interpreter on crash under Emscripten:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown
The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@hoodmane@freakboy3742