Skip to content

pthread_cond_timedwait: CLOCK_MONOTONIC hangs indefinitely #142

@tux21b

Description

@tux21b

I am really interested in the new pthread_cond_timedwait patches by @mliertzer since we have also already experience some issues with the previous libfaketime in combination with mysqld.

The compilation failed with a "possible uninitialized variable error" in libfaketime.c:2523, pthread_cond_timedwait_common() at int result;, therefore i changed the line to int result = 0;. Afterwards I was able to compile everything.

The following test case currently blocks indefinitely (when run from the test-suite) on Debian Jessie. That's the last output I see is:

$ LD_PRELOAD=../src/libfaketime.so.1 ./timetest
pthread_cond_timedwait: CLOCK_REALTIME test
(Intentionally sleeping 1 second...)
pthread_cond_timedwait: CLOCK_MONOTONIC test
(Intentionally sleeping 1 second...)

I have also tried executing the testcase directly. All programs where executed in a clean environment without any faketimerc files, faketime related enviornment variables or any global ld preload configuration. I have observed the following:

  • ./timetest works
  • LD_PRELOAD=../src/libfaketime.so.1 ./timetest blocks indefinitely
  • LD_PRELOAD=../src/libfaketime.so.1 FAKETIME= ./timetest works
  • LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=-2 ./timetest blocks indefinitely
  • LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=+2 ./timetest blocks indefinitely

The cases that didn't work, were blocking at the CLOCK_MONOTONIC test like described above. Setting DONT_FAKE_MONOTONIC=1 solves the issue.

What's the difference between the 2nd and the 3rd case? Shouldn't they be equivalent without any other environment variables or faketimerc files?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions