Skip to content

Cygwin: problem with DLL search order when using system Python #30149

@embray

Description

@embray

I noticed a problem when trying to run the tests for the latest Sage, that the wrong version of libR.dll was being loaded, because I have R installed via Sage, but I also have the R package for Cygwin installed.

My path starts with:

/home/embray/src/sagemath/sage/local/lib/R/lib:/home/embray/src/sagemath/sage/local/lib:/home/embray/src/sagemath/sage/build/bin:/home/embray/src/sagemath/sage/src/bin:/home/embray/src/sagemath/sage/local/bin:/usr/local/bin:/usr/bin

so when importing rpy2 it should link with the libR.dll that's in $SAGE_LOCAL/lib/R/lib. Normally this has been the case.

But when using the system Python this is not so. This is because according to the standard DLL search path the first place it looks is:

The directory where the executable module for the current process is located.

Well, when running the system Python that's /usr/bin where python3.7m.exe lives. However, that's also where the system's libR.dll lives.

This is just an example, but it's a broader problem: For any DLL linked to by a compiled Python module, it will always privilege the one in /usr/bin over a copy provided by Sage.

What we might have to do is, at least on Cygwin, when creating the venv it should actually copy the Python executable instead of just symlinking to it. I believe venv has an option for this.

CC: @dimpase @mkoeppe

Component: porting: Cygwin

Author: Erik Bray

Branch/Commit: f7213c5

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/30149

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions