For a while now, I've found polipo is crashing.  The last message in the
log is:

Couldn't send request to server: Immediate shutdown requested

I noticed that it often seems to happen just after resuming my computer
from hibernation.  I ran polipo under valgrind, hibernated, and it
obligingly asserted on resume, but without a backtrace.

I then tried doing the same under gdb.  Something strange is going on
because polipo was killed with SIGTERM.  I assume it's the nice Debian
scripts restarting polipo in offline mode after shutting down my network
interface.  But I've no idea why the same thing didn't happen with valgrind.

So I tried simulating hibernation by just suspending and resuming the
polipo process.  Hey presto, a full backtrace:


Program received signal SIGTSTP, Stopped (user).
0x00007f1ed7a4fc3f in poll () from /lib/libc.so.6

^Z
Program received signal SIGTSTP, Stopped (user).
0x00007f1ed7a4fc3f in poll () from /lib/libc.so.6
(gdb) cont
Continuing.

Program received signal SIGTSTP, Stopped (user).
0x00007f1ed7a4fc3f in poll () from /lib/libc.so.6
(gdb) cont
Continuing.

polipo: chunk.c:398: dispose_chunk: Assertion `chunk != ((void *)0)' failed.

Program received signal SIGABRT, Aborted.
0x00007f1ed79b3095 in raise () from /lib/libc.so.6
(gdb) where
#0  0x00007f1ed79b3095 in raise () from /lib/libc.so.6
#1  0x00007f1ed79b4af0 in abort () from /lib/libc.so.6
#2  0x00007f1ed79ac2df in __assert_fail () from /lib/libc.so.6
#3  0x00000000004062e3 in dispose_chunk (chunk=0x0) at chunk.c:408
#4  0x0000000000416e95 in httpServerHandler (status=65537, event=0x3df2,
srequest=0x6) at server.c:1749
#5  0x0000000000405c5e in do_scheduled_stream (status=15858,
event=0x3df2) at io.c:368
#6  0x000000000040413e in pokeFdEventHandler (tevent=<value optimized
out>) at event.c:569
#7  0x0000000000403793 in runTimeEventQueue () at event.c:492
#8  0x0000000000403e48 in eventLoop () at event.c:659
#9  0x000000000040d5f8 in main (argc=8, argv=0x7fffdff015e8) at main.c:165


To me, it looks like the second failure case in httpServerHandler() is
buggy.  It calls dispose_chunk(connection->reqbuf) after already calling
httpConnectionDestroyReqbuf(connection).  So a fix might be...

diff -rN -u old-polipo/server.c new-polipo/server.c
--- old-polipo/server.c 2008-07-27 16:41:01.000000000 +0100
+++ new-polipo/server.c 2008-07-27 16:41:01.000000000 +0100
@@ -1714,7 +1714,7 @@
     if(connection->reqlen == 0) {
         do_log(D_SERVER_REQ, "Writing aborted on 0x%lx\n", 
                (unsigned long)connection);
-        goto fail;
+        goto fail_reqbuf;
     }
 
     if(status == 0 && !streamRequestDone(srequest)) {
@@ -1744,8 +1744,9 @@
     
     return 1;
 
+ fail_reqbuf:
+    httpConnectionDestroyReqbuf(connection);
  fail:
-    dispose_chunk(connection->reqbuf);
     connection->reqbuf = NULL;
     shutdown(connection->fd, 2);
     pokeFdEvent(connection->fd, -EDOSHUTDOWN, POLLIN);


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Polipo-users mailing list
Polipo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/polipo-users

Reply via email to