Bug 58600 - Mono C# compiler hangs
Summary: Mono C# compiler hangs
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC All
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2017-08-05 09:56 UTC by soywiz
Modified: 2017-08-08 21:24 UTC (History)
1 user (show)

See Also:
Tags: hang
Is this bug a regression?: Yes
Last known good build:

~6MB Single file program.cs compressed in a zip file (626.79 KB, application/x-zip-compressed)
2017-08-05 09:56 UTC, soywiz

Description soywiz 2017-08-05 09:56:46 UTC
Created attachment 24042 [details]
~6MB Single file program.cs compressed in a zip file

Mono C# compiler hangs on a generated program.cs ~6MB while microsoft C# compiler compiles it in 1 second or so.
It happens on older versions of the compiler too, but worked on even older versions (the one that comes from ubuntu 12.04 seems to work fine).

I have attached the program.cs file.

How to reproduce on windows:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc" /unsafe+ program.cs # compiles in 1 second
"c:\Program Files\Mono\lib\mono\4.5\mcs" /unsafe+ program.cs # hangs forever. Probably an infinite loop somewhere.

In linux happens too (reproduced on travis on ubuntu 14.04):
https://travis-ci.org/jtransc/jtransc/builds/261263534#L9099 # Ubuntu 14.04 - hangs
https://travis-ci.org/jtransc/jtransc/builds/257048300#L5361 # Ubuntu 12.04 - works


Context (probably not necessary):

The file is generated from this Java/Kotlin code:

Into C# sourcecode. Works like IKVM but generates sourcecode and strips unused dependencies (tree shaking) generating a single cs that later is converted into a single exe. So the 6MB program.cs contains everywhing necessary to compile that program. Since it uses pointers to improve performance in specific places it requires /unsafe+ flag.

And I'm trying to upadte travis to trusty: https://github.com/jtransc/jtransc/pull/226 but hangs

I have tried to figure out why it hangs (probably an specific syntax or something), but probably you will find it faster if you can debug the compiler and pause on the infinite loop.
Comment 1 Marek Safar 2017-08-08 15:46:26 UTC
This looks like flowanalysis issue caused by few recursive goto(s)
Comment 2 soywiz 2017-08-08 21:24:45 UTC
Great that it is confirmed

Since I'm generating code from bytecode, those gotos probably are generating irreductible CFGs in some cases

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