-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Particular combination of function overload and std::runtime_error leads to segfault #17497
Comments
An interesting thing to note. In
I put some printouts in the
And here the printouts
|
Not sketchy: that's simply the 2nd argument conversion to the trial of the first overload. It doesn't fail until it hits the predicate in the next line, so after the printouts, then returns false. The program then moves on to the next overload. Anyway, looks to me like you have a stack overflow: Not sure where things run afoul. My first suspicion is/was on However, I cleaned up the |
The check `klass == ctxt->fCurScope` in ConvertImplicit was always returning false due to a bad construction of the `ctxt` variable of type `CPyCppyy::CallContext`. In particular, the `fCurScope` of the context is taken as the `fScope` data member of the instance converter. This value is usually created at construction time, for example in the `STLStringViewConverter` constructor, by calling `Cppyy::GetScope`. The `GetScope` implementation of ROOT's clingwrapper was outdated w.r.t. the cppyy-backend implementation. This commit aligns the two implementations, thus fixing issues such as the one reported at root-project#17497.
Thanks for the insights @wlav! Based on some debugging I could do along with @vepadulano 's help, the infinite loop is the fact is not only the
As mentioned, if (IsConstructor(ctxt->fFlags) && klass == ctxt->fCurScope && ctxt->GetSize() == 1) Should evaluate to true. The point at which they differ is the klass not matching the The actual creation of every member of the std::class happens like so upstream:
And on ROOT the same way with scope 8 instead. We should get the same value by doing On ROOT, even though we still take the CPyCppyy::STLStringViewConverter::STLStringViewConverter(bool keepControl) :
InstanceConverter(Cppyy::GetScope("std::string_view"), keepControl) {} And here lies our problem.
CPyCppyy::STLStringViewConverter::STLStringViewConverter(bool keepControl) :
InstanceConverter(Cppyy::GetScope("basic_string_view<char,char_traits<char> >"), keepControl) {} The code path followed is the same as upstream. I believe #17536 fixes the lookup on meta to provide the same scope for both, and should be a viable fix, and also reduce the divergence in clingwrapper between ROOT and upstream cppyy |
Dear @wlav , Thank you for taking the time to analyse this issue! Your insights proved useful, indeed the fact that |
Disabled on MacOS ARM and Windows because LLVM JIT fails to catch exceptions.
Disabled on MacOS ARM and Windows because LLVM JIT fails to catch exceptions.
Disabled on MacOS ARM and Windows because LLVM JIT fails to catch exceptions.
The check `klass == ctxt->fCurScope` in ConvertImplicit was always returning false due to a bad construction of the `ctxt` variable of type `CPyCppyy::CallContext`. In particular, the `fCurScope` of the context is taken as the `fScope` data member of the instance converter. This value is usually created at construction time, for example in the `STLStringViewConverter` constructor, by calling `Cppyy::GetScope`. The `GetScope` implementation of ROOT's clingwrapper was outdated w.r.t. the cppyy-backend implementation. This commit aligns the two implementations, thus fixing issues such as the one reported at #17497.
Disabled on MacOS ARM and Windows because LLVM JIT fails to catch exceptions.
Check duplicate issues.
Description
I can see a segfault in a seemingly innocent situation with an overload set that includes
std::string_view
andstd::vector<std::string>
in which at least one of the overloads throws a runtime error. The gdb stacktrace appears to be recursive, see attachmentgdb_stacktrace.txt
Note that this happens only if I pass an empty Python list
[]
that is then converted implicitly to thestd::vector
. If I pass manually an emptycppyy.gbl.std.vector[cppyy.gbl.std.string]
, it works. See the reproducer.This issue is the direct cause of part 1 of #17485
Reproducer
ROOT version
master
Installation method
Any
Operating system
Linux Fedora 41
Additional context
No response
The text was updated successfully, but these errors were encountered: