#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 Nov 12, 2011 at 9:29:54 PM.
Fix _RBTree_Container_of macro

Download all attachments as: .zip

Change History (7)

Changed on Nov 12, 2011 at 9:29:54 PM by Gedare Bloom

Attachment: rtems-cvs.diff added

Fix _RBTree_Container_of macro

comment:1 Changed on Nov 12, 2011 at 9:33:53 PM by Gedare Bloom

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

comment:2 Changed on Nov 12, 2011 at 9:35:31 PM by Gedare Bloom

Owner: changed from Joel Sherrill to Ralf Corsepius

comment:3 Changed on Nov 13, 2011 at 11:15:12 PM by Joel Sherrill

Cc: gedare@… joel.sherrill@… added

comment:4 Changed on Nov 25, 2011 at 2:42:53 PM by seb

Cc: seb added

comment:5 Changed on Nov 26, 2011 at 5:15:56 PM by Gedare Bloom

Resolution: fixed
Status: newclosed

Replying to comment:3:

Patch is fine. Apply.

Committed. Closing.

comment:6 Changed on Nov 24, 2014 at 6:58:28 PM 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.