pthread_mutex_trylock used to return EDEADLK and returns EBUSY

34 views
Skip to first unread message

achr...@gmail.com

unread,
Nov 15, 2016, 10:09:33 AM11/15/16
to android-ndk
I have a number of verification in DEBUG builds that a mutex is properly acquired

#ifdef DEBUG
  int r = pthread_mutex_trylock(&stm->mutex);
  assert((r == EDEADLK) && "mutex should be locked.");
#endif

This worked well till 4.3 but when I am running the same code in Android 6 the assert is hit and the reason is that now try lock methods returns EBUSY. According to the standard EBUSY is the most appropriate for that case and only pthread_mutex_lock() can return EDEADLK.

Can anyone verify that in Android 6, the return value of try lock method, changed to EBUSY in case of deadlock, when in earlier versions return EDEADLK? (or I am doing something wrong)

Dan Albert

unread,
Nov 15, 2016, 1:47:29 PM11/15/16
to android-ndk
I don't remember off the top of my head, but it sounds familiar.

Git log for bionic can be found here: https://android.googlesource.com/platform/bionic/+/marshmallow-release

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/a8460842-a827-4668-be4d-1a1dc478cfe7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages