-
Notifications
You must be signed in to change notification settings - Fork 42
Description
When trying to run mars on aarch64, mars segfaults once ODE starts its simulation. The root cause is a misstated assertion in ode, but there is also a fault in mars itself.
The segfault happens when ode calls its dDebug function, which then calls whatever has been assigned to odes debug_function, which happens to be mars::sim::myDebugFunction. Since dDebug is marked noreturn, when it would try to return(which triggers undefined behavior), the compiler instead put in a call to dMessage(which happens to be the next function in the file), which then has an incorrect stack/parameter layout and causes the segfault later(char const *msg parameter is 1).
Since dDebug does not prevent returning if a debug_function is present, i conclude that the debug_function is supposed to not return, thus, mars::sim::myDebugFunction (and mars::sim::myErrorFunction) should not return.
The issue in ode-16 is that they assumed ~((atomicord32)0) equals 0xffffffff, while it does equal -1(atomicord32 is an int32_t in this case). Thus, dICHECK(nj < ~((atomicord32)0) / dJCB__MAX) always triggers.
Apart from that, runs great, if not very fast.