* David Filion ([EMAIL PROTECTED]) wrote:
> I'm trying to compile a C program that I wrote on a Sun system
> but it won't work.  The code compiles and runs fine on the
> Sun server.  However, when I copy the code to my linux box
> (RH 6.0) from the Sun system via ftp and then try to work
> with it I have all kinds of problems. I can compile the
> code but the program causes a core dump when run.  Using
> Code Medic,  these are the two error messages I come across
> (one or the other but not both at the same time):

Well, this isn't really the forum for it. But the problem lies in your
code ;)

> 
> 1)
> Program received signal SIGSEGV Segmentation fault.
> 0x40075027 in strlen (str = 0x0 ) at ../sysdeps/i386/strlen.c:27
> ../sysdeps/i386/strlen.c:27 No such file or directory.

You are calling strlen on NULL. As a result of:

> 2)
> #0 strcpy (dest=0xbffff9e4 "É", src= 0x0) at ../sysdeps/generic/strcpy.c:37
> ../sysdeps/generic/strcpy.c:37: No such file or directory

You are copying a NULL string into what looks like garbage (unmalloced
memory or a char buffer which is uninitialised).

> The code is ANSI C compliant and contains no fancy tricks and nothing
> system dependant.

Looks like it doesn't do much parameter checking either ;)

Looking at the errors, and seeing no code at all, it is hard to say
what the problem is, but if it only shows up on one system and not
another, it doesn't mean it's the system's fault. It probably means
the input is different enough to trigger bugs in the code. I'd
re-examine your string handling code if I were you :)

Looking further into the backtrace would give more info. What do (3)
and (4) say? Trace back until one of your functions is called. I'd
start debugging there...

> Once or twice I managed to get the program to run but then
> it would crash if I edited then recompiled it.
> 
> Now for a twist.  If I create a program directly on my linux system,
> everthing works fine, no errors at all.
> 
> I'm using GNU gcc-2.95.2 on the linux box.  I'm not sure of the version
> on the UNIX system.
> 
> I'm starting to wonder if there are hidden charaters or
> something in the file format (ie. linux format vs unix vs dos)

linux file format == unix file format :)
Dos's strangeness is irrelevant here ;)

> that could be causing the problem.
> 
> Anyone have any ideas?
> 
> I want to be able to store the code in one location (the space allocated to
>  me by my ISP) and ftp it to where ever I happen to be. ie. copy it the SUN
> system and work on it there then copy it to the ISP then my linux system and
> work on it there.

Sounds like you need cvs ;)

> Thanks in advance.
> 
Tom.
-- 
            .-------------------------------------------------------.
    .^.     | Tom Gilbert, England | [EMAIL PROTECTED] |
    /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
   // \\    | Sites I recommend:   `--------------------------------|
  /(   )\   | www.freshmeat.net www.enlightenment.org slashdot.org  |
   ^^-^^    `-------------------------------------------------------'


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to