#1963 closed defect (fixed)

_RBTree_Container_of macro is broken

Reported by: Gedare Bloom Owned by: Ralf Corsepius
Priority: normal Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: joel.sherrill@…, gedare@…, seb@… Blocked By:


Reposting from the rtems-users ml:
From: Werner Almesberger <werner@…>
Reply-To: Milkymist One, Milkymist SoC and Flickernoise developers' list <devel@…>
To: Milkymist One, Milkymist SoC and Flickernoise developers' list <devel@…>

I'm looking at diffs between the CVS version of RTEMS and the version
in our SDK. One change in cpukit/score/include/rtems/score/rbtree.h
looks highly suspicious. Below is a patch that should improve it.

There seem to be two issues in the original code:

  • the "node" argument of the macro is not protected, which could lead to very hard to find errors (this doesn't seem to cause any immediate problems just now, but it's a lousy risk to take)
  • more seriously, "offsetof" counts in bytes while arithmentic on the "node" pointer counts in multiples of whatever size that object has
  • Werner


sptests/sprbtree01 is in fact broken due to the bad arithmetic with offsetof. The attached patch fixes both problems raised by Werner. sprbtree01 now terminates correctly.

Attachments (1)

rtems-cvs.diff (744 bytes) - added by Gedare Bloom on 11/12/11 at 21:29:54.
Fix _RBTree_Container_of macro

Download all attachments as: .zip

Change History (7)

Changed on 11/12/11 at 21:29:54 by Gedare Bloom

Attachment: rtems-cvs.diff added

Fix _RBTree_Container_of macro

comment:1 Changed on 11/12/11 at 21:33:53 by Gedare Bloom

attachments.ispatch: 01
attachments.mimetype: application/octet-streamtext/plain

comment:2 Changed on 11/12/11 at 21:35:31 by Gedare Bloom

Owner: changed from Joel Sherrill to Ralf Corsepius

comment:3 Changed on 11/13/11 at 23:15:12 by Joel Sherrill

Cc: gedare@… joel.sherrill@… added

comment:4 Changed on 11/25/11 at 14:42:53 by seb

Cc: seb added

comment:5 Changed on 11/26/11 at 17:15:56 by Gedare Bloom

Resolution: fixed
Status: newclosed

Replying to comment:3:

Patch is fine. Apply.

Committed. Closing.

comment:6 Changed on 11/24/14 at 18:58:28 by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

Note: See TracTickets for help on using tickets.