#1964 closed defect (fixed)

_Chain_Is_first/last overshoot

Reported by: Gedare Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: score Version: 4.10
Severity: normal Keywords:
Cc: sebastian.huber@…, seb@… Blocked By:
Blocking:

Description (last modified by Gedare)

A user reported a possible problem with the implementation of the _Chain_Is_first/last functions:


Subject: [Milkymist-devel] [PATCH, tentative] RTEMS: _Chain_Is_first/last overshoot
Date: Wed, 9 Nov 2011 16:53:53 -0300
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@…>

Doubly-linked lists ("chains") in RTEMS have a "control" block that
looks like the next/prev link pair in an element. The list elements
link both ways to this control block.

_Chain_Is_first and _Chain_Is_last only probed if the link to the
next element - which would be the control block - is non-NULL.
Telling by the function description and given that there are already
functions called _Chain_Is_head and _Chain_Is_tail (which could be
simplified), this is probably not the intended behaviour.

This also affects the aliases rtems_chain_is_first and
rtems_chain_is_last.

These functions are not used a lot and I haven't seen any immediate
effect on M1 after changing them, so I can't say whether this patch
may unearth other problems.

  • Werner

Attachments (3)

spchain.diff (1.8 KB) - added by Gedare on Nov 12, 2011 at 9:59:00 PM.
Patch demonstrating bug
rtems-cvs.diff (676 bytes) - added by Gedare on Nov 12, 2011 at 10:00:25 PM.
Patch fixing bug.
sapichain.diff (657 bytes) - added by Gedare on Nov 14, 2011 at 3:23:16 PM.
check for null dereference in rtems chain api

Download all attachments as: .zip

Change History (11)

Changed on Nov 12, 2011 at 9:59:00 PM by Gedare

Attachment: spchain.diff added

Patch demonstrating bug

Changed on Nov 12, 2011 at 10:00:25 PM by Gedare

Attachment: rtems-cvs.diff added

Patch fixing bug.

Changed on Nov 14, 2011 at 3:23:16 PM by Gedare

Attachment: sapichain.diff added

check for null dereference in rtems chain api

comment:1 Changed on Nov 14, 2011 at 3:35:36 PM by Sebastian Huber

Cc: Sebastian Huber added

comment:2 Changed on Nov 14, 2011 at 4:23:53 PM by Gedare

attachments.isobsolete: 01

comment:3 Changed on Nov 25, 2011 at 2:43:25 PM by seb

Cc: seb added

comment:4 Changed on Nov 26, 2011 at 5:12:42 PM by Gedare

Status: newassigned

comment:5 Changed on Nov 27, 2011 at 3:09:41 PM by Joel Sherrill

Resolution: fixed
Status: assignedclosed

Committed.

comment:6 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare

Version: HEAD4.11

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

comment:7 Changed on Jan 10, 2018 at 2:36:07 PM by Gedare

Description: modified (diff)
Version: 4.114.10

I ran over this on 4.10.2 also. I will plan to fix it on the 4.10 branch pending 4.10.3.

comment:8 Changed on Jan 10, 2018 at 2:49:05 PM by Gedare Bloom <gedare@…>

Last edited on Mar 23, 2018 at 2:47:23 PM by Gedare (previous) (diff)
Note: See TracTickets for help on using tickets.