load wx module works OK under python.exe (command line), but not GDB.exe's python command line interface

Hi, I just download and install wxpython 3.0 from official site in my WinXP, and I try to run “import wx” under GDB’s python interface, but I get failed below:

GNU gdb (GDB) 7.8.50.20140717-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) python import wx
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\__init__.py", li
ne 45, in <module>
    from wx._core import *
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\_core.py", line
4, in <module>
    import _core_
ImportError: DLL load failed: The specified module could not be found.
Error while executing Python code.
(gdb)

``

But this command works OK under python.exe’s command line interface, any one has encountered this problem?

BTW: I have post the full description about the DLL dependency screen shot from dependency walker in the post here:
import wx failed under GDB python interface, R6034: An application has made an attempt to load the C runtime library incorrectly - http://stackoverflow.com/questions/24988815/import-wx-failed-under-gdb-python-interface-r6034-an-application-has-made-an-a

Thanks.

I tried using cygwin to debug some segfaults but it turned out the cygwin python.exe wasn’t compiled with the same version of some MSVC .DLL as the win32 module (which the project was depending on) so I couldn’t use it.

I ended up downloading the faulthandler module (faulthandler.readthedocs.org) which was enough for me to trace through some segfaults and get them fixed.

Using pythonw.exe I had to pass a file to faulthandler.enable, since the console doesn’t exist with pythonw.exe and since if there was a segfault the GUI would disappear (in case you had redirected stdout and stderr to a GUI textbox).

Watch out if you are spawning new processes, the file handles will get associated with the new processes and won’t close if those processes stay alive after your python wants to be finished (faulthandler file handle gets attached to processes opened with subprocess.Popen · Issue #6 · vstinner/faulthandler · GitHub)

···

On Sunday, July 27, 2014 11:30:59 PM UTC-7, asm warrior wrote:

Hi, I just download and install wxpython 3.0 from official site in my WinXP, and I try to run “import wx” under GDB’s python interface, but I get failed below:

GNU gdb (GDB) 7.8.50.20140717-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://[gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html)>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://[www.gnu.org/software/gdb/bugs/](http://www.gnu.org/software/gdb/bugs/)>.
Find the GDB manual and other documentation resources online at:
<http://[www.gnu.org/software/gdb/documentation/](http://www.gnu.org/software/gdb/documentation/)>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) python import wx
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\__init__.py", li
ne 45, in <module>
    from wx._core import *
  File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\_core.py", line
4, in <module>
    import _core_
ImportError: DLL load failed: The specified module could not be found.
Error while executing Python code.
(gdb)

``

But this command works OK under python.exe’s command line interface, any one has encountered this problem?

BTW: I have post the full description about the DLL dependency screen shot from dependency walker in the post here:
import wx failed under GDB python interface, R6034: An application has made an attempt to load the C runtime library incorrectly - http://stackoverflow.com/questions/24988815/import-wx-failed-under-gdb-python-interface-r6034-an-application-has-made-an-a

Thanks.

Hi, many thanks for the reply, and thank you for supply a debug tool to hunt the crash bug. By far, I haven’t tried them, but I have found a solution to fix the dll loading problem.
It was due to the loading of MSVCRT’s dll files, I see that all the pyd file and dll file should have a manifest, otherwise, an error will reported.

The detailed fix was put as an answer to my stackoverflow question: my solution to this problem.

Thanks.

asmwarrior(ollydbg)

···

On Monday, July 28, 2014 11:06:32 PM UTC+8, Nathan McCorkle wrote:

I tried using cygwin to debug some segfaults but it turned out the cygwin python.exe wasn’t compiled with the same version of some MSVC .DLL as the win32 module (which the project was depending on) so I couldn’t use it.

I ended up downloading the faulthandler module (faulthandler.readthedocs.org) which was enough for me to trace through some segfaults and get them fixed.

Using pythonw.exe I had to pass a file to faulthandler.enable, since the console doesn’t exist with pythonw.exe and since if there was a segfault the GUI would disappear (in case you had redirected stdout and stderr to a GUI textbox).

Watch out if you are spawning new processes, the file handles will get associated with the new processes and won’t close if those processes stay alive after your python wants to be finished (https://github.com/haypo/faulthandler/issues/6)

Huh, crazy fix! Thanks for the update, I will keep this in mind in case I have DLL issues in the future!

···

On Monday, July 28, 2014 4:43:36 PM UTC-7, asm warrior wrote:

On Monday, July 28, 2014 11:06:32 PM UTC+8, Nathan McCorkle wrote:

I tried using cygwin to debug some segfaults but it turned out the cygwin python.exe wasn’t compiled with the same version of some MSVC .DLL as the win32 module (which the project was depending on) so I couldn’t use it.

I ended up downloading the faulthandler module (faulthandler.readthedocs.org) which was enough for me to trace through some segfaults and get them fixed.

Using pythonw.exe I had to pass a file to faulthandler.enable, since the console doesn’t exist with pythonw.exe and since if there was a segfault the GUI would disappear (in case you had redirected stdout and stderr to a GUI textbox).

Watch out if you are spawning new processes, the file handles will get associated with the new processes and won’t close if those processes stay alive after your python wants to be finished (https://github.com/haypo/faulthandler/issues/6)

Hi, many thanks for the reply, and thank you for supply a debug tool to hunt the crash bug. By far, I haven’t tried them, but I have found a solution to fix the dll loading problem.
It was due to the loading of MSVCRT’s dll files, I see that all the pyd file and dll file should have a manifest, otherwise, an error will reported.

The detailed fix was put as an answer to my stackoverflow question: my solution to this problem.

Thanks.

asmwarrior(ollydbg)