#365 Value reused from registers after change

closed-fixed
7
2013-05-25
2002-07-27
No

I ran into a nasty bug where a value read from a pointer to
a struct is held in registers and used again (rather than
derefereing the pointer again) after the pointer is
passed to
a function that changes the value.

Here's some sample code that reproduces the problem:

http://www.pjrc.com/tmp/p.c

The specific code is:

if (list->next_random == 0)

randomize_incremental_one_list(simm_id_from_pointer(list));
// BUG: value of "list->next_random" previously
stored in registers is
// passed to "addr6", even though the pointer
"list" was passed to
// the "simm_id_from_pointer" function can write to
that struct and
// change this value.
return ((playlist_list_t
*)addr6(list->next_random))->playlist_start_sequential;

SDCC reads the value while evaluating the if condution,
and then uses those registers when calling addr6, even
though the code executed when the value is zero will
change it.

I tested this with a fresh checkout from CVS today
(July 27, 2002)

Paul

Discussion

  • Johan Knol

    Johan Knol - 2003-01-07

    Logged In: YES
    user_id=63512

    This is a nice but tricky one. list is removed from the cseSet
    but list->next_random has already an iTemp (@-ed from list +
    structureOffset) but is not removed.

    Wonder why this doesn't happen in model-small.

     
  • Johan Knol

    Johan Knol - 2003-01-07
    • priority: 5 --> 7
     
  • Erik Petrich

    Erik Petrich - 2003-11-15
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     
  • Erik Petrich

    Erik Petrich - 2003-11-15

    Logged In: YES
    user_id=635249

    Fixed in src/SDCCdflow.c 1.12

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks