Bug 2080519

Summary: python3-libs 3.9.12-1 on s390x has broken sys.path (missing slash) under qemu 6.2.0
Product: [Fedora] Fedora Reporter: Kenneth Salerno <kennethsalerno>
Component: qemuAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: berrange, cfergeau, crobinso, cstratak, dan, fzatlouk, kchamart, mhroncok, ondrejj, pbonzini, philmd, python-maint, python-sig, rjones, thrnciar, thuth, torsava, virt-maint, vstinner
Target Milestone: ---   
Target Release: ---   
Hardware: s390x   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-6.2.0-9.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 01:54:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 467765, 2073195    

Description Kenneth Salerno 2022-04-29 21:49:19 UTC
python-libs-3.9.12-1.fc34 introduced a sys.path bug
To resolve, must downgrade to python-libs-3.9.2-1.fc34

ERROR SAMPLE:
$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib64'
  sys.executable = '/usr/bin/python'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib64/python39.zip',
    '/usr/lib64python3.9',
    '/usr/lib64/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000003ff85976ed0 (most recent call first):
<no Python frame>

FIX:
$ sudo PYTHONPATH=/usr/lib64/python3.9:/usr/lib64/python3.9/lib-dynload dnf downgrade python3
$ python
Python 3.9.2 (default, Feb 20 2021, 00:00:00)
[GCC 11.0.0 20210210 (Red Hat 11.0.0-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Comment 1 Miro Hrončok 2022-04-30 11:10:15 UTC
Thanks for the report. When you upgrade back to python3-libs-3.9.12-1.fc34, does the problem happen again? Is your s390x emulated or bare metal?

We got a similar report for RHEL 9 in bz2073195 but we could not reproduce it.

Comment 2 Miro Hrončok 2022-04-30 11:18:04 UTC
I cannot reproduce this:




$ podman run --arch s390x --rm -ti fedora:34 /usr/bin/bash

[root@cfc4cbf3e0b3 /]# rpm -q python3-libs
python3-libs-3.9.10-1.fc34.s390x

[root@cfc4cbf3e0b3 /]# dnf upgrade python3-libs
...

[root@cfc4cbf3e0b3 /]# rpm -q python3-libs
python3-libs-3.9.12-1.fc34.s390x

[root@d6736d92a448 /]# python3
Python 3.9.12 (main, Mar 25 2022, 00:00:00) 
[GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib64/python39.zip', '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages']


[root@d6736d92a448 /]# python3 -m site
sys.path = [
    '/',
    '/usr/lib64/python39.zip',
    '/usr/lib64/python3.9',
    '/usr/lib64/python3.9/lib-dynload',
    '/usr/lib64/python3.9/site-packages',
    '/usr/lib/python3.9/site-packages',
]
USER_BASE: '/root/.local' (doesn't exist)
USER_SITE: '/root/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

Comment 3 Miro Hrončok 2022-04-30 11:22:32 UTC
> Is your s390x emulated or bare metal?

And if emulated, please tell me exactly how. What is the host operating system (e.g. is it Fedora 34 itself on x86_64?) and what is the virtualization tool.

Comment 4 Kenneth Salerno 2022-04-30 13:26:50 UTC
Yes, the s390x machine is emulated:
host: Ubuntu 22.04 x86_64 on top of Windows Subsystem for Linux (WSL) on Windows 10 Pro
s390x system emulation: QEMU 6.2.0

Comment 5 Kenneth Salerno 2022-04-30 13:36:52 UTC
(In reply to Miro Hrončok from comment #1)
> Thanks for the report. When you upgrade back to python3-libs-3.9.12-1.fc34,
> does the problem happen again? Is your s390x emulated or bare metal?
> 
> We got a similar report for RHEL 9 in bz2073195 but we could not reproduce
> it.

Yes, I tried upgrading after the successful downgrade and it introduced the same problem again

Comment 6 Kenneth Salerno 2022-04-30 20:07:02 UTC
(In reply to Kenneth Salerno from comment #4)
> Yes, the s390x machine is emulated:
> host: Ubuntu 22.04 x86_64 on top of Windows Subsystem for Linux (WSL) on
> Windows 10 Pro
> s390x system emulation: QEMU 6.2.0

I also tried upgrading to WSL2, same issue:

C:\Users\KenSalerno>wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-22.04    Running         2

Comment 7 Dan Horák 2022-05-02 08:28:15 UTC
python3-3.9.12-1.fc34.s390x works just fine on real hw (tested with z13, z14, z15), so this is very unlikely a python issue, but most likely an emulation issue. Please move under qemu.

Comment 8 Miro Hrončok 2022-05-02 08:42:44 UTC
Reassigned to qemu in Fedora 36, where we have 6.2.0

Comment 9 Thomas Huth 2022-05-05 09:12:00 UTC
In BZ 2073195 it has been mentioned that it should work again when using the new QEMU v7.0.0 ... so it might be worth a try to bisect the issue if you need the fix in 6.2 as well.

Comment 10 Miro Hrončok 2022-05-05 09:54:23 UTC
I can reproduce! On Fedora 36 with qemu-system-s390x-core-6.2.0-6.fc36.x86_64

I downloaded https://download.fedoraproject.org/pub/fedora-secondary/releases/34/Cloud/s390x/images/Fedora-Cloud-Base-34-1.2.s390x.qcow2


$ virt-customize -v -a Fedora-Cloud-Base-34-1.2.s390x.qcow2 --root-password password:toor
$ qemu-system-s390x -machine s390-ccw-virtio -device virtio-rng -cpu max,zpci=on -m 4096 -smp 2 -serial mon:stdio -display none -boot menu=on -device virtio-blk-ccw,id=dev-disk0,drive=disk0 -drive id=disk0,file=Fedora-Cloud-Base-34-1.2.s390x.qcow2,if=none -device virtio-scsi
...
After "[  OK  ] Reached target Cloud-init target" I logged in as root:toor (the login prompt is intermingled with the most recent logs)

[root@fedora ~]# rpm -q python3
python3-3.9.2-1.fc34.s390x
[root@fedora ~]# dnf --repo=updates update python3
...
[root@fedora ~]# rpm -q python3
python3-3.9.12-1.fc34.s390x
[root@fedora ~]# python3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib64'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib64/python39.zip',
    '/usr/lib64python3.9',
    '/usr/lib64/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000003ff84478710 (most recent call first):
<no Python frame>

Comment 11 Richard W.M. Jones 2022-05-05 10:18:04 UTC
Tip: add ,snapshot=on to place a snapshot over the drive.
Also: virt-customize --remove cloud-init

I can also reproduce this with v6.2.0, can confirm it is fixed
in current git head (44f28df24767c), and am attempting the bisection.

Comment 12 Richard W.M. Jones 2022-05-05 10:20:57 UTC
(In reply to Richard W.M. Jones from comment #11)
> I can also reproduce this with v6.2.0, can confirm it is fixed
> in current git head (44f28df24767c), and am attempting the bisection.
                       ^^^^

Sorry, copied the wrong hash.  The good hash is 1fba9dc71a17

Comment 13 Miro Hrončok 2022-05-05 10:34:00 UTC
> Also: virt-customize --remove cloud-init

Nice tip!

------

FTR I've tried to run the exact same commands on Fedora 35 with qemu 6.1.0-14.fc35 and it doe snot happen there.

Comment 14 Richard W.M. Jones 2022-05-05 12:05:00 UTC
Bisected the fix to:

commit 46697cb96e1cc6c3f1edbe572cee1ce9ac97cc58
Author: Richard Henderson <richard.henderson>
Date:   Mon Mar 14 17:25:06 2022 -0700

    accel/tcg: Fix cpu_ldq_be_mmu typo
    
    In the conversion to cpu_ld_*_mmu, the retaddr parameter
    was corrupted in the one case of cpu_ldq_be_mmu.
    
    Fixes: f83bcecb1 ("accel/tcg: Add cpu_{ld,st}*_mmu interfaces")
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/902
    Signed-off-by: Richard Henderson <richard.henderson>
    Message-Id: <20220315002506.152030-1-richard.henderson>
    Reviewed-by: Philippe Mathieu-Daudé <f4bug>
    Tested-by: Thomas Huth <thuth>
    Signed-off-by: Thomas Huth <thuth>

 accel/tcg/cputlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Do we want to backport this?  This is already fixed in Rawhide / F37+
but is broken in Fedora 36.  It is OK in Fedora 35.

Comment 15 Miro Hrončok 2022-05-05 12:14:13 UTC
Is qemu doing upstream 6.2.x maintanance releases? I'd like to get that there if possible, so people won't assume Python is broken on RHEL9/s390x.

If not, a Fedora backport is the next best thing.

Comment 16 Richard W.M. Jones 2022-05-05 12:17:15 UTC
(In reply to Miro Hrončok from comment #15)
> Is qemu doing upstream 6.2.x maintanance releases? I'd like to get that
> there if possible, so people won't assume Python is broken on RHEL9/s390x.

In theory, although I do not see any stable-6.2 branch upstream so far.

> If not, a Fedora backport is the next best thing.

Let's try this one for now.

Comment 18 Fedora Update System 2022-05-05 19:30:33 UTC
FEDORA-2022-eed7d1e529 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-eed7d1e529

Comment 19 Miro Hrončok 2022-05-05 22:26:42 UTC
*** Bug 2073195 has been marked as a duplicate of this bug. ***

Comment 20 Fedora Update System 2022-05-06 11:01:58 UTC
FEDORA-2022-eed7d1e529 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-eed7d1e529`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-eed7d1e529

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 21 Fedora Update System 2022-05-10 01:54:14 UTC
FEDORA-2022-eed7d1e529 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.