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

JTF.TryExecute may throw NullReferenceException #544

Closed
AArnott opened this issue Oct 29, 2019 · 0 comments · Fixed by #870
Closed

JTF.TryExecute may throw NullReferenceException #544

AArnott opened this issue Oct 29, 2019 · 0 comments · Fixed by #870
Labels

Comments

@AArnott
Copy link
Member

AArnott commented Oct 29, 2019

The following code will dereference null when/if this.job==null

#pragma warning disable CS8602 // Dereference of a possibly null reference.
var syncContext = this.job != null ? this.job.ApplicableJobSyncContext : this.job.Factory.ApplicableJobSyncContext;
#pragma warning restore CS8602 // Dereference of a possibly null reference.

As found by @sharwell in #534

This was introduced by bee1e2d.

@AArnott AArnott added the bug label Oct 29, 2019
bluetarpmedia added a commit to bluetarpmedia/vs-threading that referenced this issue Jun 28, 2021
… exists with an assert instead. SingleExecuteProtector can only ever be constructed with a non-null job (validates with Requires.NotNull) and the job is only set to null after TryExecute succeeds. Therefore the job will exist if TryExecute has an invokeDelegate (i.e. has not yet executed). Removed the #pragma that disabled the CS8602 warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant