Alignment fault in pvDataCPP
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
Undecided
|
mdavidsaver |
Bug Description
We experienced a (reproduceable) crash of pvData on RTEMS/powerpc.
I tracked it down to the ByteBuffer (de-)serialization code which
does IMHO ugly things:
class ByteBuffer {
char *position;
...
template <typename T>
inline void put(T value)
{
...
*((T*)position) = value;
}
};
PLEASE: don't code like this.
The template was instantiated for a 'double' value and -- since this is a 'byte buffer' -- it is obvious that the 'position' pointer does not meet any alignment constraints.
The PowerPC (and possibly other machines, too) cannot store floating-point registers to unaligned addresses and the type cast invites the compiler to generate inappropriate code (claiming that 'position' is a valid 'double*' which in fact is not necessarily true).
During compilation I had also seen several 'breaking strict alias rule' warnings flying by (albeit not for this particular code, of course) -- but after seeing the above code I would recommend to study such warnings carefully.
Changed in epics-base: | |
assignee: | nobody → mdavidsaver (mdavidsaver) |
status: | New → Triaged |
Changed in epics-base: | |
milestone: | none → 7.0.2 |
status: | Triaged → Fix Committed |
Changed in epics-base: | |
status: | Fix Committed → Fix Released |
> ByteBuffer (de-)serialization code which does IMHO ugly things:
Agreed...
Can you provide a stack-trace?