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

Apparent segfault in immutables.Map.__init__ #7

Closed
njsmith opened this issue Jul 29, 2018 · 5 comments
Closed

Apparent segfault in immutables.Map.__init__ #7

njsmith opened this issue Jul 29, 2018 · 5 comments

Comments

@njsmith
Copy link

njsmith commented Jul 29, 2018

We're getting an intermittent segfault in the contextvars library, on our MacOS CI: https://ci.cryptography.io/blue/rest/organizations/jenkins/pipelines/python-trio/pipelines/trio/branches/PR-575/runs/2/nodes/6/steps/33/log/?start=0

The crash-handler traceback shows it as happening on line 27 of contextvars/__init__.py, which seems to be:

        self._data = immutables.Map()

So our current hypothesis is that immutables.Map() sometimes segfaults? Does that ring any bells?

We don't know how to reproduce it locally, but I believe that's the python.org build of 3.6.1.

Previous discussion: python-trio/trio#200 (comment)

@njsmith
Copy link
Author

njsmith commented Jul 30, 2018

More details: this seems to happen consistently with CPython 3.6.1 or 3.6.2 on MacOS, but not earlier or later 3.6.x versions, and not on Linux at all: https://travis-ci.org/python-trio/trio/builds/409675722

Of course, it looks like some weird memory corruption thing, so it's possible the bug is latent in other configurations and those are just the builds where it happens to trigger a segfault. But useful for reproducing, maybe.

I also managed to get a traceback out:

(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xd)
  * frame #0: 0x0000000100148dcc Python`visit_decref + 12
    frame #1: 0x0000000102c81435 _map.cpython-36m-darwin.so`map_tp_traverse + 21
    frame #2: 0x0000000100149db7 Python`collect + 439
    frame #3: 0x000000010014aa65 Python`_PyObject_GC_Alloc + 357
    frame #4: 0x000000010014ab13 Python`_PyObject_GC_NewVar + 51
    frame #5: 0x0000000102c8182c _map.cpython-36m-darwin.so`map_tp_new + 236
    frame #6: 0x0000000100080096 Python`type_call + 38
    frame #7: 0x000000010000e8d4 Python`_PyObject_FastCallDict + 180
    frame #8: 0x00000001000f3225 Python`call_function + 165

njsmith added a commit to njsmith/trio that referenced this issue Jul 30, 2018
Travis MacOS is much more functional than it used to be, and on
ci.cryptography.org we're hitting:
  MagicStack/immutables#7

So let's try turning on Travis's MacOS and see how it goes, while
scaling back our Jenkins testing so that bug doesn't block everything.
@1st1
Copy link
Member

1st1 commented Jul 30, 2018

I think the bug is already fixed in immutables, i just need to bump the dep. Can you try to install the latest immutables and see if the bug is still there?

@njsmith
Copy link
Author

njsmith commented Jul 30, 2018

Forcing a pip install immutables==0.6 does seem to have fix the issue: https://travis-ci.org/python-trio/trio/builds/409727578

njsmith added a commit to njsmith/trio that referenced this issue Jul 30, 2018
While the Travis MacOS infrastructure is clearly *much* better than it
used to be, doing these tests on Jenkins is still faster overall, and
it avoids hitting python-triogh-584.

This commit:

- adds a temporary workaround for
  MagicStack/immutables#7
- re-enables all MacOS builds on Jenkins
  - including 3.7, which was previously not enabled
- re-disables Travis MacOS builds
@1st1
Copy link
Member

1st1 commented Jul 30, 2018

I've released contextvars 2.3 that use the fixed immutables package. Closing this now.

@1st1 1st1 closed this as completed Jul 30, 2018
njsmith added a commit to njsmith/trio that referenced this issue Jul 30, 2018
The latest release of contextvars (v2.3) fixed this bug, so we don't
need a workaround anymore:
    MagicStack/immutables#7
@njsmith
Copy link
Author

njsmith commented Jul 31, 2018

Thanks!

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

2 participants