Std::bad_alloc After Replacing Boost:python Function Wrapper With Python/c Api
I had a function in C which I used to extend python, previously using the BOOST_MODULE function to accomplish this. This error came up when transitioning to the python-C API. I am
Solution 1:
As has been explained in several of the comments now, you have a memory corruption issue. Key indicators are:
- The problem reproduces erratically.
- Exact symptoms change from unexpectedly bad values being passed into some functions, through to bizarrely large memory allocation failures.
- These symptoms don't reproduce for others when run_module has a trivial implementation.
Given that valgrind isn't pinpointing it for you, it's probably a stack corruption. You could look for places where your code is calling the failed function (from valgrind) and look at what your code did before that, but this will be slow.
Your best bet at this stage is now to use the stack validation tools out there. For example, assuming you're using gcc, try the address sanitizer or mudflap features (depending on which version you're using).
Post a Comment for "Std::bad_alloc After Replacing Boost:python Function Wrapper With Python/c Api"