Page MenuHomePhabricator

net: fix use-after-free in tests
AbandonedPublic

Authored by PiRK on Aug 24 2021, 07:50.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

In PeerLogicValidation::PeerLogicValidation() we would schedule a lambda
function to execute later, capturing the local variable
consensusParams by reference.

Presumably this was considered safe because consensusParams is a
reference itself to a global variable which is not supposed to change,
but it can in tests.

Fixes https://github.com/bitcoin/bitcoin/issues/18372

This is a backport of core#18376

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Aug 24 2021, 07:50

can you reproduce this tsan error? I can't

PiRK planned changes to this revision.Aug 24 2021, 13:15

can you reproduce this tsan error? I can't

No I can't either. I backported it to err on the side of caution.

But looking at some of the discussion (https://github.com/bitcoin/bitcoin/pull/18376#issuecomment-600775702), I think it is best to put this diff on standby as long as we don't see the error. What caused the issue for core is a controversial hack.