Skip to content

Tail calls not respected on MacOs #12589

Closed

Description

@enricosada

There is a behaviour difference for tail calls between Unix/Win and MacOs, on MacOs are not respected (or the max stack deep is higher on win/unix?)

Sorry, maybe is duplicated or not implemented, but i didnt find an issue/note about that.
Also i dont know how to diagnose it better, so any feedback/link is really appreciated, and i'll try to minimize the repro further.

A repro is in https://github.com/enricosada/fcs-crash/ , see the README for how to run it, but it's just

# first restore the repro project
dotnet restore repro

# build
dotnet build

#  run, to typecheck with FCS that repro project
dotnet run -f netcoreapp2.1

# on osx will crash with Stackoverflow

That will stackoverflow with a stack trace similar to the following (it's not exactly the same, this one is from mono, because on .NET Core doesnt show the stacktrace, just the failure)

Stack overflow in unmanaged: IP: 0x10744b82b, fault addr: 0x7000076f5fb8
Stack overflow: IP: 0x10744b82b, fault addr: 0x7000076ecff8
Stacktrace:
  at <unknown> <0xffffffff>
  at string.CtorCharArrayStartLength (char[],int,int) [0x00061] in <53dca12e92aa4e3387f3b954838dd249>:0
  <...>
  at string.CreateString (char[],int,int) [0x00000] in <53dca12e92aa4e3387f3b954838dd249>:0
  at (wrapper managed-to-managed) string..ctor (char[],int,int) [0x00000] in <53dca12e92aa4e3387f3b954838dd249>:0
  at Internal.Utilities.Text.Lexing.LexBuffer`1<char>.LexemeString (Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer._fslex_tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,int,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00193] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0

...... tons more of at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString

  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexer.tripleQuoteString (Microsoft.FSharp.Compiler.AbstractIL.Internal.ByteBuffer,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Range/range, Microsoft.FSharp.Core.FSharpFunc`2<bool, Microsoft.FSharp.Core.FSharpFunc`2<byte[], Microsoft.FSharp.Compiler.Parser/token>>>,Microsoft.FSharp.Compiler.Range/range,Microsoft.FSharp.Compiler.Lexhelp/lexargs,bool,Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.runWrappedLexerInConsistentLexbufState () [0x00031] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.popNextTokenTup () [0x0001a] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.peekNextTokenTup () [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.pushCtxtSeqBlock (bool,Microsoft.FSharp.Compiler.LexFilter/AddBlockEnd) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.hwTokenFetch (bool) [0x0466a] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilterImpl.Lexer<a_REF> (a_REF) [0x00021] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilter.popNextToken () [0x0001a] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter.loop@2264-37 (Microsoft.FSharp.Compiler.LexFilter/LexFilter,Microsoft.FSharp.Core.Unit) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.LexFilter/LexFilter.Lexer<a_REF> (a_REF) [0x00002] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.SourceCodeServices.Parser/createLexerFunction@1534<a_REF>.Invoke (a_REF) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Internal.Utilities.Text.Parsing.Implementation.interpret<tok_REF> (Internal.Utilities.Text.Parsing.Tables`1<tok_REF>,Microsoft.FSharp.Core.FSharpFunc`2<Internal.Utilities.Text.Lexing.LexBuffer`1<char>, tok_REF>,Internal.Utilities.Text.Lexing.LexBuffer`1<char>,int) [0x0013c] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Internal.Utilities.Text.Parsing.Tables`1<tok_REF>.Interpret (Microsoft.FSharp.Core.FSharpFunc`2<Internal.Utilities.Text.Lexing.LexBuffer`1<char>, tok_REF>,Internal.Utilities.Text.Lexing.LexBuffer`1<char>,int) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.CompileOps.ParseInput (Microsoft.FSharp.Core.FSharpFunc`2<Internal.Utilities.Text.Lexing.LexBuffer`1<char>, Microsoft.FSharp.Compiler.Parser/token>,Microsoft.FSharp.Compiler.ErrorLogger/ErrorLogger,Internal.Utilities.Text.Lexing.LexBuffer`1<char>,Microsoft.FSharp.Core.FSharpOption`1<string>,string,System.Tuple`2<bool, bool>) [0x00070] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.SourceCodeServices.Parser/parseResult@1590.Invoke (Internal.Utilities.Text.Lexing.LexBuffer`1<char>) [0x0006b] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexhelp/usingLexbufForParsing@92<a_REF>.Invoke (Microsoft.FSharp.Core.Unit) [0x00000] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexhelp.reusingLexbufForParsing<a_REF> (Internal.Utilities.Text.Lexing.LexBuffer`1<char>,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, a_REF>) [0x00026] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.Lexhelp.usingLexbufForParsing<a_REF> (Internal.Utilities.Text.Lexing.LexBuffer`1<char>,string,Microsoft.FSharp.Core.FSharpFunc`2<Internal.Utilities.Text.Lexing.LexBuffer`1<char>, a_REF>) [0x0001a] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Compiler.SourceCodeServices.Parser.parseFile (string,string,Microsoft.FSharp.Compiler.SourceCodeServices.FSharpParsingOptions,string) [0x00066] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at <StartupCode$FSharp-Compiler-Service>.$Service/ParseFile@2505.Invoke (Microsoft.FSharp.Core.Unit) [0x0006a] in <5b5b17b04d124a0ca7450383b0175b5b>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl/callA@522<b_REF, a_REF>.Invoke (Microsoft.FSharp.Control.AsyncParams`1<b_REF>) [0x00051] in <5a7d678a904cf4daa74503838a677d5a>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl/queueAsync@434<a_REF>.Invoke (Microsoft.FSharp.Core.Unit) [0x00033] in <5a7d678a904cf4daa74503838a677d5a>:0
  at <StartupCode$FSharp-Core>.$Control.loop@124-50 (Microsoft.FSharp.Control.Trampoline,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue>) [0x00000] in <5a7d678a904cf4daa74503838a677d5a>:0
  at Microsoft.FSharp.Control.Trampoline.ExecuteAction (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue>) [0x00017] in <5a7d678a904cf4daa74503838a677d5a>:0
  at Microsoft.FSharp.Control.TrampolineHolder.Protect (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue>) [0x00031] in <5a7d678a904cf4daa74503838a677d5a>:0
  at <StartupCode$FSharp-Core>.$Control/-ctor@200-1.Invoke (object) [0x00017] in <5a7d678a904cf4daa74503838a677d5a>:0
  at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (object) [0x00007] in <53dca12e92aa4e3387f3b954838dd249>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in <53dca12e92aa4e3387f3b954838dd249>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in <53dca12e92aa4e3387f3b954838dd249>:0
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <53dca12e92aa4e3387f3b954838dd249>:0
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <53dca12e92aa4e3387f3b954838dd249>:0
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <53dca12e92aa4e3387f3b954838dd249>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_bool (object,intptr,intptr,intptr) [0x0001e] in <53dca12e92aa4e3387f3b954838dd249>:0

The crash is shown on this travis build matrix ( https://travis-ci.org/enricosada/fcs-crash/builds/524417824 ) where with .NET Core succeeded on unix and fails on osx (on win is ok too in local tests)

The method tripleQuoteString call _fslex_tripleQuoteString who call tripleQuoteString etc

  .method assembly static class FSharp.Compiler.Parser/token 
    tripleQuoteString(
      class FSharp.Compiler.AbstractIL.Internal.ByteBuffer sargs_0, 
      class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>> sargs_1, 
      valuetype FSharp.Compiler.Range/range sargs_2, 
      class FSharp.Compiler.Lexhelp/lexargs sargs_3, 
      bool skip, 
      class Internal.Utilities.Text.Lexing.LexBuffer`1<char> lexbuf
    ) cil managed 
  {
    .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) 
      = (
        01 00 03 00 00 00 04 00 00 00 01 00 00 00 01 00 // ................
        00 00 00 00                                     // ....
      )
      // int32[3]
        /*( int32(4) // 0x00000004
         int32(1) // 0x00000001
         int32(1) // 0x00000001
         )*/
    .maxstack 9

    // [1846 7 - 1846 100]
    IL_0000: ldarg.0      // sargs_0
    IL_0001: ldarg.1      // sargs_1
    IL_0002: ldarg.2      // sargs_2
    IL_0003: ldarg.3      // sargs_3
    IL_0004: ldarg.s      skip
    IL_0006: ldc.i4       178 // 0x000000b2
    IL_000b: ldarg.s      lexbuf
    IL_000d: tail.        
    IL_000f: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::_fslex_tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, int32, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_0014: ret          

  } // end of method Lexer::tripleQuoteString
  .method assembly static class FSharp.Compiler.Parser/token 
    _fslex_tripleQuoteString(
      class FSharp.Compiler.AbstractIL.Internal.ByteBuffer sargs_0, 
      class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>> sargs_1, 
      valuetype FSharp.Compiler.Range/range sargs_2, 
      class FSharp.Compiler.Lexhelp/lexargs sargs_3, 
      bool skip, 
      int32 _fslex_state, 
      class Internal.Utilities.Text.Lexing.LexBuffer`1<char> lexbuf
    ) cil managed 
  {
    .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) 
      = (
        01 00 04 00 00 00 04 00 00 00 01 00 00 00 01 00 // ................
        00 00 01 00 00 00 00 00                         // ........
      )
      // int32[4]
        /*( int32(4) // 0x00000004
         int32(1) // 0x00000001
         int32(1) // 0x00000001
         int32(1) // 0x00000001
         )*/
    .maxstack 8
    .locals init (
      [0] valuetype Internal.Utilities.Text.Lexing.Position V_0,
      [1] string 's1[111-119], s2[180-188], s3[249-257], s4[318-326], s5[410-418]'
    )

    // [3673 7 - 3673 67]
    IL_0000: call         class Internal.Utilities.Text.Lexing.UnicodeTables FSharp.Compiler.Lexer::get__fslex_tables()
    IL_0005: ldarg.s      _fslex_state
    IL_0007: ldarg.s      lexbuf
    IL_0009: callvirt     instance int32 Internal.Utilities.Text.Lexing.UnicodeTables::Interpret(int32, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_000e: switch       (IL_003a, IL_0051, IL_00ad, IL_00f2, IL_0137, IL_017c, IL_0193)

    // [3711 11 - 3711 59]
    IL_002f: ldstr        "tripleQuoteString"
    IL_0034: newobj       instance void [System.Runtime]System.Exception::.ctor(string)
    IL_0039: throw        

    // [3676 11 - 3676 166]
    IL_003a: ldarg.1      // sargs_1
    IL_003b: ldarg.s      lexbuf
    IL_003d: call         valuetype FSharp.Compiler.Range/range FSharp.Compiler.Ast::LexBuffer`1.get_LexemeRange<char>(class Internal.Utilities.Text.Lexing.LexBuffer`1<!!0/*char*/>)
    IL_0042: ldc.i4.0     
    IL_0043: ldarg.0      // sargs_0
    IL_0044: callvirt     instance unsigned int8[] FSharp.Compiler.AbstractIL.Internal.ByteBuffer::Close()
    IL_0049: tail.        
    IL_004b: call         !!1/*class FSharp.Compiler.Parser/token*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, bool>::InvokeFast<unsigned int8[], class FSharp.Compiler.Parser/token>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0/*valuetype FSharp.Compiler.Range/range*/, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1/*bool*/, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!!0/*unsigned int8[]*/, !!1/*class FSharp.Compiler.Parser/token*/>>>, !0/*valuetype FSharp.Compiler.Range/range*/, !1/*bool*/, !!0/*unsigned int8[]*/)
    IL_0050: ret          

    // [3678 11 - 3678 49]
    IL_0051: ldarg.s      lexbuf
    IL_0053: ldarg.s      lexbuf
    IL_0055: callvirt     instance valuetype Internal.Utilities.Text.Lexing.Position class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::get_EndPos()
    IL_005a: stloc.0      // V_0
    IL_005b: ldloca.s     V_0
    IL_005d: call         instance valuetype Internal.Utilities.Text.Lexing.Position Internal.Utilities.Text.Lexing.Position::get_NextLine()
    IL_0062: callvirt     instance void class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::set_EndPos(valuetype Internal.Utilities.Text.Lexing.Position)
    IL_0067: nop          

    // [3679 11 - 3679 59]
    IL_0068: ldarg.s      lexbuf
    IL_006a: call         string class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::LexemeString(class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_006f: stloc.1      // s1

    // [3680 11 - 3680 59]
    IL_0070: ldarg.0      // sargs_0
    IL_0071: call         class [netstandard]System.Text.Encoding [netstandard]System.Text.Encoding::get_Unicode()
    IL_0076: ldloc.1      // s1
    IL_0077: callvirt     instance unsigned int8[] [netstandard]System.Text.Encoding::GetBytes(string)
    IL_007c: callvirt     instance void FSharp.Compiler.AbstractIL.Internal.ByteBuffer::EmitBytes(unsigned int8[])
    IL_0081: nop          

    // [3681 11 - 3681 21]
    IL_0082: ldarg.s      skip
    IL_0084: brtrue.s     IL_009d

    // [3682 13 - 3682 146]
    IL_0086: ldarg.3      // sargs_3
    IL_0087: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_008c: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_0091: ldarg.2      // sargs_2
    IL_0092: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_0097: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewSTRING_TEXT(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_009c: ret          

    // [3683 11 - 3683 92]
    IL_009d: ldarg.0      // sargs_0
    IL_009e: ldarg.1      // sargs_1
    IL_009f: ldarg.2      // sargs_2
    IL_00a0: ldarg.3      // sargs_3
    IL_00a1: ldarg.s      skip
    IL_00a3: ldarg.s      lexbuf
    IL_00a5: tail.        
    IL_00a7: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_00ac: ret          

    // [3685 11 - 3685 59]
    IL_00ad: ldarg.s      lexbuf
    IL_00af: call         string class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::LexemeString(class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_00b4: stloc.1      // s2

    // [3686 11 - 3686 59]
    IL_00b5: ldarg.0      // sargs_0
    IL_00b6: call         class [netstandard]System.Text.Encoding [netstandard]System.Text.Encoding::get_Unicode()
    IL_00bb: ldloc.1      // s2
    IL_00bc: callvirt     instance unsigned int8[] [netstandard]System.Text.Encoding::GetBytes(string)
    IL_00c1: callvirt     instance void FSharp.Compiler.AbstractIL.Internal.ByteBuffer::EmitBytes(unsigned int8[])
    IL_00c6: nop          

    // [3687 11 - 3687 21]
    IL_00c7: ldarg.s      skip
    IL_00c9: brtrue.s     IL_00e2

    // [3688 13 - 3688 146]
    IL_00cb: ldarg.3      // sargs_3
    IL_00cc: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_00d1: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_00d6: ldarg.2      // sargs_2
    IL_00d7: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_00dc: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewSTRING_TEXT(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_00e1: ret          

    // [3689 11 - 3689 92]
    IL_00e2: ldarg.0      // sargs_0
    IL_00e3: ldarg.1      // sargs_1
    IL_00e4: ldarg.2      // sargs_2
    IL_00e5: ldarg.3      // sargs_3
    IL_00e6: ldarg.s      skip
    IL_00e8: ldarg.s      lexbuf
    IL_00ea: tail.        
    IL_00ec: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_00f1: ret          

    // [3691 11 - 3691 59]
    IL_00f2: ldarg.s      lexbuf
    IL_00f4: call         string class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::LexemeString(class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_00f9: stloc.1      // s3

    // [3692 11 - 3692 59]
    IL_00fa: ldarg.0      // sargs_0
    IL_00fb: call         class [netstandard]System.Text.Encoding [netstandard]System.Text.Encoding::get_Unicode()
    IL_0100: ldloc.1      // s3
    IL_0101: callvirt     instance unsigned int8[] [netstandard]System.Text.Encoding::GetBytes(string)
    IL_0106: callvirt     instance void FSharp.Compiler.AbstractIL.Internal.ByteBuffer::EmitBytes(unsigned int8[])
    IL_010b: nop          

    // [3693 11 - 3693 21]
    IL_010c: ldarg.s      skip
    IL_010e: brtrue.s     IL_0127

    // [3694 13 - 3694 146]
    IL_0110: ldarg.3      // sargs_3
    IL_0111: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_0116: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_011b: ldarg.2      // sargs_2
    IL_011c: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_0121: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewSTRING_TEXT(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_0126: ret          

    // [3695 11 - 3695 92]
    IL_0127: ldarg.0      // sargs_0
    IL_0128: ldarg.1      // sargs_1
    IL_0129: ldarg.2      // sargs_2
    IL_012a: ldarg.3      // sargs_3
    IL_012b: ldarg.s      skip
    IL_012d: ldarg.s      lexbuf
    IL_012f: tail.        
    IL_0131: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_0136: ret          

    // [3697 11 - 3697 59]
    IL_0137: ldarg.s      lexbuf
    IL_0139: call         string class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::LexemeString(class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_013e: stloc.1      // s4

    // [3698 11 - 3698 59]
    IL_013f: ldarg.0      // sargs_0
    IL_0140: call         class [netstandard]System.Text.Encoding [netstandard]System.Text.Encoding::get_Unicode()
    IL_0145: ldloc.1      // s4
    IL_0146: callvirt     instance unsigned int8[] [netstandard]System.Text.Encoding::GetBytes(string)
    IL_014b: callvirt     instance void FSharp.Compiler.AbstractIL.Internal.ByteBuffer::EmitBytes(unsigned int8[])
    IL_0150: nop          

    // [3699 11 - 3699 21]
    IL_0151: ldarg.s      skip
    IL_0153: brtrue.s     IL_016c

    // [3700 13 - 3700 146]
    IL_0155: ldarg.3      // sargs_3
    IL_0156: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_015b: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_0160: ldarg.2      // sargs_2
    IL_0161: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_0166: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewSTRING_TEXT(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_016b: ret          

    // [3701 11 - 3701 92]
    IL_016c: ldarg.0      // sargs_0
    IL_016d: ldarg.1      // sargs_1
    IL_016e: ldarg.2      // sargs_2
    IL_016f: ldarg.3      // sargs_3
    IL_0170: ldarg.s      skip
    IL_0172: ldarg.s      lexbuf
    IL_0174: tail.        
    IL_0176: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_017b: ret          

    // [3703 11 - 3703 136]
    IL_017c: ldarg.3      // sargs_3
    IL_017d: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_0182: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_0187: ldarg.2      // sargs_2
    IL_0188: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_018d: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewEOF(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_0192: ret          

    // [3705 11 - 3705 59]
    IL_0193: ldarg.s      lexbuf
    IL_0195: call         string class Internal.Utilities.Text.Lexing.LexBuffer`1<char>::LexemeString(class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_019a: stloc.1      // s5

    // [3706 11 - 3706 59]
    IL_019b: ldarg.0      // sargs_0
    IL_019c: call         class [netstandard]System.Text.Encoding [netstandard]System.Text.Encoding::get_Unicode()
    IL_01a1: ldloc.1      // s5
    IL_01a2: callvirt     instance unsigned int8[] [netstandard]System.Text.Encoding::GetBytes(string)
    IL_01a7: callvirt     instance void FSharp.Compiler.AbstractIL.Internal.ByteBuffer::EmitBytes(unsigned int8[])
    IL_01ac: nop          

    // [3707 11 - 3707 21]
    IL_01ad: ldarg.s      skip
    IL_01af: brtrue.s     IL_01c8

    // [3708 13 - 3708 146]
    IL_01b1: ldarg.3      // sargs_3
    IL_01b2: ldfld        class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>> FSharp.Compiler.Lexhelp/lexargs::ifdefStack@
    IL_01b7: call         instance !0/*class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>*/ class [FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1<class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>>::get_contents()
    IL_01bc: ldarg.2      // sargs_2
    IL_01bd: call         class FSharp.Compiler.Ast/LexerWhitespaceContinuation FSharp.Compiler.Ast/LexerWhitespaceContinuation::NewTripleQuoteString(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<class [netstandard]System.Tuple`2<class FSharp.Compiler.Ast/LexerIfdefStackEntry, valuetype FSharp.Compiler.Range/range>>, valuetype FSharp.Compiler.Range/range)
    IL_01c2: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Parser/token::NewSTRING_TEXT(class FSharp.Compiler.Ast/LexerWhitespaceContinuation)
    IL_01c7: ret          

    // [3709 11 - 3709 92]
    IL_01c8: ldarg.0      // sargs_0
    IL_01c9: ldarg.1      // sargs_1
    IL_01ca: ldarg.2      // sargs_2
    IL_01cb: ldarg.3      // sargs_3
    IL_01cc: ldarg.s      skip
    IL_01ce: ldarg.s      lexbuf
    IL_01d0: tail.        
    IL_01d2: call         class FSharp.Compiler.Parser/token FSharp.Compiler.Lexer::tripleQuoteString(class FSharp.Compiler.AbstractIL.Internal.ByteBuffer, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<valuetype FSharp.Compiler.Range/range, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<unsigned int8[], class FSharp.Compiler.Parser/token>>>, valuetype FSharp.Compiler.Range/range, class FSharp.Compiler.Lexhelp/lexargs, bool, class Internal.Utilities.Text.Lexing.LexBuffer`1<char>)
    IL_01d7: ret          

  } // end of method Lexer::_fslex_tripleQuoteString

Environment

Related information

  • Happen in mac osx only
  • In the repro is using .NET Core Sdk v2.1.401 (so .NET Core Runtime 2.1.3) but newer version fails too.

Activity

  1. enricosada commented on Apr 25, 2019

    @enricosada
    ContributorAuthor

    Q: how to show the stack trace on .NET Core on Mac OS?
    Q: how to diagnose failed tail calls? can that be reported somehow?

    sorry for newbie questions, tried to ask/google but failed

  2. jkotas commented on Apr 25, 2019

    @jkotas
    Member

    This is duplicate of #4907.

    how to show the stack trace on .NET Core on Mac OS?

    Run under debugger. More discussion is in https://github.com/dotnet/coreclr/issues/14720

    how to diagnose failed tail calls? can that be reported somehow?

    The failed tail calls can be observed via JIT events: https://docs.microsoft.com/en-us/dotnet/framework/performance/jit-tracing-etw-events . This document talks about ETW events and Windows, but it should be possible to do the same using eventpipe on Linux/macOS. Or the process can listen to its own events - https://blogs.msdn.microsoft.com/maoni/2019/04/08/a-portable-way-to-get-gc-events-in-process-and-no-admin-privilege-with-10-lines-of-code-and-ability-to-dynamically-enable-disable-events/ has example on how to do that.

    cc @janvorli

  3. enricosada commented on Apr 25, 2019

    @enricosada
    ContributorAuthor

    Thanks @jkotas i missed that (dunno how, i searched issues)

    I'll close and try to check your suggestions to investigate further

  4. janvorli commented on Apr 25, 2019

    @janvorli
    Member

    @enricosada you can set the COMPlus_DefaultStackSize env var to override default stack size for secondary threads. The value you set the variable to is a hexadecimal value without any prefix or suffix. So e.g. COMPlus_DefaultStackSize=180000 sets the default stack size to 1.5MB. This value was enough for your test to pass.

  5. transferred this issue fromdotnet/coreclron Jan 31, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions