Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtrap: misaligned address #146

Open
jozhalaj opened this issue May 20, 2020 · 0 comments
Open

libtrap: misaligned address #146

jozhalaj opened this issue May 20, 2020 · 0 comments

Comments

@jozhalaj
Copy link

jozhalaj commented May 20, 2020

Hi,

I'm working on an IoT detector using a nemea-framework. The detector works fine on the x86 architecture, but when tested on a Turris router with OpenWRT and an ARM processor, it crashes on a Bus Error when receiving a message and then retrieving message items using the ur_get () macro. Crashes only occur when compiler optimization is turned on. This line of code causes crash.

ZWaveDetector.cpp:236: double event_type = ur_get(in_events_template, in_record, F_EVENT_TYPE);

I tried compilation using clang with a sanitizer. I got this output after sending UniRec message to detector:

ZWaveDetector.cpp:235:26: runtime error: load of misaligned address 0x63300001c84a for type 'ur_time_t' (aka 'unsigned long'), which requires 8 byte alignment
0x63300001c84a: note: pointer points here
00 00 f0 3f 22 db f9 1e 54 27 c5 5e 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ZWaveDetector.cpp:235:26 in

ZWaveDetector.cpp:236:24: runtime error: load of misaligned address 0x63300001c81a for type 'double', which requires 8 byte alignment
0x63300001c81a: note: pointer points here
00 00 00 00 00 00 00 00 00 00 32 40 00 00 00 00 00 00 00 00 00 00 20 49 84 32 ec 41 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ZWaveDetector.cpp:236:24 in

You can reproduce it with following sequence of commands:

$ git clone https://github.com/CESNET/NEMEA-SIoT.git
$ git checkout libtrap-bug-reproduce
$ cd zwave-detector
$ ./bootstrap.sh
$ ./configure CXX=clang++ CXXFLAGS=-fsanitize=address,undefined
$ make
$ logreplay -f test_input.csv -i u:events &
$ ./siot-zwave-detector -i u:frames,u:events,u:alerts

Strict aliasing issues may cause bus errors on ARM architecture, so it seems to me that the issue can be conected with the problems reported by ASan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant