panic caused by EVFILT_SIGNAL detaching in rfork()ed thread

Igor Sysoev is at rambler-co.ru
Fri Oct 22 13:35:28 PDT 2004


Here is more correct patch to fix the panic in 4.x reported in
http://freebsd.rambler.ru/bsdmail/freebsd-hackers_2004/msg02732.html

-------------------------
--- src/sys/kern/kern_event.c   Sun Oct 10 12:17:55 2004
+++ src/sys/kern/kern_event.c   Sun Oct 10 12:19:29 2004
@@ -794,7 +794,8 @@
            while (kn != NULL) {
                kn0 = SLIST_NEXT(kn, kn_link);
                if (kq == kn->kn_kq) {
-                   kn->kn_fop->f_detach(kn);
+                   if (!(kn->kn_status & KN_DETACHED))
+                       kn->kn_fop->f_detach(kn);
        /* XXX non-fd release of kn->kn_ptr */
                    knote_free(kn);
                    *knp = kn0;
-------------------------

The patch based on the fix for FreeBSD 5.x:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_event.c.diff?r1=1.79&r2=1.80

For more information see the thread started in
http://freebsd.rambler.ru/bsdmail/freebsd-current_2004/msg18389.html

To reproduce the panic in 4.x you could download
http://sysoev.ru/nginx/nginx-0.1.2.tar.gz
and build it without the installation:

tar zxf nginx-0.1.2.tar.gz
cd nginx-0.1.2
./configure --with-threads=rfork \
            --without-http_rewrite_module \
            --prefix=$PWD \
            --pid-path=nginx.pid \
            --http-log-path=access.log \
            --error-log-path=stderr
make

Now you have to edit ./conf/nginx.conf.

Add the line "daemon  off;" in the start of the file.
Change the lines "worker_processes  3;" to "worker_threads  3;"
and "listen 80;" to "listen  8000;".

Now you could run ./nginx as non-privileged user.

If you run in another console

ps ax -o pid,ppid,%cpu,vsz,wchan,command|egrep '(nginx:|PID)'

you will see something like this:

  PID  PPID %CPU   VSZ WCHAN  COMMAND
 3737   238  0.0  1340 pause  nginx: master process ./nginx
 3738  3737  0.0  1844 kqread nginx: worker process (nginx)
 3739  3738  0.0  1844 kqread nginx: worker thread (nginx)
 3740  3738  0.0  1844 kqread nginx: worker thread (nginx)
 3741  3738  0.0  1844 kqread nginx: worker thread (nginx)

Now stop nginx by pressing ^C. Your system may panic.


Igor Sysoev
http://sysoev.ru/en/


More information about the freebsd-stable mailing list