Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 5632 [details]
Four source files, a Makefile, and the output showing the error
It seems that the mono runtime is loading both libc++ and libstdc++ when unmanaged code is compiled using libstdc++. It seems that with unmanaged code compiled and linked using libstdc++, at runtime the code is using one implementation of std::runtime_error for new() (from libstdc++) but the other implementation for delete() (from libc++). Because the implementations are not compatible, an error occurs.
mono(93092,0x10ee01000) malloc: *** error for object 0x7fff7607a574: pointer being freed was not allocated
An example demonstrating the bug along with the detailed output is attached. The object in question seems to be held by the std::runtime_error being created in the test. This code was originally generated using swig, generating a C# wrapper around some simple code. I have stripped out all but the code needed to demonstrate the bug, but the somewhat unusual code is a result of the generic way swig handles C++ object wrapping.
Note: on OSX 10.8, and Xcode 4.6.3, both gcc and clang are provided with the Xcode command line tools. This is the environment I am using. g++ uses libstdc++, and clang allows either implementation to be used.
This error does not seem to occur on a machine with Xcode 5 and OSX 10.9.
This is a linker/system problem on OSX, not a mono bug.
The mono runtime at no point explicitly tries to load libstdc++. It has no part in this problem.