Closed ankane closed 2 years ago
I'm not sure what emplace_back
here is providing over the push_back
that addArg
calls, but this should be safe. @cfis do you remember why you chose emplace_back
here?
I don't remember why I used emplace_back instead of push_back.
So feel free to change. However, I don't see how that is going to fix the bug mentioned above the way since the way the code is written either choice (push_back/emplace_back) should be the same. See https://quuxplusone.github.io/blog/2021/03/03/push-back-emplace-back/
Yeah, I didn't think they should be different either, but seems to make a difference in this specific case (but maybe there's something else going on).
Thanks @jasonroelofs!
Hi, I recently ran into a
std::bad_alloc
error when loading two gems that use Rice in the same script when one is precompiled (using rake-compiler-dock). The issue occurs on Linux but not Mac (haven't tried Windows).Debugging with gdb led to this backtrace, which seems to point to the
emplace_back
call inMethodInfo
.There's no error when all functions defined in C++ have either no args or all the args are specified with
Rice::Arg
, which also points to that code path.Changing
MethodInfo
to calladdArg
(which callspush_back
) fixes the issue. However, I don't fully understand why, so wanted to see if it makes sense to you.