'Index out of bounds' error thrown from call to function in wasmTable

57 views
Skip to first unread message

nickw

unread,
Aug 1, 2021, 8:41:28 AM8/1/21
to emscripten-discuss

Hi,

Trying to debug a third-party application which I am attempting to convert to emscripten.

Encountering a confusing 'Index out of bounds' error thrown from the JavaScript output of emscripten, specifically in the following code:

function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
  var sp = stackSave();
  try {
    return wasmTable.get(index)(a1,a2,a3,a4,a5);
  } catch(e) {
    stackRestore(sp);
    if (e !== e+0 && e !== 'longjmp') throw e;
    _setThrew(1, 0);
  }
}
The call to the function returned from wasmTable.get() throws the error. (I presume this is a call into WASM).

Not sure what index is out of bounds, as the value of 'index' is less than the length of wasmTable, so I'm guessing that it's something in the C++.

However the point at which the C++ crashes out with this error is not code which is attempting to do any indexing.

It occurs when a given C++ function (BundleAdjust()) returns, to another C++ function (BundleAdjustAll()).

As in, an error log message (written to stderr) at the end of BundleAdjust() does appear in the browser log, but another error log message in BundleAdjustAll(), immediately following the call to BundleAdjust(), does not.

Any suggestions for a debug strategy on this? In other words, is it likely to be due to an index-out-of-bounds error somewhere in the compiled C++ code?

Thanks.

nickw

unread,
Aug 1, 2021, 2:20:40 PM8/1/21
to emscripten-discuss
Just to follow up - maybe the stack is getting corrupted? (In the sense that a crash occurs on return from a function)
Reply all
Reply to author
Forward
0 new messages