WHY is this crashing???!!!
der Mouse
mouse at thunder.mcrcim.mcgill.edu
Tue Jun 11 15:13:39 AEST 1991
In article <6246 at mahendo.Jpl.Nasa.Gov>, robert at triton.jpl.nasa.gov (Robert Angelino) writes:
> I have this code that keeps going out to lunch.
[...code which doesn't mention `date' anywhere...]
> date->tm_year = atoi(ptr);
> It CRASHES at the "atoi" call.
I think it far likelier that the atoi call works perfectly well and the
assignment fails, probably because date is a null pointer.
> This is the output I get from the run:
> %SYSTEM-F-ACCVIO, access violation, reason mask=04, virtual address=00000014, PC=0000D8D9, PSL=03C00000
> %TRACE-F-TRACEBACK, symbolic stack dump follows
[...]
This makes it even more likely. The virtual address given is 0x14,
which is precisely what you'd see for the tm_year member of a null
pointer to struct tm. (The tm_year is the 6th int in the structure on
most machines, and on a VAX that normally translates into an offset of
0x14 from the beginning of the structure.)
> I've tried the following and it still crashes:
> cur_time[11] = '\0';
> ptr = cur_time + 7;
> date->tm_year = atoi((const char*) ptr);
I imagine date is still a null pointer; if so, diddling with atoi won't
do squat.
der Mouse
old: mcgill-vision!mouse
new: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.lang.c
mailing list