If this is the problem, the attached patch may help -- it turns the
reinterpret_casts in the serialization of primitives into memcpys, which
shouldn't require alignment.
Josh
On Thu, Jul 8, 2010 at 8:44 AM, René Wagner <
rene.wagner@dfki.de> wrote:
> On Thu, 2010-07-08 at 19:43 +0900, Daniel Stonier wrote:
> > Got into it with a debugger, and found it hanging at
> > roslib/include/ros/serialization.h at
> >
> >
> > ROS_CREATE_SIMPLE_SERIALIZER(double);
>
> Depending on how the serializer is used, this may result in an
> unaligned write. You can check whether an alignment error is involved
> as follows:
>
> echo 5 > /proc/cpu/alignment
>
> and re-run the executable that's causing trouble. The program should
> receive a signal (so you can see where exactly things go wrong in gdb)
> and the kernel should report an "Alignment trap: ..." on the console or
> in dmesg/syslog.
>
> Cheers,
>
> Rene
>
> --
> ------------------------------------------------------------
> Dipl.-Inf. René Wagner Junior Researcher
> DFKI Bremen Enrique-Schmidt-Str. 5
> Safe and Secure Cognitive Systems D-28359 Bremen
>
> Phone: (+49) 421-218-64224 Fax: (+49) 421-218-98-64224
> Web: http://www.informatik.uni-bremen.de/agebv/en/ReneWagner
> --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
> Firmensitz: Trippstadter Strasse 122, D-67663 Kaiserslautern
>
> Geschäftsführung:
> Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster (Vorsitzender)
> Dr. Walter Olthoff
> Vorsitzender des Aufsichtsrats:
> Prof. Dr. h.c. Hans A. Aukes
> Amtsgericht Kaiserslautern HRB 2313
> ------------------------------------------------------------
>
> _______________________________________________
> ros-users mailing list
> ros-users@code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
Index: include/ros/serialization.h
===================================================================
--- include/ros/serialization.h (revision 10273)
+++ include/ros/serialization.h (working copy)
@@ -172,12 +172,12 @@
{ \
template<typename Stream> inline static void write(Stream& stream, const Type v) \
{ \
- *reinterpret_cast<Type*>(stream.advance(sizeof(v))) = v; \
+ memcpy(stream.advance(sizeof(v)), &v, sizeof(v)); \
} \
\
template<typename Stream> inline static void read(Stream& stream, Type& v) \
{ \
- v = *reinterpret_cast<Type*>(stream.advance(sizeof(v))); \
+ memcpy(&v, stream.advance(sizeof(v)), sizeof(v)); \
} \
\
inline static uint32_t serializedLength(const Type t) \