Open N-Coder opened 2 years ago
Looks like some callee returns (void*)-1
as an error code, with the caller not handling said error. Probably b/c it's expecting a pointer and hence only checking for nullptr
.
Listing or <tab>
completion should not enter CPyCppyy::PyException::operator=
, though. But setValueWithAlloc
seems to be exclusively used for printing names, which makes sense in the context of building a list for <tab>
-completion. Then again, I wouldn't expect GetMangledName()
to show up.
Probably won't be able to say anything more sensible unless I can reproduce it. Is it just a matter of installing https://pypi.org/project/ogdf-python/ on Windows and hitting <tab>
?
This is actually reproducible with plain cppyy, no pythonizations from ogdf-python (or binaries from ogdf-wheel) needed:
git clone --recursive https://github.com/ogdf/ogdf.git
cd ogdf
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON '-DCMAKE_INSTALL_PREFIX=./install' -DCMAKE_BUILD_RPATH='$ORIGIN;@loader_path' -DCMAKE_INSTALL_RPATH='$ORIGIN;@loader_path' -DMACOSX_RPATH=TRUE
cmake --build . --config Release
cmake --install .
python
import cppyy
cppyy.add_library_path("install\\bin")
cppyy.add_include_path("install\\include")
cppyy.include("ogdf/basic/internal/config_autogen.h")
cppyy.include("ogdf/basic/internal/config.h")
cppyy.include("ogdf/basic/Graph.h")
cppyy.include("ogdf/fileformats/GraphIO.h")
cppyy.load_library("OGDF")
from cppyy.gbl import ogdf
ogdf.Graph()
<cppyy.gbl.ogdf.Graph object at 0x0000012C952F9830>
dir(ogdf) # or ogdf.G<TAB>
==========================================
=============== STACKTRACE ===============
==========================================
================ Thread 0 ================
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!cling::runtime::internal::setValueWithAlloc()
libCling!CppyyLegacy::TClingMethodInfo::GetMangledName()
libCling!CppyyLegacy::TCling::MethodInfo_GetMangledName()
libCoreLegacy!CppyyLegacy::TFunction::TFunction()
libCoreLegacy!CppyyLegacy::TMethod::TMethod()
libCoreLegacy!CppyyLegacy::TListOfFunctions::Get()
libCoreLegacy!CppyyLegacy::TListOfFunctions::Load()
libCoreLegacy!CppyyLegacy::TClass::GetListOfMethods()
libcppyy_backend!Cppyy::GetAllCppNames()
libcppyy.cp310-win_amd64!CPyCppyy::PyException::operator=()
python310!PyObject_GC_Malloc()
python310!PySequence_Check()
python310!PySequence_Check()
python310!PySequence_Check()
python310!PyDict_MergeFromSeq2()
python310!PyEval_EvalFrameDefault()
python310!PyEval_EvalCode()
python310!PyEval_EvalCode()
python310!Py_BuildValue()
python310!Py_BuildValue()
python310!PyRun_InteractiveOneObject()
python310!PyRun_InteractiveLoopObject()
python310!Py_gitversion()
python310!PyRun_AnyFileExFlags()
python310!Py_gitversion()
python310!Py_RunMain()
python310!Py_RunMain()
python3.10!??
python3.10!??
KERNEL32!BaseThreadInitThunk()
ntdll!RtlUserThreadStart()
================ Thread 1 ================
ntdll!ZwWaitForWorkViaWorkerFactory()
ntdll!TpReleaseCleanupGroupMembers()
KERNEL32!BaseThreadInitThunk()
ntdll!RtlUserThreadStart()
================ Thread 2 ================
ntdll!ZwWaitForMultipleObjects()
KERNELBASE!WaitForMultipleObjectsEx()
combase!CoRevokeInitializeSpy()
combase!CoRevokeInitializeSpy()
combase!CoRevokeInitializeSpy()
combase!CoRevokeInitializeSpy()
KERNEL32!BaseThreadInitThunk()
ntdll!RtlUserThreadStart()
================ Thread 3 ================
win32u!NtUserGetMessage()
USER32!GetMessageW()
combase!CoFreeUnusedLibraries()
combase!CoFreeUnusedLibraries()
combase!CoRevokeInitializeSpy()
combase!CoRevokeInitializeSpy()
KERNEL32!BaseThreadInitThunk()
ntdll!RtlUserThreadStart()
==========================================
============= END STACKTRACE =============
==========================================
Process finished with exit code -2147483645
It even works entirely without the OGDF, the following is a MRE that yields the same crash and stacktrace:
import cppyy
cppyy.cppdef("""
namespace mynamespace {
template<class E> class Foo {
void bar(Foo<E> A);
};
template<class E>
void Foo<E>::bar(Foo<E> A) {
}
}
""")
from cppyy.gbl import mynamespace
print(dir(mynamespace))
Dropping the parameter from bar
or giving its code inside the class "fixes" the crash. Foo<E>::bar
used to be ogdf::Array<E, INDEX>::copy
, if that is relevant.
Note: this is probably the same bug as https://github.com/kunitoki/popsicle/issues/10
Possibly related: using .Class
crashes the root shell, e.g. following the example from here:
C:\Users\Niko>root
------------------------------------------------------------------
| Welcome to ROOT 6.26/06 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for win64 on Jul 28 2022, 18:08:51 |
| From tags/v6-26-06@v6-26-06 |
| With MSVC 19.32.31332.0 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] TLine l;
root [1] l.Print();
TLine X1=0.000000 Y1=0.000000 X2=0.000000 Y2=0.000000
root [2] .Class TLine
List of classes===========================================================================
class type_info
SIZE: 24 FILE: vcruntime_typeinfo.h LINE: -1
List of member variables --------------------------------------------------
vcruntime_typeinfo.h -1 0x8 private: mutable struct __std_type_info_data _Data, size = 16
vcruntime_typeinfo.h -1 0x0 public: const char *_UndecoratedName
vcruntime_typeinfo.h -1 0x8 public: const char _DecoratedName[1]
List of member functions :---------------------------------------------------
filename line:size busy function type and name
(compiled) (NA):(NA) 0 public: type_info(const type_info &);
(compiled) (NA):(NA) 0 public: class type_info &operator=(const class type_info &) = delete;
(compiled) (NA):(NA) 0 public: size_t hash_code() const noexcept;
(compiled) (NA):(NA) 0 public: _Bool operator==(const class type_info &_Other) const noexcept;
(compiled) (NA):(NA) 0 public: _Bool operator!=(const class type_info &_Other) const noexcept;
(compiled) (NA):(NA) 0 public: _Bool before(const class type_info &_Other) const noexcept;
(compiled) (NA):(NA) 0 public: const char *name() const noexcept;
(compiled) (NA):(NA) 0 public: const char *raw_name() const noexcept;
(compiled) (NA):(NA) 0 public: virtual ~type_info() noexcept;
===========================================================================
struct __vcrt_va_list_is_reference<_Ty &>
SIZE: (NA) FILE: vadefs.h LINE: -1
List of member variables --------------------------------------------------
vadefs.h -1 0x0 public: enum __vcrt_va_list_is_reference<type-parameter-0-0 &>::(anonymous at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\vadefs.h:182:13) __the_value
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
struct __vcrt_va_list_is_reference<_Ty &&>
SIZE: (NA) FILE: vadefs.h LINE: -1
List of member variables --------------------------------------------------
vadefs.h -1 0x0 public: enum __vcrt_va_list_is_reference<type-parameter-0-0 &&>::(anonymous at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\vadefs.h:188:13) __the_value
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
struct _CrtEnableIf<true, _Ty>
SIZE: (NA) FILE: corecrt.h LINE: -1
List of member variables --------------------------------------------------
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
struct __crt_locale_data_public
SIZE: 16 FILE: corecrt.h LINE: -1
List of member variables --------------------------------------------------
corecrt.h -1 0x0 public: const unsigned short *_locale_pctype
corecrt.h -1 0x8 public: int _locale_mb_cur_max
corecrt.h -1 0xc public: unsigned int _locale_lc_codepage
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
struct __crt_locale_pointers
SIZE: 16 FILE: corecrt.h LINE: -1
List of member variables --------------------------------------------------
corecrt.h -1 0x0 public: struct __crt_locale_data *locinfo
corecrt.h -1 0x8 public: struct __crt_multibyte_data *mbcinfo
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
Forwarded struct __crt_locale_data
SIZE: n/a FILE: corecrt.h LINE: -1
===========================================================================
Forwarded struct __crt_multibyte_data
SIZE: n/a FILE: corecrt.h LINE: -1
===========================================================================
struct _Mbstatet
SIZE: 8 FILE: corecrt.h LINE: -1
List of member variables --------------------------------------------------
corecrt.h -1 0x0 public: unsigned long _Wchar
corecrt.h -1 0x4 public: unsigned short _Byte
corecrt.h -1 0x6 public: unsigned short _State
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
struct std::nothrow_t
SIZE: 1 FILE: vcruntime_new.h LINE: -1
List of member variables --------------------------------------------------
List of member functions :---------------------------------------------------
filename line:size busy function type and name
(compiled) (NA):(NA) 0 public: explicit nothrow_t();
===========================================================================
Forwarded struct _CrtMemBlockHeader
SIZE: n/a FILE: crtdbg.h LINE: -1
===========================================================================
struct _CrtMemState
SIZE: 104 FILE: crtdbg.h LINE: -1
List of member variables --------------------------------------------------
crtdbg.h -1 0x0 public: struct _CrtMemBlockHeader *pBlockHeader
crtdbg.h -1 0x8 public: size_t lCounts[5]
crtdbg.h -1 0x30 public: size_t lSizes[5]
crtdbg.h -1 0x58 public: size_t lHighWaterCount
crtdbg.h -1 0x60 public: size_t lTotalCount
List of member functions :---------------------------------------------------
filename line:size busy function type and name
===========================================================================
class std::_Lockit
SIZE: 4 FILE: yvals.h LINE: -1
List of member variables --------------------------------------------------
yvals.h -1 0x0 private: int _Locktype
List of member functions :---------------------------------------------------
filename line:size busy function type and name
Assertion failed: isa<FunctionType>(type) == true && "AppendConstructorSignature, ctorDecl->getType is not a FunctionType", file C:\build\ws\BUILDTYPE\Release\LABEL\windows64\V\6-26\root\interpreter\cling\lib\MetaProcessor\Display.cpp, line 233
It kind of looks like it is picking up the wrong class and then things become weird very fast. This happens for any value I pass as classname (e.g. .Class 42foo - bar
). Should I report this to the Root project (and if so, where)?
Just a note that I'm not ignoring this, I'm just swamped at the moment (paper deadline).
Hey, hopefully your paper went well! Could you take another look at this? This is the only thing keeping me from a doing a release and I'm pretty much stuck trying to debug this myself, so at least a pointer towards a way of fixing this would be awesome. ;)
Yes, won best paper award. :) Just back from the conference, but got the C there. :/ Recovering and only just coming back online. Have to revive my Windows machine, though, then may know more, as I don't see it crashing on Linux.
I just rebuilt the cppyy stack from source on my Windows machine to see whether I could get any more info out of this.
Setting build mode to Debug here didn't work for cppyy-cling, so I stuck with RelWithDebInfo. The stacktrace now looks a little bit different, with llvm::DenseMap<...>::init()
replacing setValueWithAlloc()
as repeated topmost frame. Unfortunately, debug info is still missing for those frames. Do you know how to get debuginfo on the missing frames?
Sorry for spamming in this issue, but I really tried hard to resolve this on my own while documenting my steps here. Unfortunately, this issue still prevents my library from being used on windows, which greatly reduces its usefullness to a broader audience, and it seems that I'm really unable to resolve this on my own. :(
My last attempt was to get just a tiny bit of more information out of the stack trace by trying to get actual debug builds of cppyy + its dependencies. The few changes I made to the cmake build are shown here. While the build process works, trying to load cppyy then fails with the following error, which I can't really make sense of. I don't know what else to try here to debug this and get windows support working, so I'm kind of giving up on this...
>>> import cppyy
Traceback (most recent call last):
File "C:\Users\Niko\AppData\Roaming\Python\Python310\site-packages\cppyy_backend\loader.py", line 57, in _load_helper
return ctypes.CDLL(os.path.join(pkgpath, 'lib', bkname), ctypes.RTLD_GLOBAL), errors
File "C:\Program Files\Python310\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Niko\AppData\Roaming\Python\Python310\site-packages\cppyy\__init__.py", line 80, in <module>
from ._cpython_cppyy import *
File "C:\Users\Niko\AppData\Roaming\Python\Python310\site-packages\cppyy\_cpython_cppyy.py", line 21, in <module>
c = loader.load_cpp_backend()
File "C:\Users\Niko\AppData\Roaming\Python\Python310\site-packages\cppyy_backend\loader.py", line 92, in load_cpp_backend
raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
RuntimeError: could not load cppyy_backend library, details:
Could not find module 'libcppyy_backend.cp310-win_amd64.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
[WinError 1114] A dynamic link library (DLL) initialization routine failed
Could not find module 'C:\Users\Niko\AppData\Roaming\Python\Python310\site-packages\cppyy_backend\lib\libcppyy_backend.cp310-win_amd64.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
Could not find module 'libcppyy_backend.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Cling based on Clang9 can no longer parse the STL headers that ship with the latest MSVC (there was a macro that could be defined as a workaround, but this has been removed). Upstream has just finished Cling based on Clang13, so I hope to move soon. That will be necessary to run on Windows with the latest MSVC and also hopefully fix this issue.
I'm getting a somewhat weird crash from within CLing on Windows 10, both locally and also in the GitHub Actions CI (see the "Testing wheel" step of the build). My library loads fine and I can also use some variables defined statically (the json info dump right before the crash in the CI was generated from macros and static variables in the library), but as soon as I try to do a little more (like listing members of the namespace by pressing Tab in a python shell), Cling seems to crash. The actual exception seems to be the following, although WinDbg already stops a little earlier in the same function, see the full dump below. I'm not really an expert in Windows topics, could you give me some pointers how to debug, fix and/or circumvent this?
The packages I use should be the most recent: CPyCppyy | 1.12.11 cppyy | 2.4.0 cppyy-backend | 1.14.9 cppyy-cling | 6.27.0