当前,当发生 webassembly 运行时错误时,堆栈跟踪如下所示(我正在尝试将 Csound 作为 webassembly 运行)
"RuntimeError: integer result unrepresentable
at (<WASM>[5336]+20)
at (<WASM>[1557]+246)
at (<WASM>[408]+1475)
at (<WASM>[6101]+14)
at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9614:89)
at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8882:32)
at (<WASM>[424]+732)
at (<WASM>[278]+45)
at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9606:128)
at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:272:19)"
(
最佳答案
经过一些研究我发现格式是
(<WASM>[function_index]+offset)
要找到函数索引的相应名称,您可以使用 binaryen 的 wasm-as
-s
选项生成函数索引
wasm-as libcsound.wast -s libcsound.sym -o libcsound.wasm
这是libcsound.sym的内容
0:Math_pow
1:enlargeMemory
2:getTotalMemory
3:abortOnCannotGrowMemory
...
使用 libcsound.sym 我们可以使用 WASM 函数名来增强示例
RuntimeError: integer result unrepresentable
at (<WASM>[5336]+20) _lrintf
at (<WASM>[1557]+246) _osckk
at (<WASM>[408]+1475) _kperf_nodebug
at (<WASM>[6101]+14) dynCall_ii
at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9614:89)
at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8882:32)
at (<WASM>[424]+732) _csoundPerformKsmps
at (<WASM>[278]+45) jsCall_vi
at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9606:128)
at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:272:19)
有趣的部分是对 lrintf 的最后一个 C 函数调用.当要转换的 float 位于长整数范围之外时,此函数可能会导致“整数结果无法表示”陷阱。我编辑了 C 代码以先检查边界,然后调用 lrint 解决了问题。
更新
当使用 -g4
并使用 Google Chrome 版本 60.0.3103.0(官方构建)金丝雀(64 位)函数名称出现在堆栈跟踪中时:
Uncaught RuntimeError: integer result unrepresentable
at _lrintf (<WASM>[4176]+6)
at _osckk (<WASM>[1291]+138)
at _kperf_nodebug (<WASM>[257]+768)
at dynCall_ii (<WASM>[4351]+13)
at Object.Module.dynCall_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9153:89)
at invoke_ii (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:8714:32)
at _csoundPerformKsmps (<WASM>[271]+558)
at _CsoundObj_performKsmps (<WASM>[131]+33)
at Module._CsoundObj_performKsmps (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/libcsound.js:9145:128)
at ScriptProcessorNode.audioProcessNode.onaudioprocess (http://192.168.2.39/~manson/emscripten/csound/emscripten/examples/javascripts/CsoundObj.js:269:19)
关于javascript - Webkit WASM 堆栈跟踪调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44047603/