#1058317 celery: FTBFS: dh_auto_test: error: pybuild --test --test-pytest -i python{version} -p "3.12 3.11" returned exit code 13

#1058317#5
Date:
2023-12-12 08:18:07 UTC
From:
To:
Hi,

During a rebuild of all packages in sid, your package failed to build
on amd64.


Relevant part (hopefully):
The full build log is available from:
http://qa-logs.debian.net/2023/12/12/celery_5.3.4-2_unstable.log

All bugs filed during this archive rebuild are listed at:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-20231212;users=lucas@debian.org
or:
https://udd.debian.org/bugs/?release=na&merged=ign&fnewerval=7&flastmodval=7&fusertag=only&fusertagtag=ftbfs-20231212&fusertaguser=lucas@debian.org&allbugs=1&cseverity=1&ctags=1&caffected=1#results

A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!

If you reassign this bug to another package, please mark it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.

#1058317#10
Date:
2024-01-18 02:29:43 UTC
From:
To:
Note the segmentation fault at the end of python 3.12 pytest run.

Using export PYTHONFAULTHANDLER=1 before running the tests, I only got
an error in garbage-collector, no trace.

It is a bit like #1055717, which was closed by
https://salsa.debian.org/python-team/packages/python-multidict/-/commit/2d54ca0b

Also I tried with celery 5.3.6, and also with kombu 5.3.5 and vine 5.1.0, no luck.

#1058317#21
Date:
2024-02-27 15:19:07 UTC
From:
To:
Control: unmerge 1058317 1063345
Control: reassign 1063345 python3.12
Control: affects 1063345 celery
Control: forwarded 1063345 https://github.com/python/cpython/issues/115874
Control: block 1058317 by 1063345
Control: tag 1063345 patch

There are two separate issues in the current celery FTBFS, so I'm
unmerging these two bugs again because they ought to be tracked
separately - and it turns out that this one really is a bug in Python
3.12.

I happened to notice that something very similar to #1063345 had
recently been reported to Python upstream as
https://github.com/python/cpython/issues/115874, with a much more
manageably-sized reproducer, and there's a patch for it in
https://github.com/python/cpython/issues/115874#issuecomment-1965775536.
I've built the Debian python3.12 package with this patch, and I've
confirmed that Celery 5.3.6 passes its tests with this patch when it
previously failed.

Celery is unlucky to run into this, but it doesn't seem to be anything
particularly intrinsic to Celery - it's an artifact of the particular
set of pytest plugins it happens to use, which manage to tickle this
particular bug.  I think it would be worth applying this patch to
Debian's python3.12 package, as it could easily bite in other places and
this was a real time-sink for me before I managed to find the upstream
bug that somebody else had fortunately filed.  (It would also be nice to
get Celery back into Debian testing and Ubuntu noble if at all possible,
the latter of which has a fairly close deadline.)

Separately, #1058317 still has the test failure in
test_AsyncResult.test_del.  That was fixed in Celery 5.3.5, and 5.3.6 is
currently on salsa, but there's only limited point in uploading it until
the Python bug is fixed.

Suggested Python patch follows, though you might want to check whether
it's progressed any further upstream in case there've been any
additional tweaks:

diff --git a/debian/changelog b/debian/changelog
index 0e16636..b57f7dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python3.12 (3.12.2-1.1) UNRELEASED; urgency=medium
+
+  * Don't rely on module state in teedataobject_clear (from Brandt Bucher in
+    https://github.com/python/cpython/issues/115874; closes: #1063345).
+
+ -- Colin Watson <cjwatson@debian.org>  Tue, 27 Feb 2024 10:15:37 +0000
+
 python3.12 (3.12.2-1) unstable; urgency=medium

   * Python 3.12.2 release.
diff --git a/debian/patches/itertools-clear-crash.diff b/debian/patches/itertools-clear-crash.diff
new file mode 100644
index 0000000..cdaeebb
--- /dev/null
+++ b/debian/patches/itertools-clear-crash.diff
@@ -0,0 +1,19 @@
+Description: Don't rely on module state in teedataobject_clear
+Origin: other, https://github.com/python/cpython/issues/115874#issuecomment-1965775536
+Bug: https://github.com/python/cpython/issues/115874
+Bug-Debian: https://bugs.debian.org/1063345
+
+Index: b/Modules/itertoolsmodule.c
+===================================================================
+--- a/Modules/itertoolsmodule.c
++++ b/Modules/itertoolsmodule.c
+@@ -832,8 +832,7 @@
+         Py_CLEAR(tdo->values[i]);
+     tmp = tdo->nextlink;
+     tdo->nextlink = NULL;
+-    itertools_state *state = get_module_state_by_cls(Py_TYPE(tdo));
+-    teedataobject_safe_decref(tmp, state->teedataobject_type);
++    teedataobject_safe_decref(tmp, Py_TYPE(tdo));
+     return 0;
+ }
+
diff --git a/debian/patches/series b/debian/patches/series
index 63c72c2..0a85028 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -31,3 +31,4 @@ fix-py_compile.diff
 ntpath-import.diff
 python3.12-updates.diff
 issue108447.diff
