Closed eerpini closed 13 years ago
I'm not seeing the problem, actually. Assuming tid is invalid and thrptr will then point to a bad location, it is never dereferenced before the isbadtid() check (i.e. an exception won't occur). This thrptr is set way late because we've already run thrptr->state != THRSUSP which will be invalid.
In reality the two checks should be exploded with a isbadtid(tid) check, set thrptr, then check thrptr->state. In practice that gives no benefit (and makes more verbose code).
Agree, thinking about it, the code is not really going to affect much, but looked faulty on a first glance.
Yes, a isbadtid(tid) followed by a thrtab access and then a state check would be the right way to do it, I do not see any possible way that tid would land up with a value outlier enough to cause an exception, but checking if the tid is valid first is a good idea.
Should check for the validity of the tid before accessing the thread table ...