[Bug 1963] New: _RBTree_Container_of macro is broken

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Sat Nov 12 22:29:55 UTC 2011


https://www.rtems.org/bugzilla/show_bug.cgi?id=1963

           Summary: _RBTree_Container_of macro is broken
           Product: RTEMS
           Version: HEAD
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: normal
          Priority: P3
         Component: cpukit
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: gedare at rtems.org


Created attachment 1375
  --> https://www.rtems.org/bugzilla/attachment.cgi?id=1375
Fix _RBTree_Container_of macro

Reposting from the rtems-users ml:
======
From: Werner Almesberger <werner at almesberger.net>
Reply-To: Milkymist One, Milkymist SoC and Flickernoise developers' list
<devel at lists.milkymist.org>
To: Milkymist One, Milkymist SoC and Flickernoise developers' list
<devel at lists.milkymist.org>

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.

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list