[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v7h6241p.fsf@trenco.lwn.net>
Date: Mon, 12 Jan 2026 09:23:30 -0700
From: Jonathan Corbet <corbet@....net>
To: Changbin Du <changbin.du@...wei.com>, Mauro Carvalho Chehab
<mchehab@...nel.org>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, Changbin Du
<changbin.du@...wei.com>, Mauro Carvalho Chehab
<mchehab+huawei@...nel.org>
Subject: Re: [PATCH v4] tools: jobserver: Prevent deadlock caused by
incorrect jobserver configuration and enhance error reporting
Jonathan Corbet <corbet@....net> writes:
> The warning comes from JobserverExec::open(), for an exception that
> appears to be expected. This is the sort of use of exceptions that has
> made me almost swear off them entirely in Python - it's a huge try block
> that is using exceptions to hide a bunch of the assumptions and logic.
> I'll be posting a patch shortly to remove this non-exceptional exception
> case.
Here's a first step, just to show what I have in mind.
jon
>From bdbb48e153714ae1c9e5214ba3ecd6142536ee6f Mon Sep 17 00:00:00 2001
From: Jonathan Corbet <corbet@....net>
Date: Mon, 12 Jan 2026 09:19:49 -0700
Subject: [PATCH] jobserver: Begin to split up the big try: block
The parsing of jobserver options is done in a massive try: block that hides
problems and (perhaps) bugs. Start to split up that block and make the
logic explicit by moving the initial parsing of MAKEFLAGS out of that
block.
Among other things, this removes the warning:
jobserver: warning: IndexError('list index out of range')
Seen after the application of bbf8c67aa6ae8.
Signed-off-by: Jonathan Corbet <corbet@....net>
---
tools/lib/python/jobserver.py | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/tools/lib/python/jobserver.py b/tools/lib/python/jobserver.py
index 616411087725e..c674319f6cb1f 100755
--- a/tools/lib/python/jobserver.py
+++ b/tools/lib/python/jobserver.py
@@ -58,15 +58,27 @@ class JobserverExec:
if self.is_open:
return
-
+ self.claim = None
+ self.is_open = True # We only try once
+ #
+ # See what they have told us to do here.
+ #
+ try:
+ flags = os.environ['MAKEFLAGS']
+ except KeyError:
+ return
+ #
+ # Look for "--jobserver=R,W"
+ # Note that GNU Make has used --jobserver-fds and --jobserver-auth
+ # so this handles all of them.
+ #
+ opts = [x for x in flags.split(" ") if x.startswith("--jobserver")]
+ if not opts:
+ return
+ #
+ # OK, parse the result.
+ #
try:
- # Fetch the make environment options.
- flags = os.environ["MAKEFLAGS"]
- # Look for "--jobserver=R,W"
- # Note that GNU Make has used --jobserver-fds and --jobserver-auth
- # so this handles all of them.
- opts = [x for x in flags.split(" ") if x.startswith("--jobserver")]
-
# Parse out R,W file descriptor numbers and set them nonblocking.
# If the MAKEFLAGS variable contains multiple instances of the
# --jobserver-auth= option, the last one is relevant.
--
2.52.0
Powered by blists - more mailing lists