[issue42731] Enhancement request for proxying PyString

2020-12-24 Thread Karl Nelson
New submission from Karl Nelson : When developing with JPype, the largest hole currently is that Java returns a string type which cannot be represented as a str. Java strings are string like and immutable and can be pulled to Python when needed, but it is best if they remain in Java until

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-20 Thread Karl Nelson
Karl Nelson added the comment: Okay, well at least now googling Python + "A dynamic link library (DLL) initialization routine failed." give something which could point a user may be able to identify the issue. It wasn't obvious to me that imports did not hold the GIL, but i

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: I found it. The change that hit JPype is https://bugs.python.org/issue33895 Thanks, Eryk Sun for figuring this out. I would never have gotten myself. -- ___ Python tracker <https://bugs.python.org/issue42

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: Drat I missed that one when I was scanning for statics because I was focusing C++ resource rather than looking for Python resources. I also wouldn't have expected this to happen on only one platform, but that was my bad. Is it possible to improve the error

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: Gave another series of shots at the problem. So the reason that attaching the debugger fixes the issue is that it calls LoadLibraryExW for a bunch libraries when it attaches. I was also able to unconditionally trigger the bug even when loading without

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: I will look through the list of samples in Detours to see if there is something that can give us better stacktrace information. If we really need a stack trace I can make Detours bust by creating an intentional segfault and see if we can attach the debugger

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: I looked more at the logs to see if I can find out what to instrument next. The log files unfortunately don't diff well because every line contains a timestamp so I can't a proper alignment as well as all the real addresses. So I wrote a short program

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-19 Thread Karl Nelson
Karl Nelson added the comment: Eryk, Unfortunately, this particular bug is resistant to attaching the debugger. Whenever the debugger is attached the bug disappears. Fortunately the suggestion to use Detours by WildCard65 appears to offer a way to diagnose the issue

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-18 Thread Karl Nelson
Karl Nelson added the comment: The last libraries loaded prior to the failure were... ``` 20201218192451066 20440 50.60: trclnk64: api-ms-win-eventing-provider-l1-1-0.dll [7ffc4c974108 7ffc4c8b7808] 20201218192451066 20440 50.60: trclnk64: EventUnregister0 7ffc4eab37a0

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-18 Thread Karl Nelson
Karl Nelson added the comment: I used Detours with trclnk64 to get the following log: ``` 20201218193836960 4332 50.60: trclnk64: 001 GetProcAddress(,) -> 7ffc4ccebef0 20201218193836960 4332 50.60: trclnk64: 001 GetProcAddress(7ffc4ccd,LCMapStringEx) 20201218193836960 4332 50

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-18 Thread Karl Nelson
Karl Nelson added the comment: Can you be so kind as pointing me to a LoadLibraryExW detour example for Python? I have shimmed a DLL before to capture transaction logs in the past, but not with a Python or a system library. -- ___ Python

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-18 Thread Karl Nelson
Karl Nelson added the comment: Just for reference here are all the dependencies that _jpype has ``` MSVCP140.dll python39.dll

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-18 Thread Karl Nelson
Karl Nelson added the comment: I attempted another deep dive on this one. 1) Removed manual library add platform_specific['libraries'] = ['Advapi32'] No change. 2) Compared symbol wise imports Two imports changed PyIndex_Check PyObject_CheckBuffer plus one additional "fflush"

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-17 Thread Karl Nelson
Karl Nelson added the comment: Well that gives me a place to search from. Unfortunately statics are not likely the source of the issue. I scrubbed all C++ structures from the project into a big structure which has only a single global pointer which I initialize in the init method

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-17 Thread Karl Nelson
Karl Nelson added the comment: Without the pyc everything goes fine... ``` ... _bootlocale' # <_frozen_importlib_external.SourceFileLoader object at 0x0222E9FD5A30> import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x0222E9F88F40> Python 3.9.0

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-17 Thread Karl Nelson
Karl Nelson added the comment: Thanks, I will see if I can get additional diagnostics today. Otherwise I will have to start recompiling Python with diagnostic hooks. I have never had to rebuild python on windows so it may take a while to figure out how to make progress. The monkey patch

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-16 Thread Karl Nelson
Karl Nelson added the comment: I am fairly sure this is a Python "bug" in the sense that there was some change in undocumented change in requirements and the distutils pattern for building a module no longer reflects that requirement. That said very likely JPype is the o

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-14 Thread Karl Nelson
Karl Nelson added the comment: Any progress on this item? I am seeing additional reports of this error in the conda stream tracker and elsewhere. As it only occurs when the debugger is not hooked up I don't have much traction to make progress myself

[issue42617] Enhancement request for PyType_FromSpecWIthBases add option for meta class

2020-12-12 Thread Karl Nelson
Karl Nelson added the comment: Perhaps just having PyType_InitHeapFromSpec which have just heap type linkage and slot copy section would help with the issue. The major problem I have is maintaining the slot code which may change at some point in the future. There would still be some

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-10 Thread Karl Nelson
Karl Nelson added the comment: Oddly that was the only exception that I got. When I hit continue it proceeded without issue and the dll was loaded correctly. However, when I try without the debugger attached the error reappears. So this is one of those Schrodinger errors. I know

[issue42618] Enhancement request for importing stacktraces from foreign sources

2020-12-10 Thread Karl Nelson
New submission from Karl Nelson : In JPype, I am transfer stack information from Java into Python for diagnostics and display purposed. Unfortunately, as the exception system is directly accessing traceback structure elements this cannot be replicated without creating traceback structures

[issue42617] Enhancement request for PyType_FromSpecWIthBases add option for meta class

2020-12-10 Thread Karl Nelson
New submission from Karl Nelson : PyType_FromSpecWithBases is missing an argument for taking a meta class. As a result it is necessary to replicate a large portion of Python code when I need to create a new heap type with a specified meta class. This is a maintenance issue as replicating

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-10 Thread Karl Nelson
Karl Nelson added the comment: I managed to get the debugger attached (unfortunately I am not a windows programmer so I don't use these tools). It appears when loading from a pyc, it is attempting to open the directory as a Zip file which is throwing an exception resulting in a failure

[issue42529] CPython DLL initialization routine failed from PYC cache file

2020-12-01 Thread Karl Nelson
New submission from Karl Nelson : While trying to use JPype on Windows Python 3.9.0, we are running into an bizarre issue with loading the internal module which is written in C. When running a python script the first time the internal module loads correctly. However, the second time