Skip to content

simple_mutex example does not work with pct strategy on master branch #12

@dmitrii-artuhov

Description

@dmitrii-artuhov

Problem

In master branch there is a bug with running simple mutex with pct.

  • In pct_strategy.h assertion has a bug in the way it is written:
    assert((max != std::numeric_limits<size_t>::min(), "all threads are empty or parked"));
    // operator `,` (comma) calculates lhs and returns rhs,
    // so this assertion is always true, since string literal is not empty 
    Correct assertion:
    assert((max != std::numeric_limits<size_t>::min() && "all threads are empty or parked"));
    // just put `&&`
  • With this fix, compiling cmake with debug config and running: LD_PRELOAD=build/syscall_intercept/libpreload.so ./build/verifying/blocking/simple_mutex --tasks 40 --strategy pct --verbose --rounds 100 throws an assertion violation:
    threads  = 2
    tasks    = 40
    switches = 100000000
    rounds   = 100
    targets  = 2
    strategy = pct
    
    
    run round: 0
    ==59036==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x7ffffffcc000; bottom 0x7ffff2bfe000; size: 0x00000d3ce000 (222093312)
    False positive error reports may follow
    For details see https://github.com/google/sanitizers/issues/189
    simple_mutex: /Ltest/runtime/include/pct_strategy.h:72: virtual TaskWithMetaData PctStrategy<Mutex, MutexVerifier>::Next() [TargetObj = Mutex, Verifier = MutexVerifier]: Assertion `(max != std::numeric_limits<size_t>::min() && "all threads are empty or parked")' failed.
    Aborted

Expected

  • No assertion violation and correct rounds execution

CC @Kirillog

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions