Viladoman / CompileScore

Tools for profiling and visualizing C++ build times.
MIT License
460 stars 19 forks source link

Gatherer::OnCompilerPassEnded - nullptr exception #2

Closed ikrima closed 3 years ago

ikrima commented 4 years ago

Excellent project

TLDR

Noticed this crash on: https://github.com/Viladoman/CompileScore/blob/cd1441c8c677440d844a26a00aa0f0bb4b3f02c8/DataExtractor/Cpp/src/Extractors/MSVCScore.cpp#L144

if m_activeTU is null => m_activeTUI->timeline.name will crash. Changed it to

if (m_activeTU && category == CompileCategory::BackEnd)
{ 
  FinalizeTU(m_activeTU->timeline.name);
}

Investigation

Only did a quick perusal. Looks like OnCompilerPassEnded gets called with said translation unit before OnCompilerPassStart() for the backend phase. I added tracepoints around the specific file that causes the crash in the start phase and the finalize phase as I initially thought it might've been prematurely dealloced or removed or something but they were never triggered first

Unsure if a deeper logic error exists or if something else is malformed as i'm not too familiar with build insights or this extensions source code

Viladoman commented 4 years ago

Wow! Sorry about that crash. I appreciate your investigation. Receiving the end event before the start is indeed strange and I was not expecting this at all :/. I am learning build insights too while coding this so there might be some mistakes on my end for sure.

I think your fix is valid to avoid crashing and I will have a look soon as I wanted to extend the MSVC exposed information.