pkgsrc-Bugs archive

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

Re: pkg/54192: lang/rust build error



The following reply was made to PR pkg/54192; it has been noted by GNATS.

From: coypu%sdf.org@localhost
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: pkg/54192: lang/rust build error
Date: Sat, 27 Jul 2019 06:33:05 +0000

 I think the lock implemented by _rtld_exclusive_enter is bogus.
 
         for (;;) {
                 if (atomic_cas_uint(&_rtld_mutex, 0, locked_value) == 0) {
                         membar_enter();
                         break;
                 }
 			/* Didn't get the lock */
 
                 waiter = atomic_swap_uint(&_rtld_waiter_exclusive, self);
                 membar_sync();
                 cur = _rtld_mutex;
                 if (cur == locked_value) {
 			/* Someone locked it. Die for no reason. */
                         _rtld_error("dead lock detected");
                         _rtld_die();
                 }
                 if (cur)
                         _lwp_park(CLOCK_REALTIME, 0, NULL, 0,
                             __UNVOLATILE(&_rtld_mutex), NULL);
                 atomic_cas_uint(&_rtld_waiter_exclusive, self, 0);
                 if (waiter)
                         _lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
 			/* Wake up other waiters for some reason.
 			   We saw the lock is still in use, so I don't understand why. */
         }
 
 
 I think the lock implemented by _rtld_shared_enter is bogus.
 
        for (;;) {
                 cur = _rtld_mutex;
                 /*
                  * First check if we are currently not exclusively locked.
                  */
                 if ((cur & RTLD_EXCLUSIVE_MASK) == 0) {
                         /* Yes, so increment use counter */
                         if (atomic_cas_uint(&_rtld_mutex, cur, cur + 1) != cur)
                                 continue;
                         membar_enter();
                         return;
                 }
                 /*
                  * Someone has an exclusive lock.  Puts us on the waiter list.
                  */
                 if (!self)
                         self = _lwp_self();
                 if (cur == (self | RTLD_EXCLUSIVE_MASK)) {
                         if (_rtld_mutex_may_recurse)
                                 return;
                         _rtld_error("dead lock detected");
                         _rtld_die();
                 }
 
 _rtld_mutex_may_recurse is false and never changed apparently.
 So our mechanism for handling exclusive -> shared lock seems bogus. I'm
 not sure, since I didn't successfully trigger it.
 
 Probably LD_BIND_NOW is a helpful hack.
 


Home | Main Index | Thread Index | Old Index