This is the mail archive of the
mailing list for the GCC project.
Re: seg fault on redirection
- To: Joe Buck <jbuck at racerx dot synopsys dot com>
- Subject: Re: seg fault on redirection
- From: Jiann-Ming Su <js1 at microwave dot ph dot msstate dot edu>
- Date: Tue, 28 Nov 2000 22:02:41 -0600 (CST)
- cc: gcc at gcc dot gnu dot org
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, email@example.com