Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible race condition in System.IO.Pipelines: InvalidCastException in (System.Memory's)System.Buffers.ReadOnlySequence.GetFirstBuffer #27580

Closed
knocte opened this issue Oct 9, 2018 · 8 comments
Labels
area-System.Memory bug tenet-reliability Reliability/stability related issue (stress, load problems, etc.)
Milestone

Comments

@knocte
Copy link
Contributor

knocte commented Oct 9, 2018

I have a System.IO.Pipelines-based TCP client written here.

The client works normally in RELEASE mode and when running under integration tests. However I have found that under certain slower conditions (debugging in an Android phone), an exception happens in System.Buffers.BufferExtensions.PositionOf:

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: start
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument) [0x00006] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.ReadOnlyMemory`1[T].Slice (System.Int32 start, System.Int32 length) [0x0001e] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.Buffers.ReadOnlySequence`1[T].GetFirstBuffer () [0x00065] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.Buffers.ReadOnlySequence`1[T].get_First () [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00008] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@56.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/JsonRpcSharp.fs:57
  at GWallet.Backend.JsonRpcSharp+clo@54-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00014] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/JsonRpcSharp.fs:63
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/FaultTolerantParallelClient.fs:132
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/FaultTolerantParallelClient.fs:126
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/FaultTolerantParallelClient.fs:126
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/FaultTolerantParallelClient.fs:73
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/FSharpUtil.fs:20
  at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/Account.fs:35
  at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/Account.fs:27
  at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTEND/src/GWallet.Backend/Account.fs:27
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  --- End of inner exception stack trace ---

The area of the code where this happens is:

// Translation of https://github.com/davidfowl/TcpEcho/blob/master/src/Program.cs
type TcpClient (resolveHostAsync: unit->Async<IPAddress>, port) =

    (...)

    let rec ReadPipeInternal (reader: PipeReader) (stringBuilder: StringBuilder) = async {
            let processLine (line:ReadOnlySequence<byte>) =
                line |> GetAsciiString |> stringBuilder.AppendLine |> ignore

            let rec keepAdvancingPosition (buffer: ReadOnlySequence<byte>): ReadOnlySequence<byte> =
                // How to call a ref extension method using extension syntax?
                let maybePosition = System.Buffers.BuffersExtensions.PositionOf(ref buffer, byte '\n')
                                    |> Option.ofNullable
                match maybePosition with
                | None ->
                    buffer
                | Some pos ->
                    buffer.Slice(0, pos)
                    |> processLine
                    let nextBuffer = buffer.GetPosition(1L, pos)
                                     |> buffer.Slice
                    keepAdvancingPosition nextBuffer

            let! result = (reader.ReadAsync().AsTask() |> Async.AwaitTask)

            let lastBuffer = keepAdvancingPosition result.Buffer
            reader.AdvanceTo(lastBuffer.Start, lastBuffer.End)
            if not result.IsCompleted then
                return! ReadPipeInternal reader stringBuilder
            else
                return stringBuilder.ToString()
        }

I've tried to guard the call to PositionOf by calling buffer.IsEmpty first (to not call PositionOf in case it's empty), but this results in a NullReferenceException (which is surprising given that buffer is of a struct type, so can't be null).

In the sources you see, the package versions used are:

System.Buffers: 4.5.0
System.IO.Pipelines 4.5.0
System.Memory 4.5.1

@davidfowl
Copy link
Member

@pakrym @ahsonkhan

@knocte
Copy link
Contributor Author

knocte commented Oct 19, 2018

Today I ran this again, and this time I got an NRE: https://gist.github.com/knocte/cb5c54f8454c42bc3853de4e9af00736

(Note that this a copy+paste from the console, given that the exception dialog didn't let me copy the exception details. To get the exception in the console I had to do this before the raise task.Exception line:)

                    Console.Error.WriteLine("________________")
                    Console.Error.WriteLine(task.Exception.ToString())
                    Console.Error.WriteLine("________________")

And I also noticed that there was a new version of System.IO.Pipelines, so I upgraded from 4.5.0 and 4.5.2, ran it again, and the problem is still not solved:


10-19 19:46:41.106 I/mono-stderr(24435): System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an objectSystem.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object

  at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 10-19 19:46:41.107 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 

10-19 19:46:41.107 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.107 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0   at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 

10-19 19:46:41.108 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0   at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClien

10-19 19:46:41.108 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 t.fs:132 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSh

10-19 19:46:41.108 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 arp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <43dbbdc147f2482093d8409abb04c233>:0 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:73 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[

10-19 19:46:41.109 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FSharpUtil.fs:20 
  at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in C:\Users\DigitasAdmin\Documents\geewallet\src\GW

10-19 19:46:41.109 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 allet.Backend\Account.fs:35 
  at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
  at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Con

10-19 19:46:41.109 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 trol.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& sourc

10-19 19:46:41.110 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---e, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 
  at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>

10-19 19:46:41.110 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 :0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at <StartupCode$GWallet-Backend-NetS

10-19 19:46:41.110 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 tandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:132 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].I

10-19 19:46:41.111 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 nvoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <43dbbdc147f2482093d8409abb04c233>:0 
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <43dbbdc147f2482093d8409abb04c233>:0 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _a

10-19 19:46:41.111 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 rg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:73 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in C:\Users\DigitasAdmin\Documents\geewall

10-19 19:46:41.111 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 et\src\GWallet.Backend\FSharpUtil.fs:20 
  at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:35 
  at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
  at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa74

10-19 19:46:41.111 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---50383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object
  at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at System.Bu

ffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
  at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 
  at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FS10-19 19:46:41.111 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:132 

harpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
--- End of stack trace from previ10-19 19:46:41.111 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 

ous location where exception was thrown ---
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:132 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa10-19 19:46:41.111 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 

7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 <---
<---

________________10-19 19:46:41.111 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 

10-19 19:46:41.111 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.111 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.111 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.111 I/mono-stderr(24435):    --- End of inner exception stack trace ---
10-19 19:46:41.111 I/mono-stderr(24435):   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.111 I/mono-stderr(24435):   at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:73 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.112 I/mono-stderr(24435):   at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FSharpUtil.fs:20 
10-19 19:46:41.112 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:35 
10-19 19:46:41.112 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
10-19 19:46:41.112 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.112 I/mono-stderr(24435):    --- End of inner exception stack trace ---
10-19 19:46:41.112 I/mono-stderr(24435): ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object
10-19 19:46:41.113 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 
10-19 19:46:41.113 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 
10-19 19:46:41.113 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.113 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.113 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.113 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.114 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:132 
10-19 19:46:41.114 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
10-19 19:46:41.114 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
10-19 19:46:41.114 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.114 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.116 I/mono-stderr(24435):    --- End of inner exception stack trace ---
10-19 19:46:41.116 I/mono-stderr(24435):   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.116 I/mono-stderr(24435):   at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.116 I/mono-stderr(24435):   at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <43dbbdc147f2482093d8409abb04c233>:0 
10-19 19:46:41.116 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:73 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.117 I/mono-stderr(24435):   at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FSharpUtil.fs:20 
10-19 19:46:41.117 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:35 
10-19 19:46:41.117 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
10-19 19:46:41.117 I/mono-stderr(24435):   at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\Account.fs:27 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.117 I/mono-stderr(24435): ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object
10-19 19:46:41.118 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGetBuffer (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.SequencePosition& next) [0x00044] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at System.Buffers.ReadOnlySequence`1[T].TryGet (System.SequencePosition& position, System.ReadOnlyMemory`1[T]& memory, System.Boolean advance) [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOfMultiSegment[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00009] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00039] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@52.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:52 
10-19 19:46:41.118 I/mono-stderr(24435):   at GWallet.Backend.JsonRpcSharp+clo@66-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\JsonRpcSharp.fs:66 
10-19 19:46:41.118 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.118 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.118 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.118 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.119 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.120 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.120 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.120 I/mono-stderr(24435): --- End of stack trace from previous location where exception was thrown ---
10-19 19:46:41.120 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:132 
10-19 19:46:41.121 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
10-19 19:46:41.121 I/mono-stderr(24435):   at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in C:\Users\DigitasAdmin\Documents\geewallet\src\GWallet.Backend\FaultTolerantParallelClient.fs:126 
10-19 19:46:41.121 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.121 I/mono-stderr(24435):   at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.121 I/mono-stderr(24435):   at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 
10-19 19:46:41.121 I/mono-stderr(24435):   at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0 <---
10-19 19:46:41.121 I/mono-stderr(24435): <---
10-19 19:46:41.121 I/mono-stderr(24435): 
10-19 19:46:41.121 I/mono-stderr(24435): ________________

@knocte knocte changed the title Possible race condition in (System.Memory's)System.Buffers.BufferExtensions.PositionOf causes ArgumentOutOfRangeException Possible race condition in System.IO.Pipelines: ArgumentOutOfRangeException in (System.Memory's)System.Buffers.BufferExtensions.PositionOf or NullReferenceException in System.Buffers.ReadOnlySequence`1[T].TryGetBuffer Oct 19, 2018
@knocte
Copy link
Contributor Author

knocte commented Oct 19, 2018

Note that while I can reproduce this consistently (100% of the times) when debugging with an Android phone (either with VS2017 or VSforMac), the bug doesn't happen when debugging with the Android emulator.

@knocte
Copy link
Contributor Author

knocte commented Dec 28, 2018

Even if I haven't upgraded any nuget packages recently in my solution (at least not later than my latest comments on the 19th of October), somehow this exception has now morphed into another one (maybe because I upgraded my VisualStudioForMac and XamarinAndroid to latest stable versions recently?).

Now the exception is an InvalidCastException inside System.Buffers.ReadOnlySequence1[T].GetFirstBuffer ()`. Full stacktrace here:

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.InvalidCastException: Specified cast is not valid.
  at System.Buffers.ReadOnlySequence`1[T].GetFirstBuffer () [0x00079] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.Buffers.ReadOnlySequence`1[T].get_First () [0x00000] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at System.Buffers.BuffersExtensions.PositionOf[T] (System.Buffers.ReadOnlySequence`1[T]& source, T value) [0x00008] in <f6dad3dbe4c6408e8a0f6ade27956b1c>:0
  at GWallet.Backend.JsonRpcSharp+keepAdvancingPosition@54.Invoke (System.Buffers.ReadOnlySequence`1[T] buffer) [0x00002] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/JsonRpcSharp.fs:57
  at GWallet.Backend.JsonRpcSharp+clo@70-2.Invoke (System.IO.Pipelines.ReadResult _arg1) [0x00002] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/JsonRpcSharp.fs:70
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000a3] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$FSharp-Core>.$Async+AwaitAndBindChildResult@1484-3[T].Invoke (System.Boolean _arg3) [0x0000f] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1426-4.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncResult`1[T].Commit () [0x0002c] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a] (System.Threading.CancellationToken cancellationToken, Microsoft.FSharp.Control.FSharpAsync`1[T] computation) [0x00028] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T] (System.Threading.CancellationToken cancellationToken, Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout) [0x00013] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T] (Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout, Microsoft.FSharp.Core.FSharpOption`1[T] cancellationToken) [0x0006e] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at GWallet.Backend.UtxoCoin.Account+ElectrumServerToRetreivalFunc@70[T,R].Invoke (GWallet.Backend.UtxoCoin.ElectrumServer electrumServer, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] electrumClientFunc, T arg) [0x000fd] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs:89
  at Microsoft.FSharp.Core.OptimizedClosures+Invoke@2823-1[T2,T3,TResult,T1].Invoke (T2 u, T3 v) [0x00000] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Core.OptimizedClosures+Invoke@2810[T2,TResult,T1].Invoke (T2 u) [0x00000] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@136-60[E,K,T,R].Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:136
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, TResult result1, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] part2) [0x00005] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives.TryWith[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFunction) [0x00034] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@135-70[E,K,T,R].Invoke (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:135
  at Microsoft.FSharp.Control.AsyncPrimitives.Invoke[T] (Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt) [0x0005f] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+QueueAsync@855[a].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00038] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FSharpUtil.fs:35
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@135-62[E,K,T,R].Invoke (System.Exception _arg2) [0x000e5] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:156
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@135-69[E,K,T,R].Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:135
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@135-71[E,K,T,R].Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:135
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@78-53[E,K,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:78
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000a3] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FSharpUtil.fs:35
  at GWallet.Backend.Account+GetBalanceFromServer@28-5.Invoke (System.Exception _arg2) [0x00028] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:36
  at GWallet.Backend.Account+GetBalanceFromServer@28-8.Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:28
  at GWallet.Backend.Account+GetBalanceFromServer@28-10.Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:28
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5beb52bf904cf4daa7450383bf52eb5b>:0
  --- End of inner exception stack trace ---

By looking at the sources, it' seems there's only one cast in that method:

https://github.com/dotnet/corefx/blob/master/src/System.Memory/src/System/Buffers/ReadOnlySequence.Helpers.cs#L109

At least now the problem seems more localized.

@knocte knocte changed the title Possible race condition in System.IO.Pipelines: ArgumentOutOfRangeException in (System.Memory's)System.Buffers.BufferExtensions.PositionOf or NullReferenceException in System.Buffers.ReadOnlySequence`1[T].TryGetBuffer Possible race condition in System.IO.Pipelines: InvalidCastException in (System.Memory's)System.Buffers.ReadOnlySequence.GetFirstBuffer Dec 28, 2018
@ahsonkhan
Copy link
Member

System.Buffers: 4.5.0
System.IO.Pipelines 4.5.0
System.Memory 4.5.1

@knocte, are you able to reproduce the issue with the latest versions of the packages?

@davidfowl
Copy link
Member

@knocte are you still seeing this?

@knocte
Copy link
Contributor Author

knocte commented Sep 20, 2019

TBH I cannot answer that because now I'm being affected by an IDE bug :( : https://github.com/mono/monodevelop/issues/8552

@knocte
Copy link
Contributor Author

knocte commented Mar 21, 2024

I haven't seen this in a big while.

@knocte knocte closed this as completed Mar 21, 2024
@knocte knocte reopened this Mar 21, 2024
@knocte knocte closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
@dotnet-policy-service dotnet-policy-service bot removed no-recent-activity backlog-cleanup-candidate An inactive issue that has been marked for automated closure. labels Mar 21, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Memory bug tenet-reliability Reliability/stability related issue (stress, load problems, etc.)
Projects
None yet
Development

No branches or pull requests

4 participants