Bug 59024 - Mono SIGSEGV when profiling AOT compiled Microsoft.CodeAnalysis.CSharp
Summary: Mono SIGSEGV when profiling AOT compiled Microsoft.CodeAnalysis.CSharp
Status: RESOLVED INVALID
Alias: None
Product: Runtime
Classification: Mono
Component: Profiler ()
Version: 5.4 (2017-06)
Hardware: All All
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2017-08-24 17:41 UTC by Andy Gocke
Modified: 2018-01-05 13:27 UTC (History)
3 users (show)

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


Attachments
Output from Mono SIGSEGV (30.59 KB, text/plain)
2017-08-24 17:41 UTC, Andy Gocke
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 Andy Gocke 2017-08-24 17:41:09 UTC
Created attachment 24406 [details]
Output from Mono SIGSEGV

Here's the version info from Mono:

```
Mono JIT compiler version 5.4.0.135 (2017-06/6425f06 Fri Jul 28 13:28:44 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          yes(3.6.0svn-mono-master/8b1520c)
	GC:            sgen (concurrent by default)
```

Repro steps:

1. Download the Microsoft.NET.Compilers package, version 2.3.1 from NuGet. (https://www.nuget.org/packages/Microsoft.Net.Compilers/2.3.1)
2. AOT compile Microsoft.CodeAnalysis.CSharp.dll (mono --aot ~/.nuget/packages/microsoft.net.compilers/2.3.1/tools/Microsoft.CodeAnalysis.CSharp.dll)

3. Attempt to gather a profile of csc compiling any C# file (even HelloWorld).

Mono SIGSEGVs with the output attached.
Comment 1 Marek Safar 2017-08-24 22:16:49 UTC
This is quite odd as we run same setup for Mono itself
Comment 2 Alex Rønne Petersen 2017-08-25 18:59:36 UTC
I don't think we run the log profiler for any parts of the build.
Comment 3 Ludovic Henry 2017-09-06 15:21:11 UTC
Which command are you running to gather the profile?

I have tried the following commands without reproducing the crash:

> wget -O microsoft.net.compilers.2.3.1.nupkg https://www.nuget.org/api/v2/package/Microsoft.Net.Compilers/2.3.1
> unzip microsoft.net.compilers.2.3.1.nupkg
> mono --aot tools/Microsoft.CodeAnalysis.CSharp.dll
> mono --profile=log tools/csc.exe helloworld.cs

The mono version is:

> Mono JIT compiler version 5.4.0.135 (2017-06/6425f06 Fri Jul 28 13:28:44 EDT 2017)
> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-> project.com
> 	TLS:           normal
> 	SIGSEGV:       altstack
> 	Notification:  kqueue
> 	Architecture:  amd64
> 	Disabled:      none
> 	Misc:          softdebug
> 	LLVM:          yes(3.6.0svn-mono-master/8b1520c)
> 	GC:            sgen (concurrent by default)
Comment 4 Alex Rønne Petersen 2017-09-06 18:19:32 UTC
I don't think it reproduces with 5.4. I was able to reproduce it with master on Linux. Will be taking a look.
Comment 5 Alex Rønne Petersen 2017-10-16 16:57:55 UTC
The problem is that we end up trying to access fields on the current domain, but since the profiler's writer thread is a tools thread, mono_domain_get () returns NULL.
Comment 6 Alex Rønne Petersen 2017-12-03 09:19:18 UTC
We could try fixing this by setting a domain for tools threads.
Comment 7 Alex Rønne Petersen 2017-12-06 16:23:52 UTC
Moving this to GitHub issues: https://github.com/mono/mono/issues/6188