[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LCP]Address out of bounds error on Linux 7.3



Ajay Aggarwal wrote:
typedef struct {
  char* relative_link;
  char* keys[MAX_KEYS];
} stack_url;

<snip>


      /* Lock Mutex put here */
      for(myurl = wib_urls; myurl->relative_link != NULL; myurl++)
      {
        fprintf(stderr,"URL /%s\n",myurl->relative_link);
        for(kp = (myurl->keys); *kp != NULL; kp++  )
        {
           fprintf( stderr, "     %s \n", *kp );        ----------- FAILING ON THIS LINE AFTER FEW ITERATIONS

Just following up on emails given by others, I'd suggest that there's a bug in your code that SunOS isn't showing up, but Linux is. Electric fence would certainly help, since kp would appear to be incrementing itself out of bounds.


You inner loop here is relying on the last keys item being null. This appears not to be the case. To start with I'd put in an assertion such as:
assert(kp - myurl->keys < MAX_KEYS);
I suspect that this will fail at some point.


The NULL you're expecting to find might be disappearing for several reasons. Firstly, some other part of the code could have erroneously written out of bounds and overwritten it. Secondly, another thread may have come in and changed the array of keys before you got to the null (the difference in the Linux and SunOS schedulers might be the reason the bug doesn't show up on SunOS). There are numerous other reasons as well, but I'd probably look for these first.

--
Regards,
Paul Gearon

Software Engineer                Telephone:   +61 7 3876 2188
Plugged In Software              Fax:         +61 7 3876 4899
http://www.PIsoftware.com        PGP Key available via finger

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")