Bug 16714 - Std::runtime_error implementation resolution causes crash on OSX 10.8: "pointer being freed was not allocated"
Summary: Std::runtime_error implementation resolution causes crash on OSX 10.8: "point...
Status: RESOLVED INVALID
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-12-10 16:03 UTC by public.marvin
Modified: 2013-12-10 16:42 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Four source files, a Makefile, and the output showing the error (13.89 KB, text/plain)
2013-12-10 16:03 UTC, public.marvin
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED INVALID

Description public.marvin 2013-12-10 16:03:29 UTC
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.
Comment 1 Rodrigo Kumpera 2013-12-10 16:42:49 UTC
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.