-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Cygwin: system sqlite3 modifies DLL search order #30157
Comments
comment:1
sqlite3 is a dependency of python3. Not sure if it is only linked when the corresponding module is used, or in general |
comment:2
Only when the corresponding module is used. |
Commit: |
Author: Erik Bray |
comment:3
It's not pretty, but it does fix the issue. Open to better ideas for what to name this and/or where to insert the fix. New commits:
|
Branch: u/embray/ticket-30157 |
comment:4
Perhaps this should also be reported as a bug to the cygwin maintainers? |
comment:5
Isn't Sage using sqlite3 in src/sage/graphs/graph_database.py ? |
comment:6
Tests run at https://github.com/mkoeppe/sage/actions/runs/174422237 |
comment:7
Tests at https://github.com/mkoeppe/sage/actions/runs/178114628 |
Reviewer: Matthias Koeppe |
Changed branch from u/embray/ticket-30157 to |
Changed commit from |
comment:10
Replying to @mkoeppe:
I did, the maintainer of the Cygwin package for sqlite3 agreed it's a bug and we discussed a possible fix: https://cygwin.com/pipermail/cygwin/2020-July/245536.html |
comment:11
Replying to @dimpase:
It's actually use during Sage start-up, but only when starting in the IPython REPL. It's used by IPython because it stores the interactive history in a sqlite database. This is actually how I was able to narrow this down: because the issue didn't occur when I imported |
Under normal operation Windows searches for DLLs in the following order:
$PATH
.On Cygwin, most DLLs are stored under /usr/bin, which is inserted early on the
$PATH
, but when in the Sage environment$SAGE_LOCAL/bin
supersedes it.However, I discovered that the Cygwin port of sqlite3 contains the following nasty patch, for reasons I can't be sure of:
The function SetDllDirectoryW is a system function which works a little like
LD_LIBRARY_PATH
orLD_PRELOAD
allowing an application to insert a non-standard directory into the DLL search path.Why sqlite3 is doing this I don't know. It has something to do with loading extensions apparently, but there's no reason it should assume I always want to load extensions from
/usr/bin
(e.g. what if I'm using a custom build of sqlite3 installed in/usr/local/bin
.It does this also when the library is first initialized, as opposed to just doing it before loading an extension and then unsetting it. Thus this change to DLL loading behavior affects the rest of the application for the lifetime of the application. It does get undone if
sqlite3_shutdown()
is called but this never happens normally.How does this affect Sage? It's not even obvious that Sage uses sqlite3, but in fact IPython does to store its history, so a sqlite3 database is connected to when starting up the Sage/IPython REPL. This in turn impacts DLL search order for all libraries that haven't been loaded yet, and can cause Cygwin's system versions of those libraries to be privileged over any copies in Sage.
I think this might actually explain some related bugs I've seen in the past, but I'm not sure.
Component: porting: Cygwin
Author: Erik Bray
Branch:
628e7d0
Reviewer: Matthias Koeppe
Issue created by migration from https://trac.sagemath.org/ticket/30157
The text was updated successfully, but these errors were encountered: