Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2025

Conversation

hoodmane
Copy link
Contributor

@hoodmane hoodmane commented Mar 12, 2025

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 hoodmane force-pushed the emscripten-better-tracebacks branch from f173d1f to 19a197c Compare March 12, 2025 16:41
@hoodmane
Copy link
Contributor Author

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

Copy link
Contributor

@freakboy3742 freakboy3742 left a comment

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:main Mar 13, 2025
53 checks passed
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.
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants