Segmentation fault

Discussion in 'C Programming' started by diyanat, Sep 30, 2003.

  1. diyanat

    diyanat Guest

    i am writing a cgi script in C using the CGIC library, the script
    fails to run, i am using apache on linux

    error report from apache : internal server error

    [error] Premature end of script headers: /var/www/cgi-bin/script.cgi

    when i debug the program i get Segmentation fault

    gdb ./script.cgi

    (gdb) run
    Starting program: /var/www/cgi-bin/script.cgi
    Content-type: text/html


    Program received signal SIGSEGV, Segmentation fault.
    0x4206c306 in fread () from /lib/i686/libc.so.6

    (gdb) backtrace
    #0 0x4206c306 in fread () from /lib/i686/libc.so.6
    #1 0x0804e345 in cgiMain ()
    #2 0x0804952b in main ()
    #3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6

    any help would be appreciated

    diyanat
     
    diyanat, Sep 30, 2003
    #1
    1. Advertising

  2. In article <>, diyanat wrote:
    > i am writing a cgi script in C using the CGIC library, the script
    > fails to run, i am using apache on linux

    [cut]
    > #0 0x4206c306 in fread () from /lib/i686/libc.so.6

    [cut]

    Without any code it's impossible to figure out what's happening.
    A wild guess is that the fread() is reading stuff into a too
    small buffer.


    --
    Andreas Kähäri
     
    Andreas Kahari, Sep 30, 2003
    #2
    1. Advertising

  3. diyanat

    Chris Dams Guest

    Hello,

    (diyanat) writes:

    >(gdb) run
    >Starting program: /var/www/cgi-bin/script.cgi
    >Content-type: text/html


    >Program received signal SIGSEGV, Segmentation fault.
    >0x4206c306 in fread () from /lib/i686/libc.so.6


    If you do not post a minimal version of your program that has this problem,
    it is implossible to tell what exactly is wrong. You can get a segmentation
    fault if you use an array or vector and use a subscript that is out of
    bounds. Generally you get a segmentation fault if you try to read memory
    that you do not own. Often a segmentation fault appears near the spot where
    the mistake was made, but this is not necesarily the case. Without code
    hardly anything further can be said.

    Good luck,
    Chris Dams
     
    Chris Dams, Sep 30, 2003
    #3
  4. Jonathan Mcdougall, Sep 30, 2003
    #4
  5. On Tue, 30 Sep 2003, diyanat wrote:

    > i am writing a cgi script in C using the CGIC library, the script
    > fails to run, i am using apache on linux


    Not relevent.

    > error report from apache : internal server error
    >
    > [error] Premature end of script headers: /var/www/cgi-bin/script.cgi


    Not relevent.

    > when i debug the program i get Segmentation fault


    This is something C related.

    > gdb ./script.cgi
    >
    > (gdb) run
    > Starting program: /var/www/cgi-bin/script.cgi
    > Content-type: text/html
    >
    >
    > Program received signal SIGSEGV, Segmentation fault.
    > 0x4206c306 in fread () from /lib/i686/libc.so.6


    On a guess, you passed a bad parameter to fread(). If the first parameter
    is an uninitialized pointer, the second or third parameter exceed the
    array size or the FILE pointer is not properly initialized (e.g. file
    failed to open).

    > (gdb) backtrace
    > #0 0x4206c306 in fread () from /lib/i686/libc.so.6
    > #1 0x0804e345 in cgiMain ()
    > #2 0x0804952b in main ()
    > #3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
    >
    > any help would be appreciated


    This is all the help I can give. Without the source code I am only able to
    guess.

    --
    Send e-mail to: darrell at cs dot toronto dot edu
    Don't send e-mail to
     
    Darrell Grainger, Sep 30, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    17
    Views:
    896
  2. Pud
    Replies:
    0
    Views:
    608
  3. Replies:
    0
    Views:
    574
  4. Ivan Vecerina
    Replies:
    0
    Views:
    507
    Ivan Vecerina
    Jun 29, 2003
  5. Vasileios Zografos

    Re: segmentation fault exception handling

    Vasileios Zografos, Jun 30, 2003, in forum: C++
    Replies:
    5
    Views:
    15,749
    Pete Becker
    Jul 1, 2003
Loading...

Share This Page