runtime_loader: Correct destruction of old TLS DSO blocks.
Instead of checking against the current block's DSO generation, the DSO that the operator[] was invoked on was being checked instead. This could lead to spurious deletions of TLS data in the case where the generation count changed between accesses of the TLS variable (currently that only happens when modules are unloaded.) May fix #17896, but I did not have a reliable way to reproduce that. Change-Id: Ie1ee51c1fbbe638918fd5a010047a2b56d481f2b Reviewed-on: https://review.haiku-os.org/c/haiku/+/5604 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]> Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
8fc394c12d
commit
aabcd6b399
@@ -235,11 +235,13 @@ DynamicThreadVector::operator[](unsigned dso)
|
||||
{
|
||||
unsigned generation = TLSBlockTemplates::Get().GetGeneration(-1);
|
||||
if (_Generation() < generation) {
|
||||
for (unsigned i = 0; i < _Size(); i++) {
|
||||
TLSBlock& block = (*fVector)[i + 1];
|
||||
// We need to destroy any blocks whose DSO generation has changed
|
||||
// to be greater than our own generation.
|
||||
for (unsigned dsoIndex = 0; dsoIndex < _Size(); dsoIndex++) {
|
||||
TLSBlock& block = (*fVector)[dsoIndex + 1];
|
||||
unsigned dsoGeneration
|
||||
= TLSBlockTemplates::Get().GetGeneration(dso);
|
||||
if (_Generation() < dsoGeneration && dsoGeneration <= generation)
|
||||
= TLSBlockTemplates::Get().GetGeneration(dsoIndex);
|
||||
if (dsoGeneration > _Generation() && dsoGeneration <= generation)
|
||||
block.Destroy();
|
||||
}
|
||||
|
||||
@@ -257,7 +259,7 @@ DynamicThreadVector::operator[](unsigned dso)
|
||||
status_t result = block.Initialize(dso);
|
||||
if (result != B_OK)
|
||||
return fNullBlock;
|
||||
};
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user