On Sun, Mar 26, 2023 at 03:16:00AM -0500, Marc West wrote:
> On 2023-03-26 07:19:18, Willy Tarreau wrote:
> > I could finally reproduce it, figure the cause and the fix. The 2.6
> > backport is missing this patch for evports and kqueue:
> > 
> >   698342635 BUG/MAJOR: poller: drop FD's tgid when masks don't match
> > 
> > I could verify that it fixes the problem. Without it it fails after
> > 2-3 reloads, and now it survived ~600 reloads without problem.
> > 
> > I'm going to backport it, and I don't need to postpone a new 2.6 anymore,
> > so expect a new one soon.
> > 
> > Thanks for your report!
> > Willy
> 
> Awesome, thanks Willy!

You're welcome. In the mean time if you want you can apply this patch on
top of your 2.6 tree.

Willy
>From 557a08ad869e9d69538b8f3752b865778fbb777e Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w...@1wt.eu>
Date: Mon, 25 Jul 2022 15:39:21 +0200
Subject: BUG/MAJOR: poller: drop FD's tgid when masks don't match

A bug was introduced in 2.7-dev2 by commit 1f947cb39 ("MAJOR: poller:
only touch/inspect the update_mask under tgid protection"): once the
FD's tgid is held, we would forget to drop it in case the update mask
doesn't match, resulting in random watchdog panics of older processes
on successive reloads.

This should fix issue #1798. Thanks to Christian for the report and
to Christopher for the reproducer.

No backport is needed.

(cherry picked from commit 698342635491a30b219bebeb1bbe7877efdbe3b6)
[wt: the mentioned patch was backported to 2.6 but not this fix;
 however during the backport in the process of resolving conflicts,
 the epoll part got fixed; thus only kqueue and evports are fixed by
 this commit]
Signed-off-by: Willy Tarreau <w...@1wt.eu>
---
 src/ev_evports.c | 4 +++-
 src/ev_kqueue.c  | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ev_evports.c b/src/ev_evports.c
index 3ec25910e..469d2fb6f 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -160,8 +160,10 @@ static void _do_poll(struct poller *p, int exp, int wake)
                        continue;
                }
 
-               if (!(fdtab[fd].update_mask & tid_bit))
+               if (!(fdtab[fd].update_mask & tid_bit)) {
+                       fd_drop_tgid(fd);
                        continue;
+               }
 
                done_update_polling(fd);
 
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index dc4e81164..c1cf5e466 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -134,8 +134,10 @@ static void _do_poll(struct poller *p, int exp, int wake)
                        continue;
                }
 
-               if (!(fdtab[fd].update_mask & tid_bit))
+               if (!(fdtab[fd].update_mask & tid_bit)) {
+                       fd_drop_tgid(fd);
                        continue;
+               }
 
                done_update_polling(fd);
 
-- 
2.37.1

Reply via email to