Ticket #1256 (closed defect: worksforme)

Opened 14 months ago

Last modified 10 days ago

CGI in C - 500 Error - cygwin

Reported by: anonymous Owned by: jan
Priority: normal Milestone: 1.5.0
Component: core Version: 1.4.15
Severity: normal Keywords:
Cc: Blocked By:
Need User Feedback: no Blocking:

Description

Hi,

I am testing a simple CGI executable written in C. (NOT FCGI).


#include <stdio.h>

int main(void) {

printf("content-type: text/html\n\n"); printf("cgi c\n"); return(0);

}


cc -o test.xx test.c


#### CGI module cgi.assign = ( ".pl" => "/usr/bin/perl",

".xx" => "" )


With the above I get a 500 error

127.0.0.1 127.0.0.1 - [02/Jul/2007:19:15:24 +0000] "GET /test.xx HTTP/1.1" 500 369 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"


I am running lighthttpd 1.4.9-1 unde cygwin.

Thanks

Attachments

Change History

Changed 14 months ago by darix

can you try:

#include <stdio.h>

int main(void)
{
  printf("Content-Type: text/plain\r\n");
  printf("\r\n\r\n");
  printf("cgi c\n");
  return(0);
}

and do you get any messages in the error log?

Changed 14 months ago by anonymous

sorry, still the same. carriage return and newline did not make a difference


#### CGI module cgi.assign = ( ".pl" => "/usr/bin/perl",

".cgi" => "/usr/bin/perl", ".xx" => "" )


#include <stdio.h>

int main(void) {

printf("Content-Type: text/plain\r\n"); printf("\r\n\r\n"); printf("cgi c\n"); return(0);

}


cc -o test.xx test.c


access.log

127.0.0.1 127.0.0.1 - [03/Jul/2007:07:47:34 +0000] "GET /test.xx HTTP/1.1" 500 369 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"


nothing in error log


Changed 14 months ago by justinmteal

i've got a similar problem with perl, but it's a less simple script than that. the script is, however less complex than another script i have that runs just fine.

access.log :

192.168.1.1 jmteal.dyndns.org - [05/Jul/2007:17:58:15 -0400] "GET /~teal/cgi-bin/percup.cgi HTTP/1.1" 500 369 "http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4" 192.168.1.1 jmteal.dyndns.org - [05/Jul/2007:18:07:05 -0400] "GET /~teal/cgi-bin/percup.cgi HTTP/1.0" 500 369 "http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" "w3m/0.5.1+cvs-1.968"

nothing in error.log

"http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" has a link to the offending script at the bottom that will let you view the code.

What makes it weird is that if i reload a few times, it works intermittently!

any help appreciated!

Changed 14 months ago by anonymous

it's not the same problem as my C cgi executable.

--

according to your description, your percup perl script is getting intermittent "400" response. "400" is:

10.4.1 - 400 Bad Request The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

--

My C cgi executable is getting a "500" response. "500" is

10.5.1 - 500 Internal Server Error The server encountered an unexpected condition which prevented it from fulfilling the request.

--

Changed 14 months ago by anonymous

no no... read the access.log. it's a 500 i'm getting. if the problem was in my script, i would assume it would never work. it just works intermittently.

Changed 14 months ago by teal.justin.m@…

weird. the first line that the script printed:

print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";

same as another script that works every time. for some reason lighttpd really hated this line. every page on my site starts with that, but it kept giving me a 500 90% of the time with this script. any ideas?

Changed 4 months ago by cpl160 at gmail.com

i am getting 500 errors running a cgi binary 'hello.exe' compiled from 'hello.c' (see link below) using gcc 3.4.4 and serving on lighttpd-1.4.18 / cygwin 1.5.25 / winxpsp2 (see link below) with lighttpd.conf cgi.assign '.exe' => ""

a similar 'hello.cgi' (#!/bin/sh) bash shell script serves fine using the same configuration with lighttpd.conf cgi.assign '.cgi' => ""

ua tested were ff3.0b5 and ie7.0.5739.11. happy to do more in-depth trouble-shooting if helps.

reference

strace http://pastebin.com/f29b29978 (request for 'hello.exe')

hello.c http://pastebin.com/fa9ffd57 (source for 'hello.exe')

Changed 10 days ago by stbuehler

  • status changed from new to closed
  • resolution set to worksforme

There have been many changes in mod_cgi and it works for me.

Please reopen if you still have problems.

Add/Change #1256 (CGI in C - 500 Error - cygwin)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.