-
Notifications
You must be signed in to change notification settings - Fork 796
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
Task ate my data! Unexpected results at runtime. No errors in core stack. #13404
Comments
If I create a new console app and add paste the code there (with
Could it be that if you have multiple taskbuilders, or the task continuation changes the execution thread, somehow something here is not thread-safe or overwrites the state of another task? tasks.fs type TaskBuilder, |
@Thorium What's your exact VS or VSCode or .NET SDK version please BTW I'd imagine a fix is to move the chunks of synchronous code out of |
@Thorium reports that he's using latest SDK which I assume means I can confirm that a workaround is to move synchronous code using
Though you may want to use this code instead, so you can scan for module Array =
[<MethodImpl(MethodImplOptions.NoInlining)>]
let mapFixed f xs = FSharp.Collections.Array.map f xs
[<Obsolete("Do not use Array.map in this project because of https://github.com/dotnet/fsharp/issues/13404", true)>]
let map f xs = FSharp.Collections.Array.map f xs |
So is this actually a bug or just that it's using an early version of F#6 which had that issue with Array.map (which was my first thought when seeing this) - has it been reproed in e.g. FSI directly or VS/VSCode etc.? |
I'm on the latest version of everything.
…On Wed, 29 Jun 2022, 14:23 Isaac Abraham, ***@***.***> wrote:
So is this actually a bug or just that it's using an early version of F#6
which had that issue with Array.map (which was my first thought when seeing
this) - has it been reproed in e.g. FSI directly or VS/VSCode etc.?
—
Reply to this email directly, view it on GitHub
<#13404 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCXBH2PRU56SOGAQGZEU5DVRRE3FANCNFSM52DAZPVQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
If it's a notebook, the kernel can be using an old |
@isaacabraham This certainly looks like another variation of the bug of #12359, unfixed as yet. Also #12337 may be relevant. The circumstances appear to be:
The underlying problem is that Array.map is inlined to an imperative |
A smaller repro that causes a different exception is at https://gist.github.com/dsyme/0e748fbab29e0ba4ca15cfefdf88055b
or in repo:
I haven't yet found a repro that doesn't involve |
@vzarytovskii thanks, that's what I was really getting at hence my suggestion re: FSI / VS etc. :-) |
notebook is just a detail to reproduce the issue, this happens also new non-notebook. |
Smallish repro that gives a |
OK I have this fixed - at least the data corruption part (caused by incorrect codegen). The bug will occur when a nested task fails state machine compilation. A realiable workaround is if a nested task gives The failure of state machine compilation is separate issue. |
That's excellent, thanks. |
- After experiencing [still many bugs with native tasks](dotnet/fsharp#13404) we're gonna revert the changes (again) to use Ply. - This also upgrades the build infrastructure to make releasing easier
The lack of static complation of some tasks is being tracked here: #12839 |
Description of the issue
Converting an existing async function to the new F# 6 task CE throws up some unexpected and undesirable behaviour:
Steps required to reproduce the problem:
The attached ZIP file contains two .NET Interactive Notebooks, test_async.dib, which is the original function using async, and test_task.dib, which uses the new task CE. Running them yields the results described. The data array gets swallowed up.
test.dib.zip
Other notes:
System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed
Expected result
True, [ ( 2022-06-28 18:06:32Z, 3, 4, 5, { Some(6): Value: 6 }, { Some(1): Value: 1 }, True, ( { Some(7): Value: 7 }, True, 2022-06-28 18:06:32Z ) ), ( 2022-06-28 18:06:32Z, 3, 4, 5, { Some(6): Value: 6 }, { Some(1): Value: 1 }, True, ( { Some(7): Value: 7 }, True, 2022-06-28 18:06:32Z ) ), ( 2022-06-28 18:06:32Z, 3, 4, 5, { Some(6): Value: 6 }, { Some(1): Value: 1 }, True, ( { Some(7): Value: 7 }, True, 2022-06-28 18:06:32Z ) ) ], 3
Actual result
True, null, 3
Known workarounds
There is no clear understanding of when we need a workaround for what, leading to a lack of ability to trust the new task-construct, so it seems rather fragile.
Related information
The text was updated successfully, but these errors were encountered: