seg fault on redirection
Jiann-Ming Su
js1@microwave.ph.msstate.edu
Tue Nov 28 20:03:00 GMT 2000
On Tue, 28 Nov 2000, Joe Buck wrote:
>
> > What would cause a program to seg fault when the output is redirected
> > to a file but run file otherwise?
>
> We could all try to come up with clever answers ... or you could tell us
> how you did it (what compiler, what platform, test case etc).
>
Actually what it turned out to be was an uninitialized pointer.
Within the function a pointer was declared. It is suppose to
be used as a return value from another function. I ended up
changing it to just a regular unsigned long variable and passed
the address of it to the other function.
That doesn't explain why it would bomb when the output was redirected
to a file, especially since it had worked before I made changes to
another part of the code that should have been unrelated.
Either way, the original implementation was poor, IMO. Having
uninitialized pointers is probably just bad. I probably could have
just passed the address of the pointer to the function that would
use it as a return value, but the current implementation is fine.
--
Jiann-Ming Su, js1@microwave.ph.msstate.edu
More information about the Gcc
mailing list