[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#849717: marked as done (Wrong return value from pthread_mutex_trylock)



Your message dated Fri, 31 Aug 2018 13:56:27 +0200
with message-id <f20a2e662dff30e7a44e224b5ccbd419735add9a.camel@physics.uu.se>
and subject line Closing
has caused the Debian Bug report #849717,
regarding Wrong return value from pthread_mutex_trylock
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
849717: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849717
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Source: libc0.3-dev
Version: 2.24-8
Severity: important

According to the documentation (man page) for pthread_mutex_trylock:

The pthread_mutex_trylock() function shall be equivalent to
pthread_mutex_lock(), except that if the mutex object referenced by
mutex is currently locked (by any thread, including the current
thread), the call shall return immediately.

RETURN VALUE
  The pthread_mutex_trylock() function shall fail if:

  EBUSY  The mutex could not be acquired because it was already locked.

Here is a short test program


#include <pthread.h>
#include <stdio.h>
#include <errno.h>

int main() {
  pthread_mutex_t m;
  int i;
  printf("%s: %i\n", "EBUSY", EBUSY);
  printf("%s: %i\n", "EAGAIN", EAGAIN);

  i = pthread_mutex_init(&m, NULL);
  printf("%s: %i\n", "init", i);
  i = pthread_mutex_lock(&m);
  printf("%s: %i\n", "lock", i);
  i = pthread_mutex_trylock(&m);
  printf("%s: %i\n", "trylock", i);
  i = pthread_mutex_unlock(&m);
  printf("%s: %i\n", "unlock", i);
  i = pthread_mutex_destroy(&m);
  printf("%s: %i\n", "destroy", i);
}


On Linux this behaves according to the documentation:

EBUSY: 16
EAGAIN: 11
init: 0
lock: 0
trylock: 16
unlock: 0
destroy: 0

I.e. the trylock on the already locked mutex returns EBUSY.

On Hurd the following happens:

EBUSY: 1073741840
EAGAIN: 1073741859
init: 0
lock: 0
trylock: -1
unlock: 0
destroy: 0

I.e. the trylock on the already locked mutex returns -1 instead.

This causes programs using GLib to abort execution:

GLib (gthread-posix.c): Unexpected error from C library during
'pthread_mutex_trylock': Error in unknown error system: FFFFFFFF. 
Aborting.
Aborted

	Mattias

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---
--- Begin Message ---
This was fixed by the patch
debian/patches/hurd-i386/git-libpthread-trylock.diff
introduces in version 2.27-0experimental1 and 2.27-1

Closing bug.

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---

Reply to: