Closed guitargeek closed 6 months ago
The same patch is also now part of my syncing PR in ROOT: https://github.com/root-project/root/pull/14507 If the current CI run over there fixes these excessive failures in the DataFrame tutorials, it means it worked.
edit: indeed, the RDataFrame tutorials pass now
Also: what is the most appropriate place for a unit test? I guess somewhere here? https://github.com/wlav/cppyy/tree/master/test
This one actually breaks two existing string_view
tests, so in the future, it would be useful to run the standard cppyy tests and not just the ROOT ones, which have clearly far less coverage.
The problem is that in SetArg
, the assumption is made that the pointed to voidp
is an std::string*
, but by changing the buffer type in the declaration to std::string
while leaving the scope id to std::string_view
in the implementation, it can be either std::string*
or std::string_view*
and no way out to tell which is which. When wrong, then crash.
Thank you very much for following up! Sorry, I didn't think of this case. It's more common to use std::string_view
as argument types and not pass them around directly, that's why I didn't catch this
There are two possible fixes to the problem with string lifetimes and
std::string_view
arguments:setting a lifeline
copying the string
Copying the string is supposedly faster on average, at least in the ROOT usecase the strings that are passed around are not very long (RDataFrame filter and variable definitions).
Also, the
InitializerListConverter
is changed such that it creates separate converters for each element if the converters have state.This PR fixes the following reproducer:
Closes #13.