test: Fix use-after-free in scheduler tests #9186

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2016_11_scheduler_fix changing 1 files +4 −3
  1. laanwj commented at 12:13 PM on November 18, 2016: member

    Make a copy of the boost time-point to wait for, as the head of the queue may be deleted by another thread while this one is waiting, while the boost function still has a reference to it.

    Although this problem is in non-test code, this is not an actual problem outside of the tests because we use the thread scheduler with only one service thread, so there will never be threads fighting at the head of the queue.

    The old boost fallback escapes this problem because it passes a scalar value to wait_until instead of a const object reference.

    Found by running the bitcoin_test in LLVM-4.0-master asan. See also: https://svn.boost.org/trac/boost/ticket/11097#comment:10

  2. test: Fix use-after-free in scheduler tests
    Make a copy of the boost time-point to wait for, otherwise the head of
    the queue may be deleted by another thread while this one is waiting,
    while the boost function still has a reference to it.
    
    Although this problem is in non-test code, this is not an actual problem
    outside of the tests because we use the thread scheduler with only one
    service thread, so there will never be threads fighting at the head of
    the queue.
    
    The old boost fallback escapes this problem because it passes a scalar
    value to wait_until instead of a const object reference.
    
    Found by running the tests in LLVM-4.0-master asan.
    12519bf62b
  3. laanwj added the label Tests on Nov 18, 2016
  4. MarcoFalke commented at 3:29 PM on November 18, 2016: member

    utACK 12519bf

  5. gmaxwell commented at 10:50 AM on November 19, 2016: contributor

    utACK

  6. laanwj merged this on Nov 19, 2016
  7. laanwj closed this on Nov 19, 2016

  8. laanwj referenced this in commit ce612f1750 on Nov 19, 2016
  9. MarcoFalke referenced this in commit dccdc3aa34 on Nov 19, 2016
  10. codablock referenced this in commit c937a0bfb1 on Jan 15, 2018
  11. lateminer referenced this in commit 9a9a172210 on Oct 21, 2018
  12. andvgal referenced this in commit cb85bdca44 on Jan 6, 2019
  13. CryptoCentric referenced this in commit 0a99cdc253 on Feb 24, 2019
  14. MarcoFalke locked this on Sep 8, 2021
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me