comp.lang.c FAQ list
·
Question 16.4
Q:
I have a program that seems to run correctly,
but
it
crashes as it's exiting,
after
the last statement in main().
What could be causing this?
A:
There are at least three things to look for:
- If a semicolon in a previous declaration is missing,
main
might be inadvertently declared as returning a structure,
conflicting with the run-time startup code's
expectations.
See
questions 2.18,
10.9,
11.12b,
and 11.14a.
- If
setbuf or setvbuf
is called,
and if the supplied buffer
is an automatic, local variable of main
(or any function),
the buffer may not exist any more
by the time the stdio
library tries to perform
its final
cleanup.
- A
cleanup function
registered by atexit
may have an error.
Perhaps it is
trying to reference data
local to main
or to some other function
which no longer exists.
(The second and third problems
are actually closely related to
question 7.5a;
see
also question
11.16.)
References:
CT&P Sec. 5.3 pp. 72-3
about this FAQ list
about eskimo
search
feedback
copyright
Hosted by