Skip to content

Trouble with myDebugFunction on aarch64 #131

@pierrewillenbrockdfki

Description

@pierrewillenbrockdfki

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.

@malter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions