DIT112-V20 / group-09

Apache License 2.0
4 stars 1 forks source link

Mismatching ABI between ArduinoRuntime and the rest of the targets #71

Closed AeroStun closed 4 years ago

AeroStun commented 4 years ago

Direct cause of this CI failure

AeroStun commented 4 years ago

Update: within a single stacktrace, two frames accessing the same address obtain different results image image

AeroStun commented 4 years ago

Only possible explanation is that the DLL somehow ends up with a different virtual memory space, but this is supposedly impossible since previous demos have demonstrated that user-code actions can be observed by the main thread

AeroStun commented 4 years ago

Better yet, with Clang: from a single stack frame, depending on how the pointer to the object is accessed, different results are obtained (see that from the lambda I get a pin_modes of size 1, and from the global, which points at the same address, I get a pin_modes of size 0) image

AeroStun commented 4 years ago

Update: tried setting an x86 hardware watchpoint using LLDB on board_info->pins_caps._M_impl._M_start (yes I use libstdc++), and the watchpoint does not fire

AeroStun commented 4 years ago

We have reached a whole other level image

AeroStun commented 4 years ago

It only gets better... Screenshot_20200518_002130

For those who don't read hex, basically the memory shows a vector containing one element, but somehow the evaluation (and the runtime code) believes that it reads three consecutive NULLs in memory (which is obviously not the case since otherwise the whole highlighted memory would be full of only 00s)

AeroStun commented 4 years ago

Have I mentioned that debuggers are useless? image

platisd commented 4 years ago

This seems like the definition of an undefined behavior. Is there something that's not initialized perhaps?

AeroStun commented 4 years ago

Undefined behavior does not affect operator sizeof since its operands are unevaluated (only the type of the expression is used) I suspect that LLDB is trying to JIT some of its evaluations with different build options

EDIT: suspicion confirmed: LLDB does seem to be doing some broken dark magic resulting in two completely different evaluation contexts, where one is based on the debug symbols, and the other on some JIT-compiled snippets using the wrong compiler options

AeroStun commented 4 years ago

Next assumption: broken ABI

AeroStun commented 4 years ago

CONFIRMED: broken ABI

AeroStun commented 4 years ago

Morale of the story: too much debugging kills the debugging And second morale is that debuggers can't be trusted since they don't tell the user how they got the results from expression evaluation; only Valgrind stands trustworthy