[AGENT++] AGENT++ 4.1.2 the PTHREAD_MUTEX_ERRORCHECK does not work right?

Claus Klein claus.klein at arcormail.de
Mon Oct 1 10:34:06 CEST 2018


Hi

I have a simple test suit to check the agent++ behavior on the interface of src/thread.cpp:

BOOST_AUTO_TEST_CASE(Synchronized_test)
{
    using namespace Agentpp;
    Synchronized sync;
    {
        BOOST_TEST(sync.lock());
        BOOST_TEST(sync.trylock() == Synchronized::OWNED);
        BOOST_TEST(sync.unlock());
        BOOST_TEST(!sync.unlock(), "to much unlock() called without error");
    }
    BOOST_TEST(!sync.unlock());
}

BOOST_AUTO_TEST_CASE(Trylock_test)
{
    using namespace Agentpp;
    Synchronized sync;
    {
        Lock l(sync);
        BOOST_TEST(sync.trylock() == Synchronized::OWNED);
    }
    BOOST_TEST(!sync.unlock());
}

BOOST_AUTO_TEST_CASE(Wait_test)
{
    using namespace Agentpp;
    Synchronized sync;
    {
        Lock l(sync);
        BOOST_TEST(sync.lock(), "no recusive lock detected!");
        BOOST_TEST(sync.lock(123), "no timeout occurred!");
        BOOST_TEST(sync.wait(42), „no timeout occurred on wait!“);
    }
}


This is the result:
20181001.10:16:36: 140735159709696: (1)WARNING: Thread: thread not running (tid): (123145302691840)
threads_test.cpp:320: error: in "Synchronized_test": check sync.trylock() == Synchronized::OWNED has failed [0 != -1]
20181001.10:16:36: 140735159709696: (1)WARNING: Synchronized: unlock failed (id)(error)(wasLocked): (28), (1), (0)
20181001.10:16:36: 140735159709696: (1)WARNING: Synchronized: unlock failed (id)(error)(wasLocked): (28), (1), (0)
threads_test.cpp:333: error: in "Trylock_test": check sync.trylock() == Synchronized::OWNED has failed [0 != -1]
20181001.10:16:36: 140735159709696: (1)WARNING: Synchronized: unlock failed (id)(error)(wasLocked): (29), (1), (0)
20181001.10:16:36: 140735159709696: (5)WARNING: Synchronized: recursive lock detected (id)!: (30)
threads_test.cpp:345: error: in "Wait_test": no timeout occurred!

Is the expectation wrong?

With AGENTPP_PTHREAD_RECURSIVE defined, my test works fine on my macbook with:

Darwin Claus-MBP.fritz.box 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64 x86_64 i386 MacBookPro5,1 Darwin

Best regards
Claus



More information about the AGENTPP mailing list