FS#74972 - [pacman] goes into an infinite loop when dealing with damaged package db files

Attached to Project: Pacman
Opened by Petrus (petrus) - Monday, 06 June 2022, 09:45 GMT
Task Type Bug Report
Category Backend/Core
Status Assigned
Assigned To Allan McRae (Allan)
Architecture x86_64
Severity High
Priority Normal
Reported Version 6.0.1
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


pacman -Syu goes into an infinite loop when dealing certain damaged package db files.

Due to a shaky internet connection I am using wget 1.21.3-1 with config `XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u`. Sometimes after several attempts of resumed download (invoked by pacman -Syu) I end up with a damaged package db (see attached bad_extra.db)

When pacman consequently attempts to read such a db file it goes into an infinite loop
printing error messages like the attached error-loop.txt. CPU usage goes through the roof and I need to kill the pacman process.

I realize that this most likely is a superposition of several potential bugs like bugs in wget, perhaps bugs in pacman's dealing with wget's return code, etc. The bottom line is that when routines in libalpm encounter with the damaged db file they don't handle it right.

Usually after such a crash a rerun of update (pacman -Syu) succeeds with a correct db file, see attached good_extra.db for comparison purposes.
This task depends upon