Infinite loop with stat watcher and inotify

Graham Leggett minfrin at sharp.fm
Wed Dec 10 13:04:27 CET 2008


Hi all,

I have been testing my libev application under RHEL5 instead of MacOSX, 
and I have discovered an infinite loop that develops within libev that 
causes the app to hang (and spin).

During the spin, the program flow looks like below.

The spin is happening because w_, w and w_->next all have the same value:

(gdb) print w_
$1 = (WL) 0x1f12d710
(gdb) print w
$2 = (ev_stat *) 0x1f12d710
(gdb) print w_->next
$3 = (struct ev_watcher_list *) 0x1f12d710

Does anyone have any ideas on how this might have happened? I am using 
libev v3.49, and the Linux kernel version is kernel-2.6.18-53.1.13.el5.

2514	      for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; )
(gdb)
2516	          ev_stat *w = (ev_stat *)w_;
(gdb)
2517	          w_ = w_->next; /* lets us remove this watcher and all 
before it */
(gdb)
2519	          if (w->wd == wd || wd == -1)
(gdb)
2514	      for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; )
(gdb)
2516	          ev_stat *w = (ev_stat *)w_;
(gdb)
2517	          w_ = w_->next; /* lets us remove this watcher and all 
before it */
(gdb)
2519	          if (w->wd == wd || wd == -1)
(gdb)
2514	      for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; )
(gdb)
2516	          ev_stat *w = (ev_stat *)w_;
(gdb)
2517	          w_ = w_->next; /* lets us remove this watcher and all 
before it */
(gdb)
2519	          if (w->wd == wd || wd == -1)
(gdb)
2514	      for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; )
(gdb)
2516	          ev_stat *w = (ev_stat *)w_;
(gdb)
2517	          w_ = w_->next; /* lets us remove this watcher and all 
before it */
(gdb)
2519	          if (w->wd == wd || wd == -1)
(gdb)

Regards,
Graham
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3287 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20081210/32e743cb/attachment.bin>


More information about the libev mailing list