Re: Wired binary behavior
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Mon, 27 Aug 2007 08:09:54 GMT
Ark Khasin <akhasin@xxxxxxxxxxxxxxxxxxxx> wrote:
Walter Roberson wrote:
In article <slrnfd401v.4br.spamoff@xxxxxxxxxxxxxx>,
Kris Garrett <kg@xxxxxxxxxx> wrote:
On AIX-4.3.3 using xlc v5.0, I observe the following madness:
Results in "Illegal instruction(coredump)" upon exiting (via return 0).
The program does run to completion, but looks as if it somehow returns
to a non-valid address. The wired part is that if the above code is
changed to:
The program runs to completion without coredumping on an illegal
instruction.
My question is why would the order of declarations effect the stability
of an executable? Non-deterministic behavior == a bad day.
The order of declarations affects, on most implementations, the
order in which variables are allocated on a stack. Some implementations
bother to sort by size or by alignment (in hopes of packing better),
but some just put the variables on a stack either in the order
declared or in the reverse of the ordered declared.
Therefore, if you happen to be overwriting an array or before the end
of an array or writing into free memory, whether you have allocated
a variable or not in a certain relative location in the code can
affect exactly what happens to be at the place being overwritten,
and thus can affect whether you see an obvious crash or not.
In fact, I would say - as a first, not completely informed guess - that
somewhere in the OP's [..snipped..] code he scribbles past the end of
ifxsrv[], the array in question.
If your assessment is correct, so is my claim that arrays on stack are
evil.
No, that claim is not correct. Writing past the end of an array is evil,
regardless of where and how that array is declared.
Richard
.
- References:
- Wired binary behavior
- From: Kris Garrett
- Re: Wired binary behavior
- From: Walter Roberson
- Re: Wired binary behavior
- From: Ark Khasin
- Wired binary behavior
- Prev by Date: Re: Malcolm's new book - Chapter 1 review
- Next by Date: Re: Final Year B.E Project
- Previous by thread: Re: Wired binary behavior
- Next by thread: Re: Wired binary behavior
- Index(es):
Relevant Pages
|