+itertools-clear-crash.diff

Thanks,

#1058317#50
Date:
2024-02-27 17:19:19 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
celery, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1058317@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Colin Watson <cjwatson@debian.org> (supplier of updated celery package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 27 Feb 2024 16:59:54 +0000
Source: celery
Architecture: source
Version: 5.3.6-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Python Team <team+python@tracker.debian.org>
Changed-By: Colin Watson <cjwatson@debian.org>
Closes: 1058317
Changes:
 celery (5.3.6-1) unstable; urgency=medium
 .
   * Team upload.
 .
   [ Alexandre Detiste ]
   * Remove useless and deprecated build-deps on python3-future and python3-mock.
   * New upstream release (closes: #1058317).
Checksums-Sha1:
 c9870a6e8d2414d69ae7f4f9b7f8d9db2f5f62c1 2906 celery_5.3.6-1.dsc
 04ada795e1c18b487657e333d00b53a23bab6118 1563926 celery_5.3.6.orig.tar.gz
 a08e29ffbcc15294ca83f7063d704b612d96e2b3 23424 celery_5.3.6-1.debian.tar.xz
 269a1bb203961b6a23adfb200c58b2870b57d4c5 11262 celery_5.3.6-1_source.buildinfo
Checksums-Sha256:
 89c0265d6e2e92daa1201fdffd9035ffa52ecea3e2f7245588db3763c2b8c59c 2906 celery_5.3.6-1.dsc
 bfad14468cf4e4f28adf0212a4256cdffccc28e7decb20b880bc8119d06c6be3 1563926 celery_5.3.6.orig.tar.gz
 f188fd232fdf807ed48d60f81618e3f6f78d618f1785dbbdc8dc42bb665779d0 23424 celery_5.3.6-1.debian.tar.xz
 3bafa46948bdb6188b53028611ae0f54582f0b4d6d404e20a69fc6cd346ee92f 11262 celery_5.3.6-1_source.buildinfo
Files:
 c2dc2a9e4123dfce51af2f6bed7e800b 2906 python optional celery_5.3.6-1.dsc
 25fb37590a127f0ecd825c933beb499b 1563926 python optional celery_5.3.6.orig.tar.gz
 d4f4a181f17c4b3ffa7b66739db08119 23424 python optional celery_5.3.6-1.debian.tar.xz
 4361e29d563a7ffcbf8e5e5b33941dc5 11262 python optional celery_5.3.6-1_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEErApP8SYRtvzPAcEROTWH2X2GUAsFAmXeFgcACgkQOTWH2X2G
UAvXqg//aAZ+/p81ajzb1hnPoNXl05TAv895u9DQNZUi+yhf5JO9RLtIEmljLFaK
YNXOpfskpQgRLNg9Dr13bquuJoffmfy+r+wUibhpkIQdiiy5NMtb81U88768CH4T
bNd+vInamq6osaAqIqv+8f2eFa1zBNs9wxfNqc7s4mU5YNje/cYNaTSZQn/S8op6
Ki67OhGtIPwvwNjUy1h6efLxO17+1jn4FVjVSxG6gpoE9odEknv9KDQss8Vtpudc
WNo07OYmNaE40N5/Ojza+jf5FS715IrOVpG1TU7+MQOLFEStCfErktZJqQgSFY+D
8U6qp+mWlavdC72XR6cmHofxJZMgE7stK+SjxF5sbNe5jglcB0jvMCR8YZ4PHcvW
PzffOL+Y7DlbPanLPM6jbfOx8l+SC1oPR/ipgc/BSTRLBD3rqmlnkZUV2u3Lsr5/
myXCXwneNSk+ZAI7cs6HmOuDOgcpD5R44GFttuQNGwkmj2ApbpEE22w74LOZEpZy
UaVQhBJrXy+MSnrIqpMt+Bhto87BGoa+koroLf2qviU3Ug2VyjGGp+3hqyZWvv/9
MCHrq5NbAN/e64xo1cD+UEKAbIpsy22BUg90iDjmWliR5kaHNc9DRX3aHI04oNav
NdhcTcAYM9vZ/F1QJdlHeuAdHnjOGgrGPybDyhtJucvyPedVkwE=
=9HRq
-----END PGP SIGNATURE-----