Bug 38794 - Segmentation fault Console.ReadLine while exiting the application
Summary: Segmentation fault Console.ReadLine while exiting the application
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Aleksey Kliger
Depends on:
Reported: 2016-02-16 13:25 UTC by Wouter Post
Modified: 2017-10-06 20:32 UTC (History)
5 users (show)

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

The C# code to reproduce the error (1.21 KB, text/plain)
2016-02-16 13:25 UTC, Wouter Post
Bash loop script (214 bytes, text/plain)
2016-02-16 13:28 UTC, Wouter Post
gdb log from core dump (3.90 KB, text/plain)
2016-02-22 14:42 UTC, Alexander Köplinger [MSFT]

Description Wouter Post 2016-02-16 13:25:49 UTC
Created attachment 15054 [details]
The C# code to reproduce the error


I've come across this bug in mono 2.11.4, 3.2.1 and 3.12.1.
Whenever Console.ReadLine() is executed in a background thread while the application is exiting, segmentation faults can occur.

I've made a bash loop script to try it out multiple times since the segfault doesn't seem to occur every time.
Sometimes it takes 500 attempts and sometimes only 5.

The code can be compiled with mcs or in visual studio with .net, both generate the error.
Comment 1 Wouter Post 2016-02-16 13:28:23 UTC
Created attachment 15055 [details]
Bash loop script

Added bash loop script for testing.
Comment 2 Aleksey Kliger 2016-02-19 17:19:03 UTC
No longer reproducible with 4.2 or HEAD on Debian x64 or OSX after ~1500 iterations.
Comment 3 Alexander Köplinger [MSFT] 2016-02-22 14:41:42 UTC
I can reproduce the segfault on Mono 3.12, Mono 4.0 and Mono 4.2 using the Mono Docker images and with 4.2 on the Ubuntu 14.04 x64 host VM (though it took about ~2500 iterations there).

I was also able to repro it using master/f558ee9 too so the bug is definitely still there.

I've attached a stack trace from the core dump of the master build and assigning to Aleksey since you already took a look earlier, please feel to reassign to someone more appropriate :)
Comment 4 Alexander Köplinger [MSFT] 2016-02-22 14:42:28 UTC
Created attachment 15123 [details]
gdb log from core dump
Comment 5 Ludovic Henry 2017-09-06 15:47:11 UTC
We have changed how threads are stopped so this might be fixed with latest version of Mono. Can you still reproduce with Mono (2017-06/6425f06) or later? Thank you
Comment 6 Ludovic Henry 2017-10-06 20:32:32 UTC
Please reopen if you can still reproduce. Thank you

Note You need to log in before you can comment on or make changes to this bug.