dotnet/runtime

Null checks in incorrect order in Cordb::Terminate

Open

#47.463 geöffnet am 26. Jan. 2021

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (5.445 Forks)batch import
area-Diagnostics-coreclrhelp wanted

Repository-Metriken

Stars
 (17.886 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)

Beschreibung

There's a null-check for m_rcEventThread in Cordb::Terminate here:

https://github.com/dotnet/runtime/blob/3f12b16fa6db2b2ca5c9016ed9540547a3e752d5/src/coreclr/debug/di/rsmain.cpp#L1125

But the variable is already used without null-testing a littler earlier in the same method:

https://github.com/dotnet/runtime/blob/3f12b16fa6db2b2ca5c9016ed9540547a3e752d5/src/coreclr/debug/di/rsmain.cpp#L1079

If the variable was actually null, dereferencing it leads to undefined behaviour, so a compiler is free to assume that wont happen. A recent compiler might therefore remove the null check on line 1125 entirely. We should probably null-check m_rcEventThread everywhere, or remove the null-checks.

Contributor Guide