Bug #1926

lighttpd 1.4.21 crashes on receipt of SIGINT on Solaris

Added by acd over 5 years ago. Updated over 5 years ago.

Status:FixedStart date:2009-03-04
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:core
Target version:1.4.22
Missing in 1.5.x:

Description

Solaris 10 x86, lighttpd 1.4.21

config file:
server.document-root = "/var/www"
server.port = 8001

after hitting ^C, lighttpd crashes as follows:
$ lighttpd -f lighttpd.conf -D
2009-03-04 11:41:03: (log.c.97) server started
^CSegmentation Fault (core dumped)

GDB output:
91 last_sigterm_info = *si;
(gdb) bt
#0 sigaction_handler (sig=0, si=0x0, context=0x80471dc) at server.c:91
#1 0xfecbd31f in __sighndlr () from /lib/libc.so.1
#2 0xfecb3980 in call_user_handler () from /lib/libc.so.1
#3 <signal handler called>
#4 0xfecbdc57 in __pollsys () from /lib/libc.so.1
#5 0xfecb2ac6 in _pollsys () from /lib/libc.so.1
#6 0xfec68536 in poll () from /lib/libc.so.1
#7 0x0806b872 in fdevent_poll_poll (ev=0x80473f0, timeout_ms=4) at fdevent_poll.c:105
#8 0x08056d20 in main (argc=1000, argv=0x8047790) at server.c:1382

Problem appears to be that si is NULL, and sigaction_handler doesn't check for that case. I changed line 91 to:
if (si) last_sigterm_info = *si;
which seems to work, though I didn't look for what last_sigterm_info is used for elsewhere.

solaris_sigint_segfault.patch Magnifier (563 Bytes) stbuehler, 2009-03-07 10:01

solaris_sigint_segfault-alternate.patch Magnifier (574 Bytes) acd, 2009-03-07 14:22

Associated revisions

Revision 2409
Added by stbuehler over 5 years ago

Fix segfault if siginfo_t* is NULL in sigaction handler (fixes #1926)

Revision 2456
Added by stbuehler over 5 years ago

merge: Fix segfault if siginfo_t* is NULL in sigaction handler (#1926)

History

#1 Updated by acd over 5 years ago

Oh, one more thing worth noting, the signal received by sigaction_handler is 2 -- SIGINT. I'm not sure why GDB can't see that, perhaps it's in a register or something, but I added a printf statement in sigaction_handler to display sig and the value is 2.

#2 Updated by stbuehler over 5 years ago

Some background info: http://fixunix.com/274252-post5.html

I prefer setting the struct to 0 (that seems to reflect the behavior on my system). Could you please try the attached patch?

#3 Updated by stbuehler over 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Applied in changeset r2409.

#4 Updated by acd over 5 years ago

This seems like a good workaround but shouldn't empty_siginfo be initialized? It looks like lighttpd is only using si_uid and si_pid from last_sigterm_info for logging, so it won't cause any negative behavior, but it doesn't seem clean to me.

#5 Updated by stbuehler over 5 years ago

http://flash-gordon.me.uk/ansi.c.txt

If an object that has static storage duration is not initialized
explicitly, it is initialized implicitly as if every member that has
arithmetic type were assigned 0 and every member that has pointer type
were assigned a null pointer constant.

#6 Updated by acd over 5 years ago

Maybe this patch is better...?

#7 Updated by acd over 5 years ago

stbuehler wrote:

http://flash-gordon.me.uk/ansi.c.txt

If an object that has static storage duration is not initialized
explicitly, it is initialized implicitly as if every member that has
arithmetic type were assigned 0 and every member that has pointer type
were assigned a null pointer constant.

Well I learn something new every day :). Didn't realize that about static structs. Thanks for the info.

Also available in: Atom