seg.faults in the middle of nowhere...

by Kyle Matthews <jits(at)ihug.co.nz>

 Date:  Sun, 05 Mar 2000 23:10:43 +1300
 To:  hwg-languages(at)hwg.org
  todo: View Thread, Original
Hi,

I'm still chasing some nasty bug on a C CGI database. I've tracked it down to:

    printf("%s\n", line);
                                 <---- in between these two lines.
    printf("b");

here's the output from shell:

103    1       19990514                                2402 /* this here is
the string "line" */
                                                            /* obviously
the text char "b" doesn't print */

Segmentation fault (core dumped)

the database is a series of sport results. the difference with this line is
that it's a 'bye' - the 2402 is a team number, there would normally be more
data out to the right, including a second team. I don't see however how
printing the string of the whole line would cause it to crash.

Line is defined as:

char line[256];

The 256 char limit is not breached here. It's the string which takes each
data item and is used for parsing.

Can anyone offer me any suggestions as to what I'm doing here? What causes
a binary to dump in between printing a string, and the next line? missing
EOL character? line has only just been read in from a line-per-record
tab-deliminated text file.

If anyone wants a closer look, I can send more of the code. Desperate pleas
for help solving seriously overdue project go here.

Kyle

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA