Move block untagging logic to another function and sink untagged pointer
to quarantineOrDeallocateChunk().
Details
- Reviewers
cferris
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
1175–1176 | it might be better if you move this into the else down below. Since the first if sets this unconditionally, I think it would be easier to follow to have it set in both the if and else. | |
1178 | I don't think this initializing is necessary since BlockBegin is set in both the if and else statement below. | |
1210–1216 | The Quarantine code path looks like it's kind of odd. I think it would make this code a lot more readable if the qurantine case was moved to the location of the BypassQuarantine bool init. It would look like this: if (!BypassQuarantine) { NewHeader.State = Chunk::State::Quarantined; bool UnlockRequired; auto *TSD = TSDRegistry.getTSDAndLock(&UnlockRequired); Quarantine.put(&TSD->getQuarantineCache(), QuarantineCallback(*this, TSD->getCache()), Ptr, Size); if (UnlockRequired) TSD->unlock(); return; } I think you might need to call unTagBlock if memory tagging is enabled in the quarantine path. Right now this new change does some extra work when in the quarantine path, but if you split it out then that won't happen. And adding the unTagBlock call might also do some extra work though so I'm not sure what's the best way to handle this. It might be better to do that in a follow-on though. I'll leave that up to you, or since it's my suggestion, I can also do this. |
Address review comments
compiler-rt/lib/scudo/standalone/combined.h | ||
---|---|---|
1210–1216 | I agree with the code motion of quarantine block. As we discussed, we may also want to config quarantine by compilation flag. Thus I'm planning to do the code motion with the config change in a later CL. I've fixed the part that we did more work in quarantine path. Now it should be the same logic as before. |
it might be better if you move this into the else down below. Since the first if sets this unconditionally, I think it would be easier to follow to have it set in both the if and else.