Unicode exception when parsing some crashes

Bug #1410672 reported by Ritesh Raj Sarraf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Undecided
Unassigned
apport (Debian)
Fix Released
Unknown

Bug Description

Package: apport
Version: 2.15.1-1
Severity: important

This behavior seems to be very racy.

ERROR: apport (pid 1148) Wed Jan 14 12:46:21 2015: pid: 1148, uid: 1000, gid: 1000, euid: 0, egid: 0
ERROR: apport (pid 1148) Wed Jan 14 12:46:21 2015: environment: environ({})
ERROR: apport (pid 1278) Wed Jan 14 12:48:05 2015: called for pid 1264, signal 11, core limit 0
ERROR: apport (pid 1278) Wed Jan 14 12:48:05 2015: executable: /bin/sleep (command line "sleep 900")
ERROR: apport (pid 1278) Wed Jan 14 12:48:05 2015: Unhandled exception:
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 389, in <module>
    if is_closing_session(pid, pidstat.st_uid):
  File "/usr/share/apport/apport", line 213, in is_closing_session
    env = e.read().split('\0').decode('utf-8')
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2646: ordinal not in range(128)
ERROR: apport (pid 1278) Wed Jan 14 12:48:05 2015: pid: 1278, uid: 1000, gid: 1000, euid: 0, egid: 0
ERROR: apport (pid 1278) Wed Jan 14 12:48:05 2015: environment: environ({})

If the same code is manualy run, e.read() succeeds.

In [4]: pid = "1543"

In [5]: with open('/proc/%s/environ' % pid) as e:
            env = e.read().split('\0')
...:

In [6]:

-- System Information:
Debian Release: 8.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages apport depends on:
ii gir1.2-glib-2.0 1.42.0-2.2
ii lsb-base 4.1+Debian13+nmu1
ii python3 3.4.2-2
ii python3-apport 2.15.1-1
ii python3-gi 3.14.0-1
pn python:any <none>

Versions of packages apport recommends:
ii policykit-1 0.105-8

Versions of packages apport suggests:
ii apport-gtk 2.15.1-1
ii apport-kde 2.15.1-1

-- Configuration Files:
/etc/apport/crashdb.conf changed:
default = 'debian-debug'
databases = {
    'ubuntu': {
        'impl': 'launchpad',
        'bug_pattern_url': 'http://people.canonical.com/~ubuntu-archive/bugpatterns/bugpatterns.xml',
        'dupdb_url': 'http://people.canonical.com/~ubuntu-archive/apport-duplicates',
        'distro': 'ubuntu',
        'escalation_tag': 'bugpattern-needed',
        'escalated_tag': 'bugpattern-written',
    },
    'fedora': {
         # NOTE this will change Fall '07 when RHT switches to bugzilla 3.x!
        'impl': 'rhbugzilla',
        'bug_pattern_url': 'http://qa.fedoraproject.org/apport/bugpatterns.xml',
        'distro': 'fedora'
    },
    'debian': {
        'impl': 'debian',
        'distro': 'debian',
        'smtphost': 'reportbug.debian.org',
        'recipient': '<email address hidden>',
        'sender': ''
    },
    'debian-debug': {
 'impl': 'debian',
 'distro': 'debian',
 'smtphost': 'localhost',
 'recipient': '<email address hidden>',
 'sender': '<email address hidden>'
    },
    'debug': {
        # for debugging
        'impl': 'memory',
        'bug_pattern_url': '/tmp/bugpatterns.xml',
        'distro': 'debug'
    },
}

/etc/init.d/apport changed:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
if [ -f /etc/default/apport ]; then
 . /etc/default/apport
fi
start() {
    [ "$enabled" = "1" ] || [ "$force_start" = "1" ] || exit 0
    mkdir -p -m 1777 /var/crash
    ulimit -c "unlimited"
    # check for kernel crash dump, convert it to apport report
    if [ -e /var/crash/vmcore ]
    then
    log_daemon_msg "Checking for kernel crash dumps"
 /usr/share/apport/kernel_crashdump || true
    log_end_msg 0
    fi
    log_daemon_msg "Enabling apport service"
    echo "|/usr/share/apport/apport %p %s %c" > /proc/sys/kernel/core_pattern
    log_end_msg 0
}
stop() {
    log_daemon_msg "Disabling apport service"
    if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" != "|" ]
    then
 exit 1
    else
 echo "core" > /proc/sys/kernel/core_pattern
    fi
    log_end_msg 0
}
restart() {
    stop
    start
}
status() {
    log_daemon_msg "Checking apport service"
    grep -qi "|/usr/share/apport/apport" /proc/sys/kernel/core_pattern && log_end_msg 0 || log_end_msg 1
}
case "$1" in
    start|stop|restart)
 $1
 ;;
    force-reload)
 restart
 ;;
    status)
 status
 ;;
    *)
 echo "Usage: $0 {start|stop|restart|force-reload|status}"
 exit 1;
 ;;
esac

-- debconf-show failed

Tags: debian
Changed in apport (Debian):
status: Unknown → New
Revision history for this message
Martin Pitt (pitti) wrote :

This was fixed upstream in r2940, released in 2.17.1.

Changed in apport:
status: New → Fix Released
Changed in apport (Debian):
status: New → 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.