Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#71312 - {pyalpm} transaction.to_add segfault

Attached to Project: Arch Linux
Opened by Matthew G (djmattyg007) - Sunday, 20 June 2021, 08:01 GMT
Last edited by Jelle van der Waa (jelly) - Sunday, 27 June 2021, 09:35 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Jelle van der Waa (jelly)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
I'm seeing segfaults when trying to perform a sysupgrade, but only if transaction.to_add and transaction.to_remove are accessed.

Package versions:
pyalpm 0.10.4-1
python 3.9.5-3
pacman 6.0.0-3

Steps to reproduce:

The behaviour is pretty weird, varying slightly depending on the order of operations.

To reproduce, I have an executable script that always starts with the following code:

---

#!/usr/bin/python3

import pycman.config
import pycman.transaction

handle = pycman.confi.init_with_config("/etc/pacman.conf")
transaction = pycman.transaction.init_from_options(handle, {})
transaction.sysupgrade(False)

---

From here, the behaviour varies depending on the order of the next few instructions. If the rest of the script looks like this:

print(transaction.to_add)
print(transaction.to_remove)
transaction.release()
print("released")

Then the script segfaults upon accessing transaction.to_remove.

If the rest of the script looks like this:

print(transaction.to_add)
transaction.release()
print("released")

Then the script segfaults upon calling transaction.release().

If the rest of the script looks like this:

print(transaction.to_remove)
print(transaction.to_add)
transaction.release()
print("released")

Then the script segfaults upon calling transaction.release().

If the rest of the script looks like this:

print(transaction.to_remove)
transaction.release()
print("released")

Then the script completes successfully without segfaulting.

If transaction.release() is called without ever accessing transaction.to_add, the script completes successfully.

To confirm:

- The same results occurred regardless of whether or not print statements were used. I used print statements simply to aid the initial diagnosis.
- Every time the script segfaulted, I had to manually clear the lock file /var/lib/pacman/db.lck before I was able to try it again.
- I tested elevating privileges using both sudo and doas, and it had the same effect.
- I observe what appears to be the exact same segfault when running 'pycman-sync -u' (with both sudo and doas).
- While performing these tests, I have three packages awaiting upgrades. I arbitrarily downgraded these packages in order to test:

broot 1.5.1-1 -> 1.6.0-1
typescript 4.3.2-1 -> 4.3.4-1
vlc 3.0.15-2 -> 3.0.16-1

Please let me know if I can provide any further information that would assist debugging.
This task depends upon

Closed by  Jelle van der Waa (jelly)
Sunday, 27 June 2021, 09:35 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in 0.10.5
Comment by Matthew G (djmattyg007) - Sunday, 20 June 2021, 08:24 GMT
As a random aside, it would be nice if the downgrade argument to transaction.sysupgrade() was made optional.
Comment by Eli Schwartz (eschwartz) - Sunday, 20 June 2021, 12:19 GMT
  • Field changed: Summary ([pyalpm] transaction.to_add segfault → {pyalpm} transaction.to_add segfault)
  • Field changed: Status (Unconfirmed → Assigned)
  • Field changed: Category (Packages: Extra → Arch Projects)
  • Task assigned to Jelle van der Waa (jelly)
I didn't get the crash with your script until I used pacman -Sy to get some to_add packages for listing as available upgrades

$ sudo python3 pyalpm_test.py
WARNING: libblockdev: local (2.25-2.1) is newer than extra (2.25-2)
[]
[]
released
$ sudo pacman -Sy
...
$ sudo python3 pyalpm_test.py
WARNING: libblockdev: local (2.25-2.1) is newer than extra (2.25-2)
[<alpm.Package("fortune-mod-3.6.1-1-x86_64") at 0x7f44970febd0>, <alpm.Package("python-backcall-0.2.0-4-any") at 0x7f44970fef90>, <alpm.Package("python-black-21.6b0-2-any") at 0x7f44970fef60>]
Segmentation fault
Comment by Matthew G (djmattyg007) - Sunday, 20 June 2021, 14:30 GMT
Yep, it makes sense that you'd need at least one package ready to be upgraded for the segfault to occur. I didn't try to replicate this with a fully up-to-date system.
Comment by Matthew G (djmattyg007) - Sunday, 27 June 2021, 06:52 GMT
As far as I can tell, pyalpm 0.10.5 has resolved this issue. I'm happy for this to be closed now.

Thank you :)

Loading...