namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.04k stars 444 forks source link

uftrace record failure when launching python #1377

Open honggyukim opened 2 years ago

honggyukim commented 2 years ago
$ git clone https://github.com/python/cpython.git -b v3.11.0a1 && cd cpython

$ ./configure CFLAGS='-pg -g'

$ make -j8 python

$ ./python --version
Python 3.11.0a1

$ ./python -c 'print("Hello")'
Hello

$ uftrace record python -c ''
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/local'
  sys.base_exec_prefix = '/usr/local'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python'
  sys.prefix = '/usr/local'
  sys.exec_prefix = '/usr/local'
  sys.path = [
    '/usr/local/lib/python310.zip',
    '/usr/local/lib/python3.10',
    '/usr/local/lib/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 0x0000ffff871aa010 (most recent call first):
  <no Python frame>
honggyukim commented 2 years ago

I just found that this is because of not using ./python -c '', but used python -c ''. So the following works fine.

$ uftrace record ./python -c ''

We may have to investigate why it fails.

namhyung commented 2 years ago

Hmm.. strange. Maybe python binary exec'es to itself?