Bug 5024 - Solaris: nss_winbind.so with libthread breaks non-MT program
Solaris: nss_winbind.so with libthread breaks non-MT program
Status: NEW
Product: Samba 3.0
Classification: Unclassified
Component: winbind
3.0.34
Other Solaris
: P3 normal
: none
Assigned To: Samba Bugzilla Account
Samba QA Contact
:
Depends on: 1822
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-18 05:18 UTC by SATOH Fumiyasu
Modified: 2009-02-05 07:53 UTC (History)
0 users

See Also:


Attachments
Link libthread.so to libsmbclient.so only (2.96 KB, patch)
2007-10-18 05:22 UTC, SATOH Fumiyasu
no flags Details
Updated patch for 3.2.8 (v3-2-test) (Remove unnecessary -lthread flag only) (1.84 KB, patch)
2009-02-05 07:52 UTC, SATOH Fumiyasu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description SATOH Fumiyasu 2007-10-18 05:18:51 UTC
Old Solaris (9 and older) has libthread.so that overrides some
system calls with multithread(MT)-aware system calls. MT-aware
system calls cannot be used with non-MT system calls.

On the other hand, nss_winbid.so on Solaris is always linked with
libthread.so since Bugizlla Bug #1822 was fixed.

There is a problem that an non-MT program with nss_winbind.so
is broken after libthread.so loaded dynamically with nss_winbind.so.

The following truss output is an example (sshd):
(system call trace on Solaris 8 by `truss -u libc -d -f -p SSHD-PID`)

Line    PID   Timestamp System call (or function call)
     1  394:     4.0534 poll(0xFFBEFA18, 2, -1)                         = 1
      ...
(1) Start sshd process
   102  1784:    4.1060 execve("/opt/osstech/sbin/sshd", 0x001DDBA8, 0xFFBEFDCC)  argc = 2
      ...
(2) Call alarm(2) with 120 seconds
  7030  1784:    8.9072 -> libc:alarm(0x78, 0x7c948, 0xdf38, 0xffbefd54)
  7031  1784:    8.9080 alarm(120)                                      = 0
  7032  1784:    8.9084 <- libc:alarm() = 0
      ...
(3) Load nss_winbind.so (sshd process calls name service function)
 24516  1784:   19.9346 stat("/usr/lib/nss_winbind.so.1", 0xFFBECD38)   = 0
 24517  1784:   19.9348 resolvepath("/usr/lib/nss_winbind.so.1", "/usr/lib/nss_winbind.so.1", 1023) = 25
 24518  1784:   19.9351 open("/usr/lib/nss_winbind.so.1", O_RDONLY)     = 4
      ...
(4) Load libthread.so and override some systemcalls (nss_winbind.so linked with libthread.so)
 24529  1784:   19.9380 stat("/usr/lib/libthread.so.1", 0xFFBECC58)     = 0
 24530  1784:   19.9381 resolvepath("/usr/lib/libthread.so.1", "/usr/lib/libthread.so.1", 1023) = 23
 24531  1784:   19.9383 open("/usr/lib/libthread.so.1", O_RDONLY)       = 4
      ...
(5) Call alarm(2) with 0 seconds to disable alarm, but ...
 29667  1784/1:         23.0513 -> libc:alarm(0x0, 0x38, 0xffffffff, 0xffbefbfc)
 29668  1784:   23.0520 lwp_alarm(0)                                    = 0
 29669  1784/1:         23.0524 <- libc:alarm() = 0
      ...

  Note: lwp_alarm(2) is MT-version alarm(2) that cannot reset alarm
        set by normal (non-MT) alarm(2)!

(6) Start user shell (/bin/bash) by sshd
 50634  1792:   35.2380 execve("/bin/bash", 0xFFBEF6F8, 0x001DE788)  argc = 1
      ...
(7) SIGALRM occurs after 120 seconds because alarm is still activated.
222844  1784/2:         128.9169        -> libc:_lwp_sigredirect(0x1, 0xe, 0xfec0fc6c, 0xfec0fc68)
222845  1784:   128.9173        lwp_sigredirect(1, SIGALRM, 0xFEC0FC6C)         = 0
222846  1784:   128.9175            Received signal #14, SIGALRM, in read() [caught]
222847  1784/2:         128.9175        <- libc:_lwp_sigredirect() = 0
222848  1784/2:         128.9178        -> libc:_lwp_mutex_lock(0xfeebcf70, 0x1e08a18, 0xfec0fc6c, 0xfec0fc68)
222849  1784:   128.9182        read(5, 0xFFBEFACC, 4)                          Err#4 EINTR
      ...
222880  1784/1:         128.9279          -> libc:_exit(0x1, 0x0, 0x0, 0x0)
222881  1784:   128.9283        _exit(1)
      ...
(8) Finally, user shell exits unexpectedly!
Comment 1 SATOH Fumiyasu 2007-10-18 05:22:18 UTC
Created attachment 2944 [details]
Link libthread.so to libsmbclient.so only
Comment 2 SATOH Fumiyasu 2009-02-05 07:52:44 UTC
Created attachment 3924 [details]
Updated patch for 3.2.8 (v3-2-test) (Remove unnecessary -lthread flag only)

See also Bug #1822

libthread.so is not required for the thread-safe errno
because ___errno() is in libc.so, not in libthread.so.

$ uname -a
SunOS blade8 5.8 Generic_117350-49 sun4u sparc SUNW,Sun-Blade-100
$ /usr/ccs/bin/nm /lib/libc.so |grep ___errno
[4327]  |    621164|      56|FUNC |GLOB |0    |9      |___errno
$ /usr/ccs/bin/nm /lib/libthread.so |grep ___errno
[1153]  |         0|       0|FUNC |GLOB |0    |UNDEF  |___errno