当前,当发生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)"
( [数字1] +数字2)是什么意思,尤其是那些数字?
最佳答案
经过研究,我发现格式为
(<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函数调用。当要转换的浮点数位于长整数范围之外时,此函数可能导致“整数结果无法表示”陷阱。我在调用lrint之前解决了问题,然后编辑了C代码以首先检查边界。
更新资料
使用
-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)