Bug 46528 - Problems running F# script with MailboxProcessor in Mono
Summary: Problems running F# script with MailboxProcessor in Mono
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-06 11:40 UTC by Michel Nielsen
Modified: 2017-10-10 14:17 UTC (History)
4 users (show)

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


Attachments
F# script to reproduce the error (675 bytes, text/plain)
2016-11-06 14:29 UTC, Michel Nielsen
Details

Description Michel Nielsen 2016-11-06 11:40:27 UTC
When trying to run a F# script containing a MailboxProcessor, in Linux with Mono I get following stacktrace. 
(I am able to compile the same code to an exe file and run it just fine with Mono, I just can't execute it as script with fsharpi without getting the stacktrace)

* Assertion at mini-generic-sharing.c:2351, condition `info' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at Microsoft.FSharp.Control.Queue`1<T_REF>..ctor () <0x00017>
  at Microsoft.FSharp.Control.Mailbox`1<TMsg_REF>..ctor () <0x00047>
  at Microsoft.FSharp.Control.FSharpMailboxProcessor`1<TMsg_REF>..ctor (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Control.FSharpMailboxProcessor`1<TMsg_REF>, Microsoft.FSharp.Control.FSharpAsync`1<Microsoft.FSharp.Core.Unit>>,Microsoft.FSharp.Core.FSharpOption`1<System.Threading.CancellationToken>) <0x00117>
  at Microsoft.FSharp.Control.FSharpMailboxProcessor`1<TMsg_REF>.Start (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Control.FSharpMailboxProcessor`1<TMsg_REF>, Microsoft.FSharp.Control.FSharpAsync`1<Microsoft.FSharp.Core.Unit>>,Microsoft.FSharp.Core.FSharpOption`1<System.Threading.CancellationToken>) <0x00047>
  at <StartupCode$FSI_0001>.$FSI_0001.main@ () <0x000b7>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0x000ba>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0x0006c>
  at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000a1>
  at System.RuntimeType.InvokeMember (string,System.Reflection.BindingFlags,System.Reflection.Binder,object,object[],System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,string[]) <0x00f06>
  at System.Reflection.Emit.TypeBuilder.InvokeMember (string,System.Reflection.BindingFlags,System.Reflection.Binder,object,object[],System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,string[]) <0x00069>
  at System.Type.InvokeMember (string,System.Reflection.BindingFlags,System.Reflection.Binder,object,object[],System.Globalization.CultureInfo) <0x0005e>
  at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter/execEntryPtFun@2053-1.Invoke (Microsoft.FSharp.Core.Unit) <0x0009e>
  at Microsoft.FSharp.Compiler.Interactive.Shell/clo@905-37.Invoke (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Core.FSharpOption`1<System.Exception>>) <0x00022>
  at Microsoft.FSharp.Primitives.Basics.List.iter<T_REF> (Microsoft.FSharp.Core.FSharpFunc`2<T_REF, Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Collections.FSharpList`1<T_REF>) <0x00047>
  at Microsoft.FSharp.Collections.ListModule.Iterate<T_REF> (Microsoft.FSharp.Core.FSharpFunc`2<T_REF, Microsoft.FSharp.Core.Unit>,Microsoft.FSharp.Collections.FSharpList`1<T_REF>) <0x0002f>
  at Microsoft.FSharp.Compiler.Interactive.Shell.arg10@904 (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompiler,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Core.FSharpOption`1<System.Exception>>>,Microsoft.FSharp.Core.Unit) <0x0006f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompiler.ProcessInputs (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Compiler.Ast/ParsedInput>,bool,bool,bool,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Compiler.Ast/Ident>) <0x0079f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompiler.EvalParsedDefinitions (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,bool,bool,Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Compiler.Ast/SynModuleDecl>) <0x0020b>
  at Microsoft.FSharp.Compiler.Interactive.Shell/clo@1653-45.Invoke (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0192b>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.InteractiveCatch<a_REF> (Microsoft.FSharp.Core.FSharpFunc`2<a_REF, System.Tuple`2<a_REF, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>,a_REF) <0x00049>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.ExecInteraction (bool,Microsoft.FSharp.Compiler.CompileOps/TcConfig,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,Microsoft.FSharp.Compiler.Ast/ParsedFsiInteraction) <0x00073>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.ExecInteractions (bool,Microsoft.FSharp.Compiler.CompileOps/TcConfig,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Compiler.Ast/ParsedFsiInteraction>) <0x00a6b>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.MainThreadProcessParsedInteraction (bool,Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Compiler.Ast/ParsedFsiInteraction>,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0019f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/res@1870.Invoke (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0002f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/run@1887-1.Invoke (Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, System.Tuple`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0001d>
  at Microsoft.FSharp.Core.OptimizedClosures/Invoke@3256<T2_REF, TResult_REF, T1_REF>.Invoke (T2_REF) <0x00029>
  at Microsoft.FSharp.Compiler.Interactive.Shell/ParseAndProcessAndEvalOneInteractionFromLexbuf@1859.Invoke (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x001d8>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.InteractiveCatch<a_REF> (Microsoft.FSharp.Core.FSharpFunc`2<a_REF, System.Tuple`2<a_REF, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>,a_REF) <0x00049>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.ParseAndProcessAndEvalOneInteractionFromLexbuf (bool,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, System.Tuple`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>, Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, System.Tuple`2<Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>>,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,Microsoft.FSharp.Compiler.LexFilter/LexFilter) <0x00173>
  at Microsoft.FSharp.Compiler.Interactive.Shell.run@1886 (Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor,bool,Microsoft.FSharp.Compiler.LexFilter/LexFilter,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0006f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/EvalIncludedScript@1882.Invoke (Microsoft.FSharp.Core.Unit) <0x00047>
  at Microsoft.FSharp.Compiler.Interactive.Shell.WithImplicitHome<a_REF> (Microsoft.FSharp.Compiler.CompileOps/TcConfigBuilder,string,Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit, a_REF>) <0x0004a>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.EvalIncludedScript (bool,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,string,Microsoft.FSharp.Compiler.Range/range) <0x000bf>
  at Microsoft.FSharp.Compiler.Interactive.Shell/EvalIncludedScripts@1906.Invoke (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x00043>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.InteractiveCatch<a_REF> (Microsoft.FSharp.Core.FSharpFunc`2<a_REF, System.Tuple`2<a_REF, Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionStepStatus>>,a_REF) <0x00049>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.EvalIncludedScripts (Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,bool,Microsoft.FSharp.Collections.FSharpList`1<string>) <0x00093>
  at Microsoft.FSharp.Compiler.Interactive.Shell.consume@1916 (Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor,bool,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState,Microsoft.FSharp.Collections.FSharpList`1<System.Tuple`2<string, bool>>) <0x000fb>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiInteractionProcessor.LoadInitialFiles (bool,Microsoft.FSharp.Compiler.Interactive.Shell/FsiDynamicCompilerState) <0x0002f>
  at Microsoft.FSharp.Compiler.Interactive.Shell/FsiEvaluationSession.Run () <0x00ec7>
  at Microsoft.FSharp.Compiler.Interactive.Shell.evaluateSession@2527 (string[],Microsoft.FSharp.Core.Unit) <0x000bb>
  at Microsoft.FSharp.Compiler.Interactive.Shell.MainMain (string[]) <0x001cf>
  at Microsoft.FSharp.Compiler.Interactive.Main.FsiMain (string[]) <0x0000f>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0x000f5>

Native stacktrace:

	/usr/bin/mono() [0x4accca]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0) [0x7f2aa36888d0]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f2aa30ed067]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f2aa30ee448]
	/usr/bin/mono() [0x65ae19]
	/usr/bin/mono() [0x65b027]
	/usr/bin/mono() [0x65b176]
	/usr/bin/mono() [0x4ba929]
	/usr/bin/mono() [0x4aec20]
	[0x41d8678c]

Debug info from gdb:


=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Aborted
Comment 1 Michel Nielsen 2016-11-06 14:29:04 UTC
Created attachment 18351 [details]
F# script to reproduce the error

F# script to reproduce the error
Comment 2 curylod 2016-11-18 15:16:35 UTC
I hit this same issue, and found a narrower case that I hope helps to find the root cause more quickly.

// Simple tuple works fine:
type Rec = int * int

MailboxProcessor<Rec>.Start(fun inbox ->
    let rec loop () = async {
        let! r = inbox.Receive ()
        do! loop ()
    }        
    loop ()
)

The above works fine, but running the same agent with a DU or record creates this crash:

type Rec = {
    A : int
    B : int
}

MailboxProcessor<Rec>.Start(fun inbox ->
    let rec loop () = async {
        let! r = inbox.Receive ()
        do! loop ()
    }        
    loop ()
)

This results in the exception reported.

* Assertion at mini-generic-sharing.c:2351, condition `info' not met
Comment 3 curylod 2016-11-18 15:25:00 UTC
Also worth noting, the same code works just fine when compiled into a console application.  This appears to only be an issue when running from FSharp interactive.
Comment 4 curylod 2017-08-02 21:13:46 UTC
I tried this on mono 5.0.1.1 and the issue no longer occurs.  IMO we can close this.  Michel - do you agree?
Comment 5 Ludovic Henry 2017-10-06 23:53:55 UTC
I cannot reproduce with Mono 5.8.0.2 (2017-10/a3943e28cf8)
Comment 6 curylod 2017-10-10 14:17:57 UTC
I also can no longer reproduce with current GA release 5.2.0.224 (d15-3/14f2c81).  Looks like this one was fixed at some point.

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