Bug 8877 - Mono crashes when using the debug variants of the macos system libraries
Summary: Mono crashes when using the debug variants of the macos system libraries
Status: RESOLVED ANSWERED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-12-10 19:02 UTC by Alan McGovern
Modified: 2017-07-14 23:34 UTC (History)
4 users (show)

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


Attachments
stacktrace (4.31 KB, text/plain)
2012-12-10 19:02 UTC, Alan McGovern
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 ANSWERED

Description Alan McGovern 2012-12-10 19:02:08 UTC
Created attachment 3079 [details]
stacktrace

1) export DYLD_IMAGE_SUFFIX=_debug
2) Run a mono application (like MonoDevelop)
3) See stacktrace file attached
Comment 1 Zoltan Varga 2013-01-03 05:13:26 UTC
This seems to happen if the app loads the non-debug version of libc.dylib:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <pthread.h>
#include <dlfcn.h>

void main ()
{
	pthread_key_t t;

	pthread_key_create (&t, NULL);

	pthread_setspecific (t, 1);

	dlopen ("libc.dylib", RTLD_GLOBAL|RTLD_LAZY);

	printf ("%p\n", pthread_getspecific (t));
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This program should print '0x1', but when run with DYLD_IMAGE_SUFFIX=_debug, it prints '0x0'. The debug 

A workaround is making a copy of just the libraries you need with a unique suffix, and setting DYLD_IMAGE_SUFFIX to this suffix.
Comment 2 Alan McGovern 2013-01-03 05:47:58 UTC
Exporting "_debug" is the macos recommended way of loading the debug libraries. This does seem like something which isn't our fault based on your diagnosis there, but how is this supposed to work? Am i simply missing the debug variants of some libraries?
Comment 3 Zoltan Varga 2013-01-03 06:50:46 UTC
It seems the problem is that the debug version of libc is already loaded, and when the non-debug version is loaded, it nulls out the values of thread-local variables, leading to the crash. So I don't think this is a mono bug.
Comment 4 Rodrigo Kumpera 2017-07-14 23:34:49 UTC
This is an OSX limitation and not runtime related.