Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

ros (de)serialization is not multi-arch safe  #184

@tfoote

Description

@tfoote

From Peter Rudolph on ROS Users: https://code.ros.org/lurker/thread/20130303.105941.7106c801.en.html

He guys!
I tried to solved and it seems solved! First i will explain the problem itself: while de-/serializing unaligned pointercasts are done. normally this is not a problem! but since newer versions of arm-gcc use float support with options -mfloat-abi=hard/softfp, there are many possibilities to hit this alignment fault, because NEON instructions must be aligned! This is a very big problem... compiling ROS with -Wcast-align shows the potential lines! Solving this by setting "-mno-unaligned-access" as compiler-flag does NOT work! Every prebuilt-compiler i used seemed to ignore this switch.

example from www, demonstrates the error (compile it w/o any optimization(-O0), else compiler will re-align the pointercast, but this won't work for ROS, since everything is built w/ optimization(-O2)):

include <stdio.h>

int main(int argc, char* argv[])
{
char attribute ((aligned(32))) buffer[8] = { 0 };
float* fval_p;

fval_p = (float*)&buffer[1];
*fval_p = 0.1234;

printf("\nfloat at &buf[1] is %f\n", *fval_p);

return 0;

}

Build my own example from this, to check what works correctly and serious...

Only possibility was to hack the correct lines in roscpp_serialization. I only changed the lines from pointercasts to simple memcpy's and now everything seems to work fine! No alignment faults, no bus errors, no kernel exceptions! Tried a lightweight openni version, my own robot stack, and gmapping! navigation stack will follow!

Due to having no time now, patchfile will follow, too!

Regards,
sem23

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions