-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
test_dbm and test_dbm_ndbm segfaults in M1 Mac with Homebrew gdbm 1.23 #89452
Comments
The backtrace according to lldb:
The last 3 frames:
The segfault happens here:
|
Looking at macOS native crash reporting, the issue is in this line of
Crash report:
|
A minimal reproduction is: import dbm.ndbm
from pathlib import Path
db_path = Path("/tmp/test.dbm")
db_path.unlink(missing_ok=True)
f = dbm.ndbm.open(db_path, 'c')
print("Underlying lib:", dbm.ndbm.library)
print("f is an", repr(f))
print("The next line segfaults:")
f.keys() This crashes with:
|
Note that swapping import dbm.gnu
from pathlib import Path
db_path = Path("/tmp/test.dbm")
db_path.unlink(missing_ok=True)
f = dbm.gnu.open(db_path, 'c')
print("f is an", repr(f))
print("The next line runs fine:")
f.keys() This just outputs:
So looks like there is something off with the ndbm compatibility layer of gdbm on M1 Macs. |
This is on Homebrew gdbm 1.23. |
Apparently this runs fine on the MacPorts version of gdbm 1.23. |
Ooohhh, I get it. The reason Homebrew fails and MacPorts works is that the former provides the ndbm-compat interface while the latter doesn't (by default). Python discovers the ndbm-compat interface but then chooses the wrong header, causing segfaults. You see, the macOS SDK ships with a
As you see in the configure output above, the Lines 15 to 19 in 39e6b8a
In sum, this issue can be entirely avoided if the search ordering for dbm compatibility is reversed. If the environment provides gdbm with compat libraries, they should be fully preferred. I'm making a PR to this effect. |
This makes macOS gdbm provided by Homebrew not segfault through correct selection of the linked library (-lgdbm_compat) *AND* the correct ndbm-style header (gdbm-ndbm.h instead of the invalid ndbm.h).
I unlinked the issue because this is not what we want: "linked a pull request that will close this issue" We want to backport the fix. |
This makes macOS gdbm provided by Homebrew not segfault through correct selection of the linked library (-lgdbm_compat) *AND* the correct ndbm-style header (gdbm-ndbm.h instead of the invalid ndbm.h).
See PR, we actually don't want to backport this. So this is fixed for 3.11+. For older Python versions, the workaround is to build with:
|
…th homebrew's gdbm 1.24 Per python#89452 (comment), the issue is fixed in configure for 3.11+, and > For older Python versions, the workaround is to build with: > > ./configure --with-dbmliborder=gdbm:ndbm We need this workaround in GitHub Actions, otherwise the tests fail.
This is now blocking 3.10 & 3.9 backport PRs. I'll re-open. |
…ebrew's gdbm 1.24 (#125112) Per #89452 (comment), the issue is fixed in configure for 3.11+, and > For older Python versions, the workaround is to build with: > > ./configure --with-dbmliborder=gdbm:ndbm We need this workaround in GitHub Actions, otherwise the tests fail.
…h homebrew's gdbm 1.24 (pythonGH-125112) Per https://github.com/python/cpython/issues/89452GH-issuecomment-1116329316, the issue is fixed in configure for 3.11+, and > For older Python versions, the workaround is to build with: > > ./configure --with-dbmliborder=gdbm:ndbm We need this workaround in GitHub Actions, otherwise the tests fail. (cherry picked from commit 850189a)
…brew's gdbm 1.24 (GH-125112) (#125176) Per https://github.com/python/cpython/issues/89452GH-issuecomment-1116329316, the issue is fixed in configure for 3.11+, and > For older Python versions, the workaround is to build with: > > ./configure --with-dbmliborder=gdbm:ndbm We need this workaround in GitHub Actions, otherwise the tests fail. (cherry picked from commit 850189a) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Thanks! Fixed and merged. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Hand-linked PRs
Linked PRs
The text was updated successfully, but these errors were encountered: