Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 932804 - sys-apps/portage: emerge --useoldpkg-atoms triggers IndexError for matched_packages[-1]
Summary: sys-apps/portage: emerge --useoldpkg-atoms triggers IndexError for matched_pa...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 930802
Blocks:
  Show dependency tree
 
Reported: 2024-05-26 18:00 UTC by Zac Medico
Modified: 2024-06-04 01:31 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2024-05-26 18:00:44 UTC
The issue and fix were reported here, and the logic is clearly invalid unless matched_oldpkg is a subset of matched_packages:

https://github.com/gentoo/portage/pull/1322

> From 719d8a5100bae64b69894af9fb07131e59aafe3e Mon Sep 17 00:00:00 2001
> From: Tatsuyuki Ishi <ishitatsuyuki@google.com>
> Date: Wed, 15 May 2024 16:46:36 +0900
> Subject: [PATCH] Fix a depgraph crash with useoldpkg and subslot bumps
> 
> This resolves a "list index out of range" error that could happen with
> when a package's subslot is bumped and --useoldpkg is used.
> 
> Due to the subslot bump, the code will filter matched_packages to
> only contain the latest version. However, this didn't update
> matched_oldpkg, which would now contain stale packages and cause logic
> errors.
> 
> Fix this by filtering matched_oldpkg again before its use.
> 
> Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
> ---
>  lib/_emerge/depgraph.py | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
> index 9673d85f87..579b4e2350 100644
> --- a/lib/_emerge/depgraph.py
> +++ b/lib/_emerge/depgraph.py
> @@ -8177,6 +8177,7 @@ def _wrapped_select_pkg_highest_available_imp(
>                      ):
>                          return pkg, existing_node
>  
> +            matched_oldpkg = [x for x in matched_oldpkg if x in matched_packages]
>              visible_matches = []
>              if matched_oldpkg:
>                  visible_matches = [
Comment 1 Larry the Git Cow gentoo-dev 2024-05-26 18:02:43 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=685908978c48f6bfeab99f47ba7d78ee00294a64

commit 685908978c48f6bfeab99f47ba7d78ee00294a64
Author:     Tatsuyuki Ishi <ishitatsuyuki@google.com>
AuthorDate: 2024-05-15 07:46:36 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-05-26 18:01:22 +0000

    Fix a depgraph crash with useoldpkg and subslot bumps
    
    This resolves a "list index out of range" error that could happen with
    when a package's subslot is bumped and --useoldpkg is used.
    
    Due to the subslot bump, the code will filter matched_packages to
    only contain the latest version. However, this didn't update
    matched_oldpkg, which would now contain stale packages and cause logic
    errors.
    
    Fix this by filtering matched_oldpkg again before its use.
    
    Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
    Bug: https://bugs.gentoo.org/932804
    Closes: https://github.com/gentoo/portage/pull/1322
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/_emerge/depgraph.py | 1 +
 1 file changed, 1 insertion(+)
Comment 2 Larry the Git Cow gentoo-dev 2024-06-04 01:31:38 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1dd08f05355b14c7594d0e0ccf46cdb2b1486cbe

commit 1dd08f05355b14c7594d0e0ccf46cdb2b1486cbe
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-04 01:31:07 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-04 01:31:07 +0000

    sys-apps/portage: add 3.0.65
    
    Closes: https://bugs.gentoo.org/930802
    Closes: https://bugs.gentoo.org/787623
    Closes: https://bugs.gentoo.org/922629
    Closes: https://bugs.gentoo.org/927241
    Closes: https://bugs.gentoo.org/930992
    Closes: https://bugs.gentoo.org/932739
    Closes: https://bugs.gentoo.org/932804
    Closes: https://bugs.gentoo.org/933297
    Closes: https://bugs.gentoo.org/933385
    Closes: https://bugs.gentoo.org/933442
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.65.ebuild | 242 +++++++++++++++++++++++++++++++++
 2 files changed, 243 insertions(+)