Forum

Segfault reading config file in 6.5

Bob
11 March 2008, 20:32
With the following httpd.conf:
Hostname = 192.168.9.1
WebsiteRoot = /var/www-docroot

Binding {
Port = 80
}

FastCGIserver {
FastCGIid = Test
}


there is a segfault when I start hiawatha:

 ./hiawatha -k -c etc/hiawatha/
Using etc/hiawatha/
Reading httpd.conf
do_page_fault() #2: sending SIGSEGV to hiawatha for invalid read access from
00000000 (epc == 00413178, ra == 004130ac)


any idea?
Raphaël HUCK
11 March 2008, 21:13
I've spotted the problem after recompiling with -g and having a look at objdump -S

The problem occurs in serverconfig.c around line 1584:

case fcgi_server:
if ((config->fcgi_server->fcgi_id != NULL) && (config->fcgi_server->connect_to->port != 0)) {
current_fcgi_server = NULL;
} else {
fprintf(stderr, "A FastCGIid and/or ConnectTo is missing in a FastCGIserver section in %s.\n", configfile);
retval = -1;
}
break;


it crashes at the line which says:
if ((config->fcgi_server->fcgi_id != NULL) && (config->fcgi_server->connect_to->port != 0)) {


Raphaël HUCK
11 March 2008, 21:23
config->fcgi_server->connect_to
is a NULL pointer
Hugo Leisink
11 March 2008, 22:31
Thanks for your feedback. It is indeed a bug in Hiawatha, although you also have an error in your configurationfile.

To fix the problem, change the lines
if ((config->fcgi_server->fcgi_id != NULL) && (config->fcgi_server->connect_to->port != 0)) {
current_fcgi_server = NULL;
} else {
fprintf(stderr, "A FastCGIid and/or ConnectTo is missing in a FastCGIserver section in %s.\n", configfile);
retval = -1;
}


in serverconfig.c into

if ((config->fcgi_server->fcgi_id != NULL) && (config->fcgi_server->connect_to != NULL) && (config->fcgi_server->extension.size > 0)) {
current_fcgi_server = NULL;
} else {
fprintf(stderr, "A FastCGIid, Extension or ConnectTo is missing in a FastCGIserver section in %s.\n", configfile);
retval = -1;
}



About your configurationfile: the FastCGIserver section is incomplete. You are missing the Extension and ConnectTo options.

Hostname = 192.168.9.1
WebsiteRoot = /var/www-docroot

Binding {
Port = 80
}

FastCGIserver {
FastCGIid = Test
Extension = <file extension>
ConnectTo = <ip-address>:<port>
}
Rapha&euml;l HUCK
12 March 2008, 01:40
Thanks for you quick reply!

Now the problem is that I have a single FastCGI daemon, which has no extension. I'd like to forward all the request matching a specific URI to this daemon.

Is there a way to do this with hiawatha? I'm able to do this with lighttpd and cherokee, but I'd like to use hiawatha as it is more lightweight.
Rapha&euml;l HUCK
12 March 2008, 11:13
I have spotted the problem. In libip.c line 181,
s_ip = remove_spaces(s_ip);

should be replaced by:
s_ip = remove_spaces(line);


otherwise s_ip is undefined in case HAVE_IPV6 is set to false.
Hugo Leisink
12 March 2008, 14:55
Thanks for your bugreport. Keep up the good work with your audit
This topic has been closed.