bytecodealliance / bytecodealliance/componentize-py

Is there a way to include debug info?

オープン
#146 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
277
フォーク
51
平均マージ
12時間 10分
マージ済み PR(30日)
10

説明

When the .wasm file raises an error, the resulting backtrace does not contain any reference to the original source files (even using `wasmtime::WasmBacktraceDetails::Enable`).

With Rust and Go components it's possible to use compile-time flags such as `--release` or `-no-debug` to control whether debug info is included or not in the .wasm file. So I was wondering if the same would be possible with componentize-py?

Here's an example of the backtrace I get on error (where the only useful reference to my component's code is line 28):

```shell
Error: Failed to call component: error while executing at wasm backtrace:
0: 0xa9b968 - wit-component:adapter:wasi_snapshot_preview1!
1: 0x2230183 - wit-component:shim!adapt-wasi_snapshot_preview1-fd_write
2: 0x21b2244 - libc.so!__wasi_fd_write
3: 0x21b1a9f - libc.so!write
4: 0x14934 - !
5: 0xeba24e - _Py_write_impl
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/fileutils.c:1962:17 - _Py_write
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/fileutils.c:2033:12
6: 0xf9dffd - _io_FileIO_write_impl
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Modules/_io/fileio.c:874:9 - _io_FileIO_write
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Modules/_io/clinic/fileio.c.h:388:20
7: 0xd16038 - method_vectorcall_FASTCALL_KEYWORDS_METHOD
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/descrobject.c:387:24
8: 0xd09540 - _PyObject_VectorcallTstate
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11 - PyObject_VectorcallMethod
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:887:24
9: 0xfab74b - PyObject_CallMethodOneArg
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/cpython/abstract.h:103:12 - _textiowrapper_writeflush
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Modules/_io/textio.c:1629:15
10: 0xfacee3 - _io_TextIOWrapper_write_impl
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Modules/_io/textio.c:1759:13 - _io_TextIOWrapper_write
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Modules/_io/clinic/textio.c.h:680:20
11: 0xd64d6e - cfunction_vectorcall_O
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/methodobject.c:509:24
12: 0xd084da - _PyObject_VectorcallTstate
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11 - PyObject_CallOneArg
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:401:12
13: 0xd291f6 - PyFile_WriteObject
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/fileobject.c:132:14
14: 0xd292e5 - PyFile_WriteString
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/fileobject.c:156:15
15: 0xeab96b - _Py_WriteIndentedMargin
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:430:13 - _PyTraceBack_Print_Indented
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:1078:9
16: 0xe96e54 - print_exception_traceback
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:911:15 - print_exception
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:1180:9
17: 0xe96465 - print_exception_recursive
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:1474:13
18: 0xe96122 - _PyErr_Display
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:1524:9
19: 0xe9600c - PyErr_Display
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:1556:5
20: 0xea872d - sys_excepthook_impl
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/sysmodule.c:772:5 - sys_excepthook
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/clinic/sysmodule.c.h:102:20
21: 0xd64ea4 - cfunction_vectorcall_FASTCALL
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/methodobject.c:422:24
22: 0xd08285 - _PyObject_VectorcallTstate
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11 - _PyObject_FastCallTstate
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:116:12 - _PyObject_FastCall
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:334:12
23: 0xe94994 - _PyErr_PrintEx
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:807:28
24: 0xe96049 - PyErr_PrintEx
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/pythonrun.c:845:5
25: 0x12f52 - !
26: 0xaf3c63 - libcomponentize_py_runtime.so!pyo3::err::PyErr::print::hbb86b960398edf90
27: 0xadda83 - libcomponentize_py_runtime.so!componentize-py#Dispatch
28: 0x221c1db - libcomponentize_py_bindings.so!edgee:components/data-collection#page-export
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、componentize-py のビルドパスと、生成された .wasm が Wasmtime に渡される方法を追跡し、デバッグの参照として WasmBacktraceDetails::Enable を使用します。Rust と Go で利用可能なコンパイル時のデバッグ情報制御を componentize-py のオプションと比較し、そのうえで、結果として得られるバックトレースがコンポーネントの元のソースファイルを特定することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, rust, wasm
領域
build-system, tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。