View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0001180||Slicer4||Core: Base Code||public||2011-05-30 13:28||2017-06-07 23:27|
|Priority||low||Severity||minor||Reproducibility||have not tried|
|Target Version||Slicer 4.3.0||Fixed in Version||Slicer 4.3.0|
|Summary||0001180: Slicer might load the wrong Python and other dlls|
The launcher adds the Slicer directories to the PATH env
|Tags||No tags attached.|
From: Steve Pieper [mailto:firstname.lastname@example.org]
Hi Andras -
Very good catch - this will impact developers, but not users, since the python dll is put in the bin directory by the installer as part of cpack.
In general though it seems the windows side-by-side is the 'correct' solution for windows builds. Although it is a pain, it should probably be done automatically as part of the build process.
It looks like there's some support for this in cmake:
Alternatively we could copy the python dlls (and others) into the Slicer-build/bin/<type> directory as part of the build process rather than as part of the packaging process.
On Tue, May 24, 2011 at 11:00 AM, Andras Lasso <email@example.com> wrote:
I tried to build and test Slicer4 on Windows 7. The build was OK, but it
I've found that copying python26.dll into the ...\Slicer-build\bin\Release\
The problem is that the launcher adds the Slicer directories to the PATH env
The problem was the same with Slicer3 and tcl, but probably tcl changed less
I also ran into this problem, and confirm that it was solved by deleting python26.dll from c:\windows\system32 directory.
After deleting python26.dll, I could no longer run python.exe. Perhaps the dll is installed to that location by an official windows python binary.
Andras> Would it be possible to confirm using dependency walker ?
Greg> Could you confirm that python.exe and python26.dll built by Slicer are located in the same folder ?
I confirm that dependency walker shows python26.dll is loaded from c:\windows\system32 if python26.dll is installed in the windows system directories and python26.dll is not available in the executable's directory.
This is the case when attempting to run Slicer from the build tree.
This would happen also if you started any exe that is not located in Slicer 4.1.0\bin uses python (or loads a python-using dll). Fortunately, with the current CLIs this cannot happen, as none of them use python. The problem may happen when somebody tries to launch a python scripted module from command line using python.exe.
The crash when starting Slicer from the build tree could be prevented by adding a line to one of the CMakeLists.txt files to copy Python26.dll into the SlicerQt-real.exe directory.
It was some time ago when I last checked this, but normally the Python installer copies:
Issue-1180-Python-dll-loaded.png (85,102 bytes)
Issue-1180-Python-dll-loaded.png (85,102 bytes)
It seems the problem is resolved. See enclosed screenshot
Dear issue reporter,
Good news :) Slicer developers SOLVED the problem you reported - YOU now need to VERIFY and CLOSE this issue.
The problem still exists. How to reproduce:
This issue affects only developer and based on today hangout discussion, it has been re-targeted for 4.3
Same issue has cropped up again:
Updated documentation link to "Search Path Used by Windows to Locate a DLL"
1) Immediate solution: As part of the Slicer build process, we could copy the python library along side the qSlicerApp-real.exe executable.
2) Alternative/complementary solution: If there is a system python (matching the requirement) available on the windows machine, it could/should probably be used.
While solution (1) will fix that specific issue, should we detect if there are itk/qt/vtk/... already available on the system and warn the developer ? If not, unexpected problem will arise. Should we also copy DLL of VTK, ITK, ... along side the executable ?
We could also ask VTK/ITK/.. to build their library along side the Slicer executable. That would avoid issue but would prevent the developer from deleting Slicer-build inner directory without having to rebuild everything.
Note that this issue somehow became more problematic now (probably because of external reasons). While Andras and Greg could uninstall python 2.6 from their systems to get Slicer start up, I cannot start Slicer now, even after uninstalling Python 2.7. And this is confirmed on other computers too.
So an immediate solution (as in the previous comment) would be much appreciated.
@ungi: Could you investigate why Slicer fails to start even after removing the problematic from system folder. What is the output of dependency walker in that case.
Note that solution (1) will be implemented, Just want to have a better understanding of what is going on.
Have you tried using SetDllDirectory  to override the search path, so that the slicer directories are used first? If this is called by the launcher, then any subsequent loadlibrary calls within the process should respect the modified path.
Seems that "SetDllDirectory" is useful when relying on "LoadLibrary" in case of explicit linking.
Some interesting readings about the topic:
As explained here, explicit linking would be complex process for an application like Slicer: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9a70abb2-ee8e-4c91-8d88-cdb213c5832e/
As of today, copying the python library along side the executable seems to be a good compromise.
If we encounter issue with VTK, ITK, .. libraries, we could also copy them along side the executable.
Dependency Walker says:
When staring Slicer from Visual Studio (in Debug 64-bit mode) it says in the output window:
Humm ... after doing a regular build, there are no file "e:\Slicer4\Debug\Slicer-build\PYTHON27.DLL" but "e:\Slicer4\Debug\Slicer-build\python-install\bin\python27.dll" should exist.
Do you confirm you started both dependency walker and visual studio using the slicer launcher ?
Sorry, you are right. None of the files exist.
I deleted every entry from my Windows Registry that included "System32\python27". There were a few. But the problem is still the same when I try to run Slicer from Visual Studio.
Do you mean that the following file does not exist:
If it does NOT exist, it means there is any issue building python that should be addressed first.
Fixed in r21943
Follow up commit r21948
It fixes error reported on the dashboard:
Closing resolved issues that have not been updated in more than 3 months
Fix committed to 2145-support-for-installing-extension-from-file branch.
Slicer: 2145-support-for-installing-extension-from-file 689851c3
2013-04-26 17:19:08Details Diff
|BUG: Fix startup crash due to improper dynamic linking of python dll
This problem affect the a windows build tree of Slicer.
On windows, as explained in , system path are searched before path
appended to PATH variable.
 Title: Search Path Used by Windows to Locate a DLL
Following the introduction of CMake'ified python (r21863), python 2.7.3 is
now used. Since developer also have a similar version installed on their
system, this is causing Slicer to crash due to binary incompatibility
between the patched version build by Slicer (r21848) and the one
installed on the system.
While this commit address the immediate issue specific to python, the same
problem would occur with VTK, Qt, ITK or any other Slicer external projects
is already installed in the system. The solution implemented by this commit
will have to be revisited.
git-svn-id: http://svn.slicer.org/Slicer4/trunk@21943 3bd1e089-480b-0410-8dfb-8563597acbee
|mod - Applications/SlicerApp/CMakeLists.txt||Diff File|
Slicer: 2145-support-for-installing-extension-from-file cc18ef43
2013-04-26 18:17:12Details Diff
|COMP: Fix config error introduced in r21943 by using PYTHON_LIBRARY_PATH
See issue 0001180 - http://www.na-mic.org/Bug/view.php?id=1180
git-svn-id: http://svn.slicer.org/Slicer4/trunk@21948 3bd1e089-480b-0410-8dfb-8563597acbee
|mod - Applications/SlicerApp/CMakeLists.txt||Diff File|
|2011-05-30 13:28||lassoan||New Issue|
|2011-05-30 13:28||lassoan||Note Added: 0002464|
|2011-05-30 13:38||finetjul||Priority||normal => low|
|2012-01-19 07:01||gregsharp||Note Added: 0003506|
|2012-02-10 10:24||jcfr||Status||new => assigned|
|2012-02-10 10:24||jcfr||Assigned To||=> jcfr|
|2012-04-25 18:37||jcfr||Note Added: 0004082|
|2012-04-25 18:38||jcfr||Note Edited: 0004082|
|2012-04-26 06:32||lassoan||Note Added: 0004085|
|2012-04-26 06:34||lassoan||Note Added: 0004086|
|2012-06-25 15:45||jcfr||File Added: Issue-1180-Python-dll-loaded.png|
|2012-06-25 15:47||jcfr||Note Added: 0004937|
|2012-06-25 15:47||jcfr||Status||assigned => resolved|
|2012-06-25 15:47||jcfr||Fixed in Version||=> Slicer 4.2.0 - Sept 1st 2012|
|2012-06-25 15:47||jcfr||Resolution||open => fixed|
|2012-07-27 15:36||jcfr||Note Added: 0005303|
|2012-07-27 17:24||lassoan||Note Added: 0005430|
|2012-07-27 17:24||lassoan||Status||resolved => feedback|
|2012-07-27 17:24||lassoan||Resolution||fixed => reopened|
|2012-07-27 18:18||jcfr||Status||feedback => assigned|
|2012-08-22 05:42||jcfr||Target Version||=> Slicer 4.2.0 - Feature freeze Sept 1st 2012|
|2012-09-04 12:17||jcfr||Target Version||Slicer 4.2.0 - Feature freeze Sept 1st 2012 => Slicer 4.3.0|
|2012-09-04 12:19||jcfr||Note Added: 0005959|
|2013-04-25 12:08||pieper||Note Added: 0008490|
|2013-04-25 12:21||jcfr||Note Added: 0008491|
|2013-04-25 12:23||jcfr||Note Edited: 0008491|
|2013-04-25 12:25||jcfr||Note Edited: 0008491|
|2013-04-25 12:51||ungi||Note Added: 0008492|
|2013-04-25 13:12||jcfr||Note Added: 0008494|
|2013-04-25 13:20||inorton||Note Added: 0008497|
|2013-04-25 13:47||jcfr||Note Added: 0008498|
|2013-04-25 13:48||ungi||Note Added: 0008499|
|2013-04-25 13:59||jcfr||Note Added: 0008500|
|2013-04-25 14:42||ungi||Note Added: 0008502|
|2013-04-25 14:47||ungi||Note Added: 0008503|
|2013-04-25 14:54||jcfr||Note Edited: 0008500|
|2013-04-25 14:55||jcfr||Note Added: 0008504|
|2013-04-25 15:13||ungi||Note Added: 0008506|
|2013-04-25 15:14||ungi||Note Edited: 0008506|
|2013-04-26 13:19||jcfr||Note Added: 0008521|
|2013-04-26 13:19||jcfr||Status||assigned => resolved|
|2013-04-26 13:19||jcfr||Fixed in Version||Slicer 4.2.0 => Slicer 4.3.0|
|2013-04-26 13:19||jcfr||Resolution||reopened => fixed|
|2013-04-26 14:18||jcfr||Note Added: 0008523|
|2014-03-06 04:53||jcfr||Note Added: 0010787|
|2014-03-06 04:54||jcfr||Status||resolved => closed|
|2017-06-07 23:27||jcfr||Changeset attached||=> Slicer 2145-support-for-installing-extension-from-file cc18ef43|
|2017-06-07 23:27||jcfr||Changeset attached||=> Slicer 2145-support-for-installing-extension-from-file 689851c3|
|2017-06-07 23:27||jcfr||Note Added: 0014646|