Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 891125 - Installing dev-python/pillow-9.4.0 causes a btrfs kernel panic
Summary: Installing dev-python/pillow-9.4.0 causes a btrfs kernel panic
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL: https://marc.info/?l=linux-btrfs&m=16...
Whiteboard:
Keywords:
Depends on:
Blocks: 635020
  Show dependency tree
 
Reported: 2023-01-16 14:33 UTC by Mark Nowiasz
Modified: 2023-01-29 18:37 UTC (History)
1 user (show)

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


Attachments
btrfs: fix invalid leaf access due to inline extent during lseek (btrfs_fix-invalid-leaf-access.patch,2.67 KB, patch)
2023-01-16 15:58 UTC, Mike Pagano
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Nowiasz 2023-01-16 14:33:01 UTC
This is a *very* odd bug:

When trying to install/upgrade pillow to 9.4.0, a kernel panic erupts when the filesystem is btrfs. I've tested it on two machines, both the same results. After the panic the only way to restore functionality is reboot.

Tested on both kernels 6.1.1 and 6.1.6.

Reproducible: Always

Steps to Reproduce:
1. emerge dev-python/pillow
2. Kernel Panic
3.
Actual Results:  
 * Verifying compiled files for python3.10
strip: x86_64-pc-linux-gnu-strip --strip-unneeded -N __gentoo_check_ldflags__ -R .comment -R .GCC.command.line -R .note.gnu.gold-version
   /usr/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so
   /usr/lib/python3.10/site-packages/PIL/_imagingmath.cpython-310-x86_64-linux-gnu.so
   /usr/lib/python3.10/site-packages/PIL/_imagingtk.cpython-310-x86_64-linux-gnu.so
   /usr/lib/python3.10/site-packages/PIL/_imagingmorph.cpython-310-x86_64-linux-gnu.so

>>> Installing (2 of 2) dev-python/pillow-9.4.0::gentoo

dmesg:
[170064.285087] BTRFS warning (device sda4): bad eb member end: ptr 0x3fe7 start 458276864 member offset 16380 size 8
[170064.285408] general protection fault, probably for non-canonical address 0x5088000000000: 0000 [#1] SMP
[170064.285634] CPU: 3 PID: 102307 Comm: emerge Not tainted 6.1.5-gentoo-r1 #1
[170064.285834] Hardware name: netcup KVM Server, BIOS RS 2000 G9 06/17/2021
[170064.286015] RIP: 0010:btrfs_get_64+0xf4/0x110
[170064.286208] Code: 40 08 48 c1 fa 06 48 8d 0c 04 48 b8 00 00 00 00 80 88 ff ff 48 c1 e2 0c 48 01 c2 81 eb f8 0f 00 00 74 13 31 c0 89 c6 83 c0 01 <0f> b6 3c 32 40 88 3c 31 39 d8 72 ef 48 8b 44 24 08 e9 76 ff ff ff
[170064.286581] RSP: 0018:ffff888141ef3e10 EFLAGS: 00010202
[170064.286746] RAX: 0000000000000001 RBX: 0000000000000004 RCX: ffff888141ef3e1c
[170064.286999] RDX: 0005088000000000 RSI: 0000000000000000 RDI: 000000000000000a
[170064.287304] RBP: ffff88841566f300 R08: 0000000000000004 R09: 00000000ffffdfff
[170064.287620] R10: ffffffff822320c0 R11: ffffffff822320c0 R12: 0000000000000003
[170064.287941] R13: 0000000000003fe7 R14: 0000000000000000 R15: 0000000000000000
[170064.288239] FS:  00007f6c54776740(0000) GS:ffff88842fd80000(0000) knlGS:0000000000000000
[170064.288586] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[170064.288822] CR2: 00007f6c52298018 CR3: 000000040af26000 CR4: 0000000000350ea0
[170064.289131] Call Trace:
[170064.289339]  <TASK>
[170064.289536]  btrfs_file_llseek+0x210/0x5f0
[170064.289793]  ksys_lseek+0x5a/0xa0
[170064.290051]  do_syscall_64+0x3c/0xb0
[170064.290269]  entry_SYSCALL_64_after_hwframe+0x46/0xb0
[170064.290504] RIP: 0033:0x7f6c5494c3c7
[170064.290695] Code: 00 00 90 89 c3 48 8b 05 37 5a 0d 00 f7 db 64 89 18 48 c7 c0 ff ff ff ff eb b1 66 0f 1f 84 00 00 00 00 00 b8 08 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 09 5a 0d 00 f7 d8 64 89 02 48
[170064.291339] RSP: 002b:00007ffc2005f598 EFLAGS: 00000202 ORIG_RAX: 0000000000000008
[170064.291658] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f6c5494c3c7
[170064.291963] RDX: 0000000000000003 RSI: 0000000000000000 RDI: 000000000000000f
[170064.292264] RBP: 000000000000000f R08: 0000000000000069 R09: 0000000000000000
[170064.292605] R10: 00007ffc2005f4c0 R11: 0000000000000202 R12: 0000000000000000
[170064.292911] R13: 0000000000000000 R14: 0000000000000013 R15: 0000000000000000
[170064.293217]  </TASK>
[170064.293388] Modules linked in: tcp_diag inet_diag polyval_clmulni polyval_generic fuse configfs qemu_fw_cfg
[170064.293812] ---[ end trace 0000000000000000 ]---
[170064.294033] RIP: 0010:btrfs_get_64+0xf4/0x110
[170064.294236] Code: 40 08 48 c1 fa 06 48 8d 0c 04 48 b8 00 00 00 00 80 88 ff ff 48 c1 e2 0c 48 01 c2 81 eb f8 0f 00 00 74 13 31 c0 89 c6 83 c0 01 <0f> b6 3c 32 40 88 3c 31 39 d8 72 ef 48 8b 44 24 08 e9 76 ff ff ff
[170064.294782] RSP: 0018:ffff888141ef3e10 EFLAGS: 00010202
[170064.295008] RAX: 0000000000000001 RBX: 0000000000000004 RCX: ffff888141ef3e1c
[170064.295312] RDX: 0005088000000000 RSI: 0000000000000000 RDI: 000000000000000a
[170064.295621] RBP: ffff88841566f300 R08: 0000000000000004 R09: 00000000ffffdfff
[170064.295942] R10: ffffffff822320c0 R11: ffffffff822320c0 R12: 0000000000000003
[170064.296243] R13: 0000000000003fe7 R14: 0000000000000000 R15: 0000000000000000
[170064.296556] FS:  00007f6c54776740(0000) GS:ffff88842fd80000(0000) knlGS:0000000000000000
[170064.296883] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[170064.297119] CR2: 00007f6c52298018 CR3: 000000040af26000 CR4: 0000000000350ea0


Expected Results:  
Installation of pillow

emerge --info
Portage 3.0.43 (python 3.10.9-final-0, default/linux/amd64/17.1/systemd/merged-usr, gcc-12, glibc-2.36-r6, 6.1.6-gentoo x86_64)
=================================================================
System uname: Linux-6.1.6-gentoo-x86_64-Intel-R-_Celeron-R-_J4125_CPU_@_2.00GHz-with-glibc2.36
KiB Mem:     7966424 total,    146520 free
KiB Swap:    8388604 total,   8330748 free
Timestamp of repository gentoo: Sun, 15 Jan 2023 11:00:01 +0000
Head commit of repository gentoo: b787603cf7c8157db88c83dd77f46074f27fa7ed
sh bash 5.2_p15-r1
ld GNU ld (Gentoo 2.40 p1) 2.40
app-misc/pax-utils:        1.3.6-r1::gentoo
app-shells/bash:           5.2_p15-r1::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           3.10.9::gentoo, 3.11.1::gentoo, 3.12.0_alpha4::gentoo
dev-lang/rust:             1.66.1::gentoo
dev-util/cmake:            3.25.1::gentoo
dev-util/meson:            1.0.0::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/sandbox:          2.30-r1::gentoo
sys-apps/systemd:          252.4-r1::gentoo
sys-devel/autoconf:        2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.40::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r1::gentoo
sys-devel/gcc:             12.2.1_p20221231::gentoo
sys-devel/gcc-config:      2.10::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/llvm:            15.0.7::gentoo
sys-devel/make:            4.4::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts:
    sync-rsync-verify-jobs: 1

guru
    location: /var/lib/layman/guru
    masters: gentoo
    priority: 50
    volatile: True

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php8.2/ext-active/ /etc/php/cgi-php8.2/ext-active/ /etc/php/cli-php8.2/ext-active/ /etc/php/fpm-php8.2/ext-active/ /etc/php/phpdbg-php8.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo/ rsync://mirror.eu.oneandone.net/gentoo/ http://mirror.netcologne.de/gentoo/ rsync://mirror.netcologne.de/gentoo/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://ftp.halifax.rwth-aachen.de/gentoo/ ftp://ftp.halifax.rwth-aachen.de/gentoo/ rsync://ftp.halifax.rwth-aachen.de/gentoo/ ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
LINGUAS="de en"
MAKEOPTS="-j4 -l4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X acl aes alsa amd64 bash-completion bluetooth branding bzip2 cli crypt cryptsetup curl dbus dri dvd ffmpeg fortran gdbm git gles gles2 iconv ipv6 jpeg libglvnd libtirpc matroska mmx mp3 multilib ncurses nls nptl opengl openmp pam pcre python readline samba seccomp smartcard smp sse sse2 sse3 ssl systemd test-rust udev unicode upnp usb vaapi vim-syntax wayland xattr zeroconf zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy proxy_fcgi remoteip" APACHE2_MPMS="event" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27 ruby30" USERLAND="GNU" VIDEO_CARDS="intel i965 iris" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-16 14:34:14 UTC
Given this sounds reproducible, I'm guessing that if you try portage[-native-extensions], it won't happen?
Comment 2 Mark Nowiasz 2023-01-16 14:41:07 UTC
(In reply to Sam James from comment #1)
> Given this sounds reproducible, I'm guessing that if you try
> portage[-native-extensions], it won't happen?

To be honest I don't now about this? 

But you're right:

USE="-native-extensions" emerge -1 portage

and

emerge -1 pillow

works without kernel panic
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-16 14:47:33 UTC
Thanks, that's going to be useful in narrowing it down.

The reason (of course, this is still a kernel bug) is that with USE=native-extensions, Portage tries to copy using CoW if possible, so it takes a different path in the kernel.

Are you able to report this to the kernel folks upstream?
Comment 4 Mark Nowiasz 2023-01-16 15:04:50 UTC
(In reply to Sam James from comment #3)
> Thanks, that's going to be useful in narrowing it down.
> 
> The reason (of course, this is still a kernel bug) is that with
> USE=native-extensions, Portage tries to copy using CoW if possible, so it
> takes a different path in the kernel.

Ah, this explains it.

 
> Are you able to report this to the kernel folks upstream?

Not really. First of all I don't think I've got an account there, but even if it would be hard for me to debug it/supply more information because I don't know where in the installation process the kernel bug occurs. Furthermore, the panic means hard rebooting the machine in question which is time consuming and causes a downtime - I was willing to do so to test if it's really a bug or a hardware problem on one of the machines. Since two completely different machines - one hardware, one virtual - are affected we can rule out a hardware problem.

To make a long story short: I'm not really qualified to report this upstreams, compare to Gentoo's kernel team :-)
Comment 5 Mike Pagano gentoo-dev 2023-01-16 15:58:42 UTC
Created attachment 848685 [details, diff]
btrfs: fix invalid leaf access due to inline extent during lseek

Please test this patch and let us know the outcome
Comment 6 Mike Pagano gentoo-dev 2023-01-27 17:07:21 UTC
(In reply to Mark Nowiasz from comment #4)
> (In reply to Sam James from comment #3)
> > Thanks, that's going to be useful in narrowing it down.
> > 
> > The reason (of course, this is still a kernel bug) is that with
> > USE=native-extensions, Portage tries to copy using CoW if possible, so it
> > takes a different path in the kernel.
> 
> Ah, this explains it.
> 
>  
> > Are you able to report this to the kernel folks upstream?
> 
> Not really. First of all I don't think I've got an account there, but even
> if it would be hard for me to debug it/supply more information because I
> don't know where in the installation process the kernel bug occurs.
> Furthermore, the panic means hard rebooting the machine in question which is
> time consuming and causes a downtime - I was willing to do so to test if
> it's really a bug or a hardware problem on one of the machines. Since two
> completely different machines - one hardware, one virtual - are affected we
> can rule out a hardware problem.
> 
> To make a long story short: I'm not really qualified to report this
> upstreams, compare to Gentoo's kernel team :-)


Mark, please test with gentoo-sources-6.1.8
Comment 7 Mark Nowiasz 2023-01-29 08:32:03 UTC
(In reply to Mike Pagano from comment #6)
 
> Mark, please test with gentoo-sources-6.1.8

Works :-) At 6.1.8 I'm able to emerge pillow (with USE + native-extensions).