Skip to content

Commit

Permalink
Don't try to access if thread is not running - fixes dotnet#3171
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 2, 2017
1 parent 5872b44 commit fcbb1ce
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ module internal RoslynHelpers =
async { do! Async.SwitchToThreadPool()
return! computation },
continuation=(fun result -> disposeReg(); tcs.TrySetResult(result) |> ignore),
exceptionContinuation=(function :? OperationCanceledException -> disposeReg(); tcs.TrySetCanceled(cancellationToken) |> ignore
| exn -> disposeReg(); tcs.TrySetException(exn) |> ignore),
exceptionContinuation=(function :? OperationCanceledException ->
disposeReg()
if tcs.Task.Status = TaskStatus.Running then

This comment has been minimized.

Copy link
@chillitom

chillitom Jun 2, 2017

could there be a race condition between this line and the next?

This comment has been minimized.

Copy link
@forki

forki Jun 2, 2017

Author Owner

I bet. and tbh I wonder why TrySetException crashes so hard.
Let's just say I located a possible cause. Feel free to send your own PR that fixes it. Would be cool

This comment has been minimized.

Copy link
@chillitom

chillitom Jun 2, 2017

if i can get my head around it then sure thing, but don't hold your breath

the hard crashing is odd, looks like it's coming from deep in a pinvoke syscall

tcs.TrySetCanceled(cancellationToken) |> ignore
| exn ->
disposeReg()
if tcs.Task.Status = TaskStatus.Running then

This comment has been minimized.

Copy link
@chillitom

chillitom Jun 2, 2017

likewise this one, i know it's unlikely

tcs.TrySetException(exn) |> ignore),
cancellationContinuation=(fun _oce -> disposeReg(); tcs.TrySetCanceled(cancellationToken) |> ignore),
cancellationToken=cancellationToken)
task
Expand Down

0 comments on commit fcbb1ce

Please sign in to comment.