Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multidict 4.7.1 causes segfault when bundled with PyInstaller #432

Closed
gmarull opened this issue Dec 12, 2019 · 11 comments
Closed

multidict 4.7.1 causes segfault when bundled with PyInstaller #432

gmarull opened this issue Dec 12, 2019 · 11 comments

Comments

@gmarull
Copy link

gmarull commented Dec 12, 2019

Describe the bug

After upgrading to multidict 4.7.1 we have found that the applications we bundle using PyInstaller crash. Actually, I discovered this problem because we use aiohttp which depends on multidict. Version 4.6.1 does not have this problem.

To Reproduce

  1. Create a new virtual environment
  2. pip install multidict==4.7.1 pyinstaller
  3. Create a simple test.py script with:
print("Hello!")
import multidict
  1. Bundle it pyinstaller test.py
  2. Run it:
./dist/test/test
Hello!
[1]    22548 segmentation fault (core dumped)  ./dist/test/test

Expected behavior

Application prints "Hello!" and quits nicely.

Logs/tracebacks

Provided above.

Your version of the Python

Observed with 3.6.9 and 3.7.5

Your version of the multidict distribution

4.7.1

Additional context

N/A

@razaqq
Copy link

razaqq commented Dec 12, 2019

Im getting this with every version > 4.6.1 (4.7.0 and 4.7.1).
Took me like 6 hours to find out it was multidict causing this...

@asvetlov
Copy link
Member

Thanks for the report!

@Varriount
Copy link

Varriount commented Dec 12, 2019

This also happens when multidict is used with nuitka.

@razaqq A temporary workaround is to set the MULTIDICT_NO_EXTENSIONS environment variable to something before installing via pip, and to then pip install --no-binary multidict multidict (you might need to add --upgrade --force-reinstall --ignore-installed too, if the package is already installed).

I encountered this problem, and changed the install lines in my CI/CD pipeline to:

export MULTIDICT_NO_EXTENSIONS=1
pip install --upgrade --force-reinstall --ignore-installed --no-binary :all: <package_dir>

@Varriount
Copy link

@asvetlov GDB states that the segfault occurs at https://github.com/aio-libs/multidict/blob/master/multidict/_multidict.c#L1595 , though I don't know if that's 100% accurate, as I wasn't working with a debug build (I don't think).

@asvetlov
Copy link
Member

Decref of static type is definitely a mistake but it happens on import failing only as I see.
I wonder why the import multidict fails at all?

@iemelyanov
Copy link
Contributor

iemelyanov commented Dec 13, 2019

Decref of static type is definitely a mistake but it happens on import failing only as I see.
I wonder why the import multidict fails at all?

The fail happens here - https://github.com/aio-libs/multidict/blob/master/multidict/_multidict.c#L1494. And only when using pyinstaller.

@asvetlov
Copy link
Member

@iemelyanov thanks!
I'll have time to work on the fix in 2 hours.

@Oberon00
Copy link

Oberon00 commented Dec 13, 2019

A segfault with 4.7.0 also occurred in open-telemetry/opentelemetry-python#329. This is not using py installer or any other bundling tool.

@philpax
Copy link

philpax commented Dec 18, 2019

Can confirm that we've been getting random segfaults with 4.7.1; downgrading to 4.6.1 fixed the issue for us. This is through regular pip installation.

@kkagill
Copy link

kkagill commented Dec 19, 2019

In my case, it crashed with slack-client 2.5.0. Downgrading to 4.6.1 fixed the problem.

@asvetlov
Copy link
Member

Fixed by #438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants