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

Failed to read captured data (MinGW 7.3) #176

Open
sk-landry opened this issue Apr 3, 2020 · 0 comments
Open

Failed to read captured data (MinGW 7.3) #176

sk-landry opened this issue Apr 3, 2020 · 0 comments

Comments

@sk-landry
Copy link

sk-landry commented Apr 3, 2020

Hi everyone !

I've built easy_profiler (commit 5ee29cd ) on Windows 10 with MinGW 7.3 (from QT)

The build went fine, no error, I can start capturing data, but when I stop the capture I am unable to read it. The profiler_gui crashes

After investigation the error was coming from the destructor of ThreadGuard in (profile_manager.cpp)

The error is strange, the problem is from the order of the if statement. May be a problem with the macro THIS_THREAD.

When I change this
if (m_id != 0 && THIS_THREAD != nullptr && THIS_THREAD->id == m_id)
to that
if (THIS_THREAD != nullptr && m_id != 0 && THIS_THREAD->id == m_id)
It solves the issue

To be specific you cannot call THIS_THREAD != nullptr before m_id != 0, I've tried a nested if and got the same issue

if (m_id != 0)
    {
		if(THIS_THREAD != nullptr)
		{
			
		}
	}

Here is the full code of the destructor

profiler::ThreadGuard::~ThreadGuard()
{
#ifndef EASY_PROFILER_API_DISABLED
	if (THIS_THREAD != nullptr && m_id != 0 && THIS_THREAD->id == m_id)
    {
		bool isMarked = false;
        EASY_EVENT_RES(isMarked, "ThreadFinished", EASY_COLOR_THREAD_END, profiler::FORCE_ON);
        //THIS_THREAD->markProfilingFrameEnded();
        THIS_THREAD->putMark();
        THIS_THREAD->expired.store(isMarked ? 2 : 1, std::memory_order_release);
		THIS_THREAD = nullptr;
    }
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant