kqueue crash on FreeBSD with 2.2.25

Edgar Pettijohn edgar at pettijohn-web.com
Tue Jul 5 00:26:59 UTC 2016


On 16-07-03 22:14:01, Edgar Pettijohn wrote:
> On 16-07-03 03:30:36, Timo Sirainen wrote:
> > On 02 Jul 2016, at 03:30, Adam Weinberger <adamw at adamw.org> wrote:
> > > 
> > >>> Jul  1 10:07:27 imap dovecot: master: Panic: kevent(EV_ADD, READ, 54) failed: Bad file descriptor
> > >>> 
> > >>> It's not dumping core, and I get the message even with "protocols ="
> > >>> 
> > >>> Downgrading back to 2.2.24 fixes it. What info would be helpful for me to provide here?
> > >> 
> > >> gdb backtrace: http://dovecot.org/bugreport.html#coredumps
> > >> 
> > > 
> > > Fuller logs attached. Thanks for your help, Timo.
> > > 
> > > #6  0x2815b23a in i_panic (format=0x281ccf7a "kevent(EV_ADD, READ, %d) failed: %m") at failures.c:275
> > > #7  0x28185e10 in io_loop_handle_add (io=0x288843a0) at ioloop-kqueue.c:67
> > > #8  0x281815a8 in io_add_file (fd=56, condition=IO_READ, source_linenum=244, callback=0x2818a7d0 <signal_read>, context=0x0) at ioloop.c:59
> > > #9  0x281813a6 in io_add (fd=56, condition=IO_READ, source_linenum=244, callback=0x2818a7d0 <signal_read>, context=0x0) at ioloop.c:81
> > > #10 0x2818a666 in lib_signals_set_handler (signo=1, flags=3, handler=0x804e6c0 <sig_settings_reload>, context=0x0) at lib-signals.c:243
> > > #11 0x0804e129 in main_init (set=0x2881d098) at main.c:518
> > > #12 0x0804d562 in main (argc=3, argv=0xffffae08) at main.c:890
> > 
> > Weird. I haven't touched anything even close to that. Also kqueue works on my OSX. The only thing that comes to my mind is https://github.com/dovecot/core/commit/fde7b8a03bf91cfa5bb7ca3e84545386243fa0d2
> > 
> > Does it happen to work if you use the attached patch?
> > 
> 
> Still trying to learn git, but here is what happened when I tried applying this diff.
> 
> Sun Jul 03 10:12:32 ~/dovecot/core $ git reset --hard 3fea4d5988de365503df44a9b067e3b181cac65c 
> HEAD is now at 3fea4d5 master: Stopping didn't close dead-pipes early enough.
> Sun Jul 03 10:12:37 ~/dovecot/core $ git apply diff.patch                                      
> error: patch failed: src/master/service-monitor.c:522
> error: src/master/service-monitor.c: patch does not apply
> error: patch failed: src/master/service-monitor.c:452
> error: src/master/service-monitor.c: patch does not apply
> error: patch failed: src/master/service-process.c:133
> error: src/master/service-process.c: patch does not apply
> error: patch failed: src/master/service.c:283
> error: src/master/service.c: patch does not apply
> error: patch failed: src/master/service.h:85
> error: src/master/service.h: patch does not apply
> 
> Same thing happened before the reset --hard.
> 
> -- 
> Edgar Pettijohn
It was a misconfiguration problem on my part causing the issues on OpenBSD.  Probably the same for FreeBSD.  Had to make changes to /etc/login.conf 
to fix it.  However, the following diff keeps it from panicing and logs enough info to help figure out the problem.



-- 
Edgar Pettijohn
-------------- next part --------------
diff --git a/src/lib/ioloop-kqueue.c b/src/lib/ioloop-kqueue.c
index 881ce87..9c35202 100644
--- a/src/lib/ioloop-kqueue.c
+++ b/src/lib/ioloop-kqueue.c
@@ -63,12 +63,12 @@ void io_loop_handle_add(struct io_file *io)
 
 	if ((io->io.condition & (IO_READ | IO_ERROR)) != 0) {
 		MY_EV_SET(&ev, io->fd, EVFILT_READ, EV_ADD, 0, 0, io);
-		if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0)
+		if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) == -1)
 			i_panic("kevent(EV_ADD, READ, %d) failed: %m", io->fd);
 	}
 	if ((io->io.condition & IO_WRITE) != 0) {
 		MY_EV_SET(&ev, io->fd, EVFILT_WRITE, EV_ADD, 0, 0, io);
-		if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0)
+		if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) == -1)
 			i_panic("kevent(EV_ADD, WRITE, %d) failed: %m", io->fd);
 	}
 


More information about the dovecot mailing list