PhantomGamesDevelopment / Galactic-2D

Open source engine technology created in C++.
1 stars 1 forks source link

Tests Needed: PThread_ContinualThread Deletion #17

Open Phantom139 opened 10 years ago

Phantom139 commented 10 years ago

As noted with a lovely 4 line block comment in pContinualThread.cpp, we have a potential major issue here when a thread instance is deleted. Since the threading system itself by definition must also have multi-thread support, it is entirely possible that the instance of "this", may be deleted before a call to delete() is actually done, which would lead to access violation crashes.

Now, the notion of checking the this pointer itself, seems to be something that would be valid, however most people think it violates some silly "standard". I honestly have to disagree here since writing safe code has the precedence. However, I'm opening this issue to have a full test of the module to ensure this block of code behaves as intended.

                    if(this != NULL) {
                        SendToHell(this);
                    }
                    else {
                        GC_Error("PContinualThread::kill(): Thread kill exception leak blocked...");
                        return false;
                    }
Phantom139 commented 9 years ago

Some investigations into the manner suggests that the notion of testing the "this" pointer is perfectly safe in this case and it should safeguard the potential crashes.

I'll leave the investigation label on this as we'll need to get a good test of this before I'll close the issue and that'll require platform support for a PThread platform (Linux, Mac, Etc).