Skip to content

Conversation

@wesm
Copy link
Member

@wesm wesm commented Jul 8, 2019

As reported on JIRA, the following script provokes a segfault

#! /usr/bin/env python

import pyarrow
import sys
del sys.modules['pyarrow.lib']

For some reason this does not trigger the destruction of the private _ExtensionTypesInitializer object. Not sure why (Antoine may know). Using the atexit module instead seems to do the trick

@wesm
Copy link
Member Author

wesm commented Jul 8, 2019

@wesm wesm closed this in 90affbd Jul 8, 2019
@wesm wesm deleted the ARROW-5863 branch July 8, 2019 21:28
@pitrou
Copy link
Member

pitrou commented Jul 9, 2019

I'm not sure I understand the underlying cause either. It seems the module-wide _ExtensionTypesInitializer instance was never destroyed. Would be worth opening a Cython issue for advice, IMHO.

@wesm
Copy link
Member Author

wesm commented Jul 10, 2019

I opened cython/cython#3039

@scoder
Copy link
Contributor

scoder commented Jul 10, 2019

In order to prevent common cases for crashes or other weird behaviour at shutdown, module-level cleanup is not enabled by default. Does pyarrow use it?

https://github.com/cython/cython/blob/3c4e11ddcf5634cf15c786e22ac1835a419a3622/Cython/Compiler/Options.py#L63-L67

The comment in there is not entirely correct for Py3 anymore, where the cleanup is triggered by CPython's module object cleanup. That might not be at system exit but when actually unloading the module for whatever (rare) reason, even before exiting. It's still typically the system exit, though.

@scoder
Copy link
Contributor

scoder commented Jul 10, 2019

Updated the comment here.

wesm added a commit that referenced this pull request Jul 13, 2019
…n to avoid segfault

As reported on JIRA, the following script provokes a segfault

```
#! /usr/bin/env python

import pyarrow
import sys
del sys.modules['pyarrow.lib']
```

For some reason this does not trigger the destruction of the private `_ExtensionTypesInitializer` object. Not sure why (Antoine may know). Using the atexit module instead seems to do the trick

Author: Wes McKinney <wesm+git@apache.org>

Closes #4824 from wesm/ARROW-5863 and squashes the following commits:

ba60578 <Wes McKinney> Use atexit module for extension type finalization
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

Successfully merging this pull request may close these issues.

3 participants