Troubleshooting
SOAR Errors
SOAR-L ERROR “Unknown module …”
When declaring a Wasm module by extending WasmModule, ensure there is a corresponding .wasm file in the classpath.
An error in SOAR-L might occur if the Wasm file is missing.
Failure to do so may result in the following error:
soar2-r/do:
[soar2-r] 1 : SOAR-L ERROR :
[soar2-r] [M403] - Unknown module 'my_module.wasm' (module is bound to the Java type 'com.mycompany.MyWebAssemblyModule').
[soar2-r]
SOAR-L ERROR “Unsupported WebAssembly instruction …”
Not all WebAssembly instructions are supported.
If your Wasm file uses an unsupported instruction, you might encounter a SOAR-L error, for example:
soar2-r/do:
[soar2-r] 1 : SOAR-L ERROR :
[soar2-r] [M401] - Unsupported WebAssembly instruction: '0xc0' (i32.lt_s) in function 'my_function' in module '/path/to/mymodule.wasm'.
SOAR-L ERROR “Unknown method ‘…’
Java methods called from C source code has to follow the right Java method signature convention. An error in SOAR-L might occur if the Java method is not found.
Failure to do so may result in the following error:
soar2-r/do:
[soar2-r] 4 : SOAR-S ERROR :
[soar2-r] [M57] - Unknown method 'com.mycompany.MyWebAssemblyModule.delay(long)void' (caused by an import function in the Wasm module 'my_module.wasm' bound to the class 'com.mycompany.MyWebAssemblyModule').
SOAR-L ERROR “Cannot find the exported function ‘…’ bound to …”
When declaring an instance native method on a WasmModule subclass, ensure there is a corresponding exported Wasm function with the right signature in the associated Wasm module.
An error in SOAR-L might occur if no exported function matching the Java method signature is found.
Failure to do so may result in the following error:
soar2-r/do:
[soar2-r] 1 : SOAR-L ERROR :
[soar2-r] [M407] - Cannot find the exported function 'factorial' bound to the method 'com.mycompany.MyApp.factorial(int)int'.
S3 ERROR “Inconsistent Mock implementation: ….”
Please be aware that Managed C code is not currently supported in simulations.
Running code containing Managed C in a simulation will prompt an error similar to this:
ERROR: Inconsistent Mock implementation: the type 'com/mycompany/Module' cannot be loaded from the HIL classpath (java.lang.ClassNotFoundException:com.mycompany.Module).
Runtime Errors
java.lang.OutOfMemoryError
If you encounter a stack trace like the following, there is insufficient space in the Managed Heap to allocate a Wasm module linear memory. Increase the Managed Heap size or reduce the linear memory size of the Wasm module.
java.lang.OutOfMemoryErrorM:0x808d2c8:0x808d2d3@
at com.mycompany.MyApplication.<clinit>(Unknown Source)
at java.lang.Thread.execClinit(Unknown Source)
at java.lang.Thread.clinitWrapper(Thread.java:484)
at java.lang.Thread.callWrapper(Thread.java:450)
java.lang.AssertionError
If you encounter an exception like the following (without stack trace), you are executing an unreachable instruction.
Exception in thread "main" java.lang.AssertionError
java.lang.ArrayIndexOutOfBoundsException when using a pointer
If you encounter a stack trace like the following, you are trying to access an address outside of the linear memory, which results in an out-of-bounds exception.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at com.mycompany.myapplication.TestOutOfBounds.wasm:sync:oob(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.oob(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.main(TestOutOfBounds.java:11)
at java.lang.MainThread.run(Thread.java:856)
at java.lang.Thread.runWrapper(Thread.java:465)
malloc returns NULL
If malloc returns NULL, the heap in the linear memory is full.
The linear memory never grows, so memory.grow fails and malloc cannot get more memory.
Increase the initial linear memory size of the Wasm module.
Unexpected java.lang.ArrayIndexOutOfBoundsException in call stack trace
If you encounter a stack trace like the following, you have likely reached the lower bound of the linear memory. The code execution stops while attempting to load or store data in the stack due to a computed negative offset.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:$recursiveCall0(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.wasm:sync:recursiveCall(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.recursiveCall(Unknown Source)
at com.mycompany.myapplication.TestOutOfBounds.main(TestOutOfBounds.java:34)
at java.lang.MainThread.run(Thread.java:856)
at java.lang.Thread.runWrapper(Thread.java:465)
