> From: Brian Kirkland/CADC Designer <[EMAIL PROTECTED]>
> 
> I have a simple C program which I can compile with the
> simple command:
> 
>  gcc cluster.c -lm
> 
> and it compiles fine on both Solaris and RH 5.0.
> 
> However, it only runs on Solaris. On RH 5.0, it
> runs part way and then crashes with:
> 
> Segmentation violation
> 
> as the error. I have tried this with the stock gcc from RH5.0
> and the egcs  in the contrib directory. Anybody know what is up
> here? I suspect it is the glibc but I am not knowledgable enough
> on C to track down the problem. So I am looking for suggestions
> as to what the problem could be and/or how to track it down, that
> is, do I use gdb or something like that to find out what's causing
> the Seg. fault?


Just because it runs under Solaris and not RH 5.0 does not mean it's a
bug in glibc.  It may be a bug in your code that doesn't cause
problems on Solaris but does on the Linux version.  Invalid memory
accesses are very often the cause of these types of problems (and
segmentation violation certainly suggests an invalid memory access).
Invalid memory accesses can even cause your program to run correctly
sometimes and crash other times on the same machine.

Use a debugger (e.g., gdb) to track down where it crashes or if you
aren't comfortable with a debugger, place output statements throughout
your code to try to figure out where it is crashing (be certain to use
fprintf(stderr, not printf since printf is buffered output.  Also, the
problem may not be where the program crashes.  Corrupting memory
earlier can cause problems later in the code.  Memory errors are one
of the most difficult types of errors to track down.

Dave
[EMAIL PROTECTED]


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to