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

Detect invalid VerifyAccess calls #42

Open
randymarsh77 opened this issue Jan 15, 2019 · 0 comments
Open

Detect invalid VerifyAccess calls #42

randymarsh77 opened this issue Jan 15, 2019 · 0 comments
Labels
new analyzer Suggestion for a new analyzer to add

Comments

@randymarsh77
Copy link
Member

Calling (Dispatcher.)VerifyAccess() (typically through NotifyPropertyChangedDispatcherBase) from a non dispatcher-affined thread (typically, any threadpool thread) causes an application crash. Yet, this is a very common developer mistake that results in wasted time at the very least.

Detecting the dispatcher context of calls to VerifyAccess seems possible, though computationally intensive. Doing a fixed N-level deep search on code in the scope of a switch to the threadpool seems like it might be less computationally expensive, and still provide value.

However, perhaps the biggest challenge would be to resolve variant runtime behavior in order to properly detect invalid code. e.g.

context.Switch(await context.ToThreadPool());
if (x) context.Switch(await context.ToSyncContext());
if (y) VerifyAccess();
@randymarsh77 randymarsh77 added the new analyzer Suggestion for a new analyzer to add label Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new analyzer Suggestion for a new analyzer to add
Development

No branches or pull requests

1 participant