Project

General

Profile

Actions

Bug #9959

closed

pthread_mutex_init should initialize mutex appropriately for robust mutex_init

Added by Rich Lowe almost 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2018-11-06
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

Sun mutexes expect that a mutex_t for a robust mutex be initialized to all 0 prior to mutex_init(), posix mutexes do not.
pthread_mutex_init() should 0 out any uninitialized mutex_t prior to calling mutex_t on it, if a robust mutex is requested.

Actions #1

Updated by Electric Monk almost 5 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 6da2547363ddbd247ee9513db83b05a31bca31af

commit  6da2547363ddbd247ee9513db83b05a31bca31af
Author: Richard Lowe <richlowe@richlowe.net>
Date:   2018-11-26T02:13:30.000Z

    9959 pthread_mutex_init should initialize mutex appropriately for robust mutex_init
    Reviewed by: Jason King <jason.king@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions #2

Updated by Gordon Ross about 1 year ago

There's a remaining problem with Samba 4.10.6 and later. See:
https://github.com/OpenIndiana/oi-userland/commit/89ed9275ee6c8c03f23f7cf7edb86af9b4e319b3
components/network/samba/patches/12-memset_for_pthread_mutex_init.patch
and later commits where that gets renamed a couple times:
components/network/samba/patches/12-memset_for_pthread_mutex_init.patch
components/network/samba/patches/10-memset_for_pthread_mutex_init.patch
components/network/samba/patches/09-memset_for_pthread_mutex_init.patch
components/network/samba/patches/06-memset_for_pthread_mutex_init.patch

Samba loads a TDB file at startup, mapping that file into memory.
In that file, there are pthread_mutex_t objects that were initialized by some previous TDB user and written out.
In this scenario, it's not clear what pthread_mutex_init() should do, but it returns EBUSY because the
mutex objects appear to be already initialized (they contain mutex_magic == MUTEX_MAGIC).

The Linux version of pthread_mutex_init appears to initialize unconditionally.
Perhaps we should do the same?

Actions

Also available in: Atom PDF