Strange core dump problem

Has anybody seen this behavior before?
In a cron job, swish-e runs, creates an index, but dies before printing
the statistics with a Segmentation fault and a core dump.
Enabling debugging allowed me to track down the fault to a core dump
*in the exit() routine*!
The statistics are not being generated because (probably) the exit()
routine has not flushed stdout yet (stdout is redirected, and so
is buffered. Perhaps from the command line it would be line-buffered
and become visible.)
I changed the last few lines of the section of swish.c which actually
does the indexing to read:
printf("Indexing done!\n");
}
#ifdef INDEXPERMS
chmod(indexlist->line, INDEXPERMS);
#endif
fflush(stderr);
fflush(stdout);
exit(0); /* Note: seg faults _here_ */
This allowed me to get the following output:
Writing main index... 65055 unique words indexed.
Writing file index... 3577 files indexed.
Running time: 15 minutes, 28 seconds.
Indexing done!
The size of the resuling index file is 11,278,609 bytes.
The code closes the index file before reaching this point, so the
index file itself is not corrupted. What's going on?
This is under BSDI BSD/OS 3.1 on a Pentium-class machine with
64MB RAM and 786MB swap.
Or is this an operating system bug?
Thanks, Tom