https mirrors apport-retrace crashed with SystemError in _get_primary_mirror_from_apt_sources(): cannot determine default mirror: /etc/apt/sources.list does not contain a valid deb line

Bug #1822712 reported by Bryan Quigley
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Medium
Unassigned
apport (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

1. Have other crash occur.
2. Click retrace locally.
3. apport-retrace crashes.

The only thing I can think is it's the fact that i changed my mirror to:
deb https://mirrors.ocf.berkeley.edu/ubuntu/ disco main restricted universe multiverse
deb-src https://mirrors.ocf.berkeley.edu/ubuntu/ disco main restricted universe multiverse

ProblemType: Crash
DistroRelease: Ubuntu 19.04
Package: apport-retrace 2.20.10-0ubuntu23
ProcVersionSignature: Ubuntu 5.0.0-8.9-generic 5.0.1
Uname: Linux 5.0.0-8-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportLog:
 ERROR: apport (pid 10677) Mon Apr 1 19:40:34 2019: called for pid 8661, signal 11, core limit 0, dump mode 1
 ERROR: apport (pid 10677) Mon Apr 1 19:40:34 2019: executable: /usr/bin/gedit (command line "/usr/bin/gedit --gapplication-service")
 ERROR: apport (pid 10677) Mon Apr 1 19:40:34 2019: debug: session gdbus call: (true,)

 ERROR: apport (pid 10677) Mon Apr 1 19:40:42 2019: wrote report /var/crash/_usr_bin_gedit.1000.crash
ApportVersion: 2.20.10-0ubuntu23
Architecture: amd64
CrashReports:
 640:1000:117:8118520:2019-04-01 20:06:04.204469680 -0700:2019-04-01 20:06:05.204469680 -0700:/var/crash/_usr_bin_gedit.1000.crash
 640:1000:117:23602:2019-04-01 20:06:21.172740697 -0700:2019-04-01 20:06:22.172740697 -0700:/var/crash/_usr_bin_apport-retrace.1000.crash
CurrentDesktop: ubuntu:GNOME
Date: Mon Apr 1 20:06:22 2019
ExecutablePath: /usr/bin/apport-retrace
InstallationDate: Installed on 2018-04-14 (352 days ago)
InstallationMedia: Ubuntu 18.04 LTS "Bionic Beaver" - Alpha amd64 (20180414)
InterpreterPath: /usr/bin/python3.7
PackageArchitecture: all
ProcCmdline: /usr/bin/python3 /usr/bin/apport-retrace -S system -C /home/username/.cache/apport/retrace -v --output /var/crash/_usr_bin_gedit.1000.crash /var/crash/_usr_bin_gedit.1000.crash
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
Python3Details: /usr/bin/python3.7, Python 3.7.3, python3-minimal, 3.7.2-1
PythonArgs: ['/usr/bin/apport-retrace', '-S', 'system', '-C', '/home/username/.cache/apport/retrace', '-v', '--output', '/var/crash/_usr_bin_gedit.1000.crash', '/var/crash/_usr_bin_gedit.1000.crash']
PythonDetails: /usr/bin/python2.7, Python 2.7.16, python-minimal, 2.7.16-1
SourcePackage: apport
Title: apport-retrace crashed with SystemError in _get_primary_mirror_from_apt_sources(): cannot determine default mirror: /etc/apt/sources.list does not contain a valid deb line
UpgradeStatus: Upgraded to disco on 2019-01-05 (86 days ago)
UserGroups: adm cdrom dip libvirt lpadmin lxd plugdev sambashare sudo

Revision history for this message
Bryan Quigley (bryanquigley) wrote :
tags: removed: need-duplicate-check
Changed in apport (Ubuntu):
importance: Undecided → Medium
information type: Private → Public
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apport (Ubuntu):
status: New → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

Please provide your full /etc/apt/sources.list file so I can see what's going on. Thanks in advance!

Changed in apport (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Bryan Quigley (bryanquigley) wrote :

Sources was:
deb https://mirrors.rit.edu/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.rit.edu/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.rit.edu/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.rit.edu/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.rit.edu/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.rit.edu/ubuntu/ focal-security main restricted universe multiverse

but I haven't reproduced this in over a year, so I'm going to close it.

Changed in apport (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

My sources.list file has this first deb line:

deb [ arch=riscv64 ] http://ports.ubuntu.com/ubuntu-ports/ lunar main restricted

root@unmatched2:/var/crash# apport-retrace --gdb --sandbox system --cache ~/.cache/apport-retrace/ _usr_bin_qemu-x86_64-static.1000.crash
Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 743, in <module>
    main()
  File "/usr/bin/apport-retrace", line 487, in main
    sandbox, cache, outdated_msg = apport.sandboxutils.make_sandbox(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 277, in make_sandbox
    pkg = packaging.get_file_package(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 536, in get_file_package
    return self._search_contents(file, map_cachedir, release, arch)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1478, in _search_contents
    self._get_mirror(),
    ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1426, in _get_mirror
    self._mirror = self._get_primary_mirror_from_apt_sources(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1414, in _get_primary_mirror_from_apt_sources
    raise SystemError(
SystemError: cannot determine default mirror: /etc/apt/sources.list does not contain a valid deb line
root@unmatched2:/var/crash#

Changed in apport (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Heinrich Schuchardt (xypron) wrote (last edit ):

Splitting above sources.list line results in:
['deb', '[', 'arch=riscv64', ']', 'http://ports.ubuntu.com/ubuntu-ports/', 'lunar', 'main', 'restricted']

Method _get_primary_mirror_from_apt_sources() incorrectly assumes that if the second field in the line starts with '[' the next field is the mirror url. Instead the method should look for the matching ']'. The field after ']' is the mirror.

    @staticmethod
    def _get_primary_mirror_from_apt_sources(apt_sources):
        """Heuristically determine primary mirror from an apt sources.list."""
        with open(apt_sources, encoding="utf-8") as f:
            for line in f:
                fields = line.split()
                if len(fields) >= 3 and fields[0] == "deb":
                    if fields[1].startswith("["):
                        # options given, mirror is in third field
                        mirror_idx = 2
                    else:
                        mirror_idx = 1
                    if fields[mirror_idx].startswith("http://") or fields[
                        mirror_idx
                    ].startswith("https://"):
                        return fields[mirror_idx]

Revision history for this message
Benjamin Drung (bdrung) wrote :
Benjamin Drung (bdrung)
Changed in apport:
milestone: none → 2.27.0
status: New → In Progress
importance: Undecided → Medium
Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport:
status: In Progress → Fix Committed
Benjamin Drung (bdrung)
Changed in apport:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.26.1-0ubuntu2

---------------
apport (2.26.1-0ubuntu2) lunar; urgency=medium

  * fix(tests): Clear environment for test_run_as_real_user_no_sudo

apport (2.26.1-0ubuntu1) lunar; urgency=medium

  [ Benjamin Drung ]
  * New upstream bug-fix release.
    - SECURITY UPDATE: viewing an apport-cli crash with default pager could
      escalate privilege (LP: #2016023). Do not run sensible-pager as root
      if using sudo/pkexec.
    - Catch HTTPError in UserInterface.file_report (LP: #2008638)
    - Print proper error message if /proc/<pid> is gone (LP: #2008638)
    - Do not drop environment variables when calling GDB (LP: #2012374)
    - Fix parsing options with spaces in sources.list (LP: #1822712)
  * Disable Launchpad crash reports for 23.04 release

  [ Sebastien Bacher ]
  * Let subiquity collect the desktop installer details if available

 -- Benjamin Drung <email address hidden> Fri, 14 Apr 2023 00:17:27 +0200

Changed in apport (Ubuntu):
status: Confirmed → 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.