a) "collections" has no attribute "callable"; b) PY_SSIZE_T_CLEAN

Bug #1960088 reported by Andreas Hasenack
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libapache2-mod-python (Ubuntu)
Fix Released
Medium
Graham Inggs

Bug Description

Caught in DEP8[1], but had to extract the apache error log manually:

[Fri Feb 04 23:54:41.720489 2022] [:warn] [pid 6718:tid 140490661578304] WARNING: mod_python version mismatch, expected '3.5.0-', found '3.5.0'.
[Fri Feb 04 23:54:41.720545 2022] [:warn] [pid 6718:tid 140490661578304] WARNING: mod_python modules location '/usr/lib/python3/dist-packages/mod_python/__init__.py'.
[Fri Feb 04 23:54:41.735111 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: Traceback (most recent call last):
[Fri Feb 04 23:54:41.735153 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/apache.py", line 398, in HandlerDispatch\n result = obj(req)
[Fri Feb 04 23:54:41.735162 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 222, in handler\n published = publish_object(req, object)
[Fri Feb 04 23:54:41.735171 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 440, in publish_object\n if _callable(obj):
[Fri Feb 04 23:54:41.735179 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 54, in _callable\n return (isinstance(obj, collections.Callable) or
[Fri Feb 04 23:54:41.735187 2022] [:error] [pid 6718:tid 140490661578304] [client 127.0.0.1:41932] PythonHandler mod_python.publisher: AttributeError: module 'collections' has no attribute 'Callable'
[Fri Feb 04 23:54:41.773768 2022] [:warn] [pid 6718:tid 140490661578304] WARNING: mod_python version mismatch, expected '3.5.0-', found '3.5.0'.
[Fri Feb 04 23:54:41.773816 2022] [:warn] [pid 6718:tid 140490661578304] WARNING: mod_python modules location '/usr/lib/python3/dist-packages/mod_python/__init__.py'.

1. https://autopkgtest.ubuntu.com/results/autopkgtest-jammy/jammy/amd64/liba/libapache2-mod-python/20220122_094511_890af@/log.gz

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

After fixing that error, though, something else pops up:
[Fri Feb 04 23:58:25.590275 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: Traceback (most recent call last):
[Fri Feb 04 23:58:25.590337 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/apache.py", line 398, in HandlerDispatch\n result = obj(req)
[Fri Feb 04 23:58:25.590353 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 222, in handler\n published = publish_object(req, object)
[Fri Feb 04 23:58:25.590366 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 446, in publish_object\n return publish_object(req, util.apply_fs_data(obj, req.form, req=req))
[Fri Feb 04 23:58:25.590378 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: File "/usr/lib/python3/dist-packages/mod_python/publisher.py", line 509, in publish_object\n req.write(result, 0)
[Fri Feb 04 23:58:25.590390 2022] [:error] [pid 6719:tid 140490653185600] [client 127.0.0.1:41934] PythonHandler mod_python.publisher: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
[Fri Feb 04 23:58:26.051704 2022] [core:notice] [pid 6257:tid 140490685847424] AH00051: child pid 6719 exit signal Segmentation fault (11), possible coredump in /etc/apache2

Revision history for this message
Andreas Hasenack (ahasenack) wrote :
Changed in libapache2-mod-python (Ubuntu):
assignee: Andreas Hasenack (ahasenack) → nobody
status: In Progress → New
tags: added: update-excuse update-excuses
summary: - "collections" has no attribute "callable"
+ a) "collections" has no attribute "callable"; b) PY_SSIZE_T_CLEAN
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I tried these patches, but apache is segfaulting still.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :
tags: added: patch
tags: added: server-todo
Revision history for this message
Alexandre Ghiti (alexghiti) wrote :
Download full text (3.2 KiB)

I worked a bit on this package too, here are my findings:

```
Thread 2 "apache2" hit Breakpoint 2, 0x00005624ceb81420 in ap_rwrite ()
(gdb) bt
#0 0x00005624ceb81420 in ap_rwrite ()
#1 0x00007fe7c99bbe72 in req_write (self=0x7fe7c84df700, args=<optimized out>)
    at /home/ubuntu/libapache2-mod-python/libapache2-mod-python-3.5.0/src/requestobject.c:1590
#2 0x00007fe7c9501bce in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#3 0x00007fe7c948be4e in _PyEval_EvalFrameDefault () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#4 0x00007fe7c95d7e1f in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#5 0x00007fe7c948a58e in _PyEval_EvalFrameDefault () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#6 0x00007fe7c95d7e1f in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#7 0x00007fe7c948a58e in _PyEval_EvalFrameDefault () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#8 0x00007fe7c95d7e1f in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#9 0x00007fe7c948a58e in _PyEval_EvalFrameDefault () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#10 0x00007fe7c95d7e1f in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#11 0x00007fe7c94f8f48 in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#12 0x00007fe7c94f9143 in ?? () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#13 0x00007fe7c94f9825 in _PyObject_CallMethod_SizeT () from target:/lib/x86_64-linux-gnu/libpython3.10.so.1.0
#14 0x00007fe7c99c505c in python_handler (req=0x7fe7c93740a0, phase=<optimized out>)
    at /home/ubuntu/libapache2-mod-python/libapache2-mod-python-3.5.0/src/mod_python.c:1535
#15 0x00005624ceb8dc08 in ap_run_handler ()
#16 0x00005624ceb8faf6 in ap_invoke_handler ()
#17 0x00005624cebb6678 in ap_process_async_request ()
#18 0x00005624cebb6d1b in ?? ()
#19 0x00005624ceba2d68 in ap_run_process_connection ()
#20 0x00007fe7c9a1d795 in ?? () from target:/usr/lib/apache2/modules/mod_mpm_event.so
#21 0x00007fe7c9a1e13c in ?? () from target:/usr/lib/apache2/modules/mod_mpm_event.so
#22 0x00007fe7c9c05b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#23 0x00007fe7c9c97b80 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) up
#1 0x00007fe7c99bbe72 in req_write (self=0x7fe7c84df700, args=<optimized out>)
    at /home/ubuntu/libapache2-mod-python/libapache2-mod-python-3.5.0/src/requestobject.c:1590
1590 rc = ap_rwrite(buff, len, self->request_rec);
(gdb) p/x buff
$1 = 0x7fe700000000
(gdb) p/x *buff
Cannot access memory at address 0x7fe700000000
```

And indeed the segfault happens in a lower frame at this same address:

```
Thread 2 "apache2" received signal SIGSEGV, Segmentation fault.
__memmove_sse2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:416
416 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) display /i $pc
1: x/i $pc
=> 0x7fe7c9c35a60 <__memmove_sse2_unaligned_erms+96>: mov -0x8(%rsi,%rdx,1),%rcx
(gdb) p/x $rsi
$2 = 0x7fe700000000
(gdb) p/x $rdx
$3 = 0xe
```

And I can't find this address in /proc/pid/maps, which is weird because that...

Read more...

Bryce Harrington (bryce)
Changed in libapache2-mod-python (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Alexandre Ghiti (alexghiti) wrote :

I have just asked for help here https://github.com/grisha/mod_python/issues/113

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Applying the patches on top of git master makes things work.

So i wonder if we should just package the git snapshot. Or like apply all patches from git master. Or like see which ones we need.

Revision history for this message
Alexandre Ghiti (alexghiti) wrote :

I went ahead and gave master a try here [1] and that locally fixes the segfault. I think taking master is ok, there's not much activity in this repo which I interpret as master is stable enough.
I versioned this package as 3.6.0 but I'm not sure here.

Thanks xnox,

[1] https://launchpad.net/~alexghiti/+archive/ubuntu/riscv/+sourcepub/13277687/+listing-archive-extra

Revision history for this message
Graham Inggs (ginggs) wrote :

I suggest using a version like 3.5.0+git20211031-0ubuntu1.

Revision history for this message
Paride Legovini (paride) wrote :

I second Graham's suggestion: if one day 3.6.0 gets released, or skipped by e.g. a jump to 4.0, having a package with version 3.6.0 will be confusing.

Given that upstream development is slow I don't think it's worth adding a short commit hash to the version string.

Graham Inggs (ginggs)
Changed in libapache2-mod-python (Ubuntu):
status: Triaged → Fix Committed
assignee: nobody → Graham Inggs (ginggs)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libapache2-mod-python - 3.5.0+git20211031-0ubuntu1

---------------
libapache2-mod-python (3.5.0+git20211031-0ubuntu1) jammy; urgency=medium

  * Bump to commit e6458ecc285f as mod_python does not deliver release anymore.
  * d/patches:
    + adapted 03_ignore-git-version.patch
    + removed as already applied 05_fix_spelling.patch
    + removed as already applied 07_fix-compilation-with-python-3.7.patch
    + removed as already applied 09_create-DESTDIR-BINDIR-if-needed.patch
    + added 11_py310_py_ssize_t_clean.patch from ahasenack (LP: #1960088)
    + added 12_py310_collections_import.patch from ahasenack (LP: #1960088)
    + added 13_version_fix.patch
  * Update maintainer to Ubuntu developers
  * Regenerate doc-html

 -- Alexandre Ghiti <email address hidden> Wed, 23 Feb 2022 13:32:41 +0100

Changed in libapache2-mod-python (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.