A segfault, then debug troubles

21 views
Skip to first unread message

Steve Shulman-Laniel

unread,
Nov 21, 2024, 4:31:24 PM11/21/24
to pyins...@googlegroups.com
tl;dr: when I run pyinstaller, I get an executable that dumps core. When I run it with a debug Python, I get an executable that can't find basic libraries, even though the Python REPL can. What am I doing wrong?

Hi folks,

I'm trying to package up Locust.io, and its associated locustfile, into a pyinstaller executable. I have a more-complicated locustfile that I actually want to package up, but for debug purposes I'm using a minimal one:

import time
from locust import HttpUser, task, between

It really doesn't even do anything. Then I run 'pyinstaller ./locustfile_minimal.py', get the output below [1], try to run the executable, and:

(ssl_test_venv) [sshulmanlaniel@autobuilder ~/some-project/src/oclivetesting_workers]$ ./dist/locustfile_minimal/locustfile_minimal
Segmentation fault (core dumped)

I want to figure out why it dumped core, so I

1. build a Python debug build with

./configure --with-pydebug --prefix=${HOME}/debug_python
make install

2. make a venv from that debug Python with

./python -m venv ~/ssl_test_venv_debug

3. Install everything I need for this project into the venv, via

pip install -r ~/some-project/requirements.txt

4. re-run pyinstaller using the same command as before.

And now:

(ssl_test_venv_debug) [sshulmanlaniel@autobuilder ~/some-project/src/some-project]$ ./dist/locustfile_minimal/locustfile_minimal
[PYI-6961:ERROR] Module object for struct is NULL!
Traceback (most recent call last):
  File "struct.py", line 13, in <module>
ModuleNotFoundError: No module named '_struct'

I check whether this is a problem with Python:

(ssl_test_venv_debug) [sshulmanlaniel@autobuilder ~/some-project/src/some-project]$ which python
/home/sshulmanlaniel/ssl_test_venv_debug/bin/python
(ssl_test_venv_debug) [sshulmanlaniel@autobuilder ~/some-project/src/some-project]$ python
Python 3.11.10 (main, Nov 21 2024, 20:10:51) [Clang 19.1.3 (https://github.com/llvm/llvm-project.git llvmorg-19.1.3-0-gab51ec on freebsd15
Type "help", "copyright", "credits" or "license" for more information.
>>> import _struct
>>> _struct.__file__
'/usr/home/sshulmanlaniel/python3.11.10/Python-3.11.10/build/lib.freebsd-15.0-CURRENT-amd64-3.11-pydebug/_struct.cpython-311d.so'

So the shared object is there, and the import works fine. So the problem isn't in Python itself, but somewhere between Python and pyinstaller.

What's the trick? What am I missing?

Cheers,
Steve

[1] -

201 INFO: PyInstaller: 6.11.0, contrib hooks: 2024.9
202 INFO: Python: 3.11.10
208 INFO: Platform: FreeBSD-15.0-CURRENT-amd64-64bit-ELF
208 INFO: Python environment: /home/sshulmanlaniel/ssl_test_venv
209 INFO: wrote /usr/home/sshulmanlaniel/some-project/src/some-project/locustfile_minimal.spec
212 INFO: Module search paths (PYTHONPATH):
['/usr/local/lib/python311.zip',
 '/usr/local/lib/python3.11',
 '/usr/local/lib/python3.11/lib-dynload',
 '/home/sshulmanlaniel/ssl_test_venv/lib/python3.11/site-packages',
 '/home/sshulmanlaniel/ssl_test_venv/lib/python3.11/site-packages/setuptools/_vendor',
 '/usr/home/sshulmanlaniel/some-project/src']
380 INFO: checking Analysis
398 INFO: checking PYZ
413 INFO: checking PKG
413 INFO: Bootloader /home/sshulmanlaniel/ssl_test_venv/lib/python3.11/site-packages/PyInstaller/bootloader/FreeBSD-64bit/run
414 INFO: checking EXE
415 INFO: checking COLLECT
WARNING: The output directory "/usr/home/sshulmanlaniel/some-project/src/some-project/dist/locustfile_minimal" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
On your own risk, you can use the option `--noconfirm` to get rid of this question.
4150 INFO: Removing dir /usr/home/sshulmanlaniel/qrs-oclivetesting-workers/src/oclivetesting_workers/dist/locustfile_minimal
4158 INFO: Building COLLECT COLLECT-00.toc
4217 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Reply all
Reply to author
Forward
0 new messages