Segmentation fault

D

diyanat

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
 
A

Andreas Kahari

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.
 
C

Chris Dams

Hello,

(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
 
D

Darrell Grainger

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top