Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-26 Thread Konstantin Belousov
On Sun, Jun 26, 2016 at 12:33:38AM +0200, Jilles Tjoelker wrote:
> To be bug-compatible with glibc, you'd need to return the wrong
> [EDEADLK] error for robust errorcheck mutexes only. Robust
> non-errorcheck and non-robust errorcheck mutexes return the correct
> [EBUSY]. I have not checked PI and PP mutexes which probably use a
> different code path.
Yes, you are right, I read the glibc code wrong way.

> I'm not sure whether we should copy glibc's bug, but if we do it must be
> documented in the man page. I'm not happy with it because the bug may
> break applications written to the standard; at least, Samba developers
> should be contacted first.

I tried to send the mail to samba tech list yesterday, but it did not pass.
Seems that today I managed it.

Still, it is pity that the only real-world consumer of the robust
interface cannot exercise our implementation due to this minor issue.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-26 Thread Tomoaki AOKI
> In message <20160625223338.GA22802 at stack.nl>, Jilles Tjoelker writes:
>> On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote:
>> > I already asked re for approval of the reversal and got it.  But I am still
>> > hesitating doing the revert vs. returning EDEADLK for error-checking
>> > mutexes.
>> 
>> > My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK
>> > returning EDEADLK as the requirement for both functions.  It was induced
>> > by reading the following code in samba:
>> > https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928
>> > I did extracted this into stand-alone test and checked that glibc does
>> > return EDEADLK in this case.  BTW, if somebody has Solaris machine availabl
>> e
>> > to test this, I would be grateful.  Code is available at
>> > https://www.kib.kiev.ua/kib/pshared/pthread_samba.c
>> 
>> > I.e., plain revert would disable the only known to me consumer of the
>> > robust mutexes. The patch which I mailed last time, returns EDEADLK for
>> > trylock on ERRORCHECKed mutexes only. And I am tending toward glibc
>> > compatibility there, over the literal POSIX compliance, but I want to
>> > see the confirmation from the Klimenko' test first.
>> 
>> To be bug-compatible with glibc, you'd need to return the wrong
>> [EDEADLK] error for robust errorcheck mutexes only. Robust
>> non-errorcheck and non-robust errorcheck mutexes return the correct
>> [EBUSY]. I have not checked PI and PP mutexes which probably use a
>> different code path.
>> 
>> I'm not sure whether we should copy glibc's bug, but if we do it must be
>> documented in the man page. I'm not happy with it because the bug may
>> break applications written to the standard; at least, Samba developers
>> should be contacted first.
>
> I think there are advantages both in POSIX and glibc compatibility
> however I think it more important to be POSIX compatible. Having said
> that, there may be a compromise. Either setting an environment variable
> and/or setting a global variable (or call a function) to invoke a
> glibc-bug emulation mode. Thus linux-only applications could be ported
> with minimally invasive alterations.
>
> Either we break POSIX compatibility (and some existing applications) or
> we can implement the above which may satisfy both camps.

It would be better fixing in ports and stay POSIX-compliant side.
For linux binaries, they would use glibc introduced by one of
linux_base-* port, so native libthr wouldn't be used. (Right?)

The problematic cases would be ported softwares primarily for Linux.
(Native binary)

Of course, the best way is to be cared inside each upstream.
(Check for glibc on configure stage, and do special care only if
needed.)
This case, we need no special care for this glibc quirks.


For FreeBSD community, there would be...

  1) Make new USES on ports framework for this regression.
  2) Patch (via files/* or REINPLACE_CMD) on each port needed.
 (No special care is needed for libthr itself.)

Unfortunately, 1) would be almost impossible without switching like you
mentioned, as methods for checking return value / error codes should
have tooo many patterns. :-(

System-wide setting wouldn't help, as there's possibilities that, for
example, console-kit (needs normal POSIX behaviour) and samba4 (needs
glibc quirks) can coexist.

IMHO, for per-binary settings, using ELF branding or alike to switch
would be better than using environment variables.

If we prefer environment variable, we'd need wrapper script especially
for pkg users, causing possible performance penalty (would be
significant for use-cases like filters). But using ELF branding, it's
stored inside the binary itself.


>
>
> -- 
> Cheers,
> Cy Schubert 
> FreeBSD UNIX: Web:  http://www.FreeBSD.org
>
>   The need of the many outweighs the greed of the few.

-- 
Tomoaki AOKIjunch...@dec.sakura.ne.jp
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Cy Schubert
In message <20160625223338.ga22...@stack.nl>, Jilles Tjoelker writes:
> On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote:
> > I already asked re for approval of the reversal and got it.  But I am still
> > hesitating doing the revert vs. returning EDEADLK for error-checking
> > mutexes.
> 
> > My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK
> > returning EDEADLK as the requirement for both functions.  It was induced
> > by reading the following code in samba:
> > https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928
> > I did extracted this into stand-alone test and checked that glibc does
> > return EDEADLK in this case.  BTW, if somebody has Solaris machine availabl
> e
> > to test this, I would be grateful.  Code is available at
> > https://www.kib.kiev.ua/kib/pshared/pthread_samba.c
> 
> > I.e., plain revert would disable the only known to me consumer of the
> > robust mutexes. The patch which I mailed last time, returns EDEADLK for
> > trylock on ERRORCHECKed mutexes only. And I am tending toward glibc
> > compatibility there, over the literal POSIX compliance, but I want to
> > see the confirmation from the Klimenko' test first.
> 
> To be bug-compatible with glibc, you'd need to return the wrong
> [EDEADLK] error for robust errorcheck mutexes only. Robust
> non-errorcheck and non-robust errorcheck mutexes return the correct
> [EBUSY]. I have not checked PI and PP mutexes which probably use a
> different code path.
> 
> I'm not sure whether we should copy glibc's bug, but if we do it must be
> documented in the man page. I'm not happy with it because the bug may
> break applications written to the standard; at least, Samba developers
> should be contacted first.

I think there are advantages both in POSIX and glibc compatibility however 
I think it more important to be POSIX compatible. Having said that, there 
may be a compromise. Either setting an environment variable and/or setting 
a global variable (or call a function) to invoke a glibc-bug emulation 
mode. Thus linux-only applications could be ported with minimally invasive 
alterations.

Either we break POSIX compatibility (and some existing applications) or we 
can implement the above which may satisfy both camps.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Jilles Tjoelker
On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote:
> I already asked re for approval of the reversal and got it.  But I am still
> hesitating doing the revert vs. returning EDEADLK for error-checking
> mutexes.

> My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK
> returning EDEADLK as the requirement for both functions.  It was induced
> by reading the following code in samba:
> https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928
> I did extracted this into stand-alone test and checked that glibc does
> return EDEADLK in this case.  BTW, if somebody has Solaris machine available
> to test this, I would be grateful.  Code is available at
> https://www.kib.kiev.ua/kib/pshared/pthread_samba.c

> I.e., plain revert would disable the only known to me consumer of the
> robust mutexes. The patch which I mailed last time, returns EDEADLK for
> trylock on ERRORCHECKed mutexes only. And I am tending toward glibc
> compatibility there, over the literal POSIX compliance, but I want to
> see the confirmation from the Klimenko' test first.

To be bug-compatible with glibc, you'd need to return the wrong
[EDEADLK] error for robust errorcheck mutexes only. Robust
non-errorcheck and non-robust errorcheck mutexes return the correct
[EBUSY]. I have not checked PI and PP mutexes which probably use a
different code path.

I'm not sure whether we should copy glibc's bug, but if we do it must be
documented in the man page. I'm not happy with it because the bug may
break applications written to the standard; at least, Samba developers
should be contacted first.

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Daniel Eischen

On Sat, 25 Jun 2016, Konstantin Belousov wrote:


On Sat, Jun 25, 2016 at 07:14:40PM +0200, Jilles Tjoelker wrote:

On Sat, Jun 25, 2016 at 11:30:40AM +, Konstantin Belousov wrote:

Author: kib
Date: Sat Jun 25 11:30:40 2016
New Revision: 302194
URL: https://svnweb.freebsd.org/changeset/base/302194



Log:
  For pthread_mutex_trylock() call on owned error-check or non-portable
  adaptive mutex, return EDEADLK as required by POSIX.  The
  pthread_mutex_lock() is already compliant.



  Tested by:Guy Yur 
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Approved by:  re (gjb)



Modified:
  head/lib/libthr/thread/thr_mutex.c



Modified: head/lib/libthr/thread/thr_mutex.c
==
--- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 10:08:04 2016
(r302193)
+++ head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 11:30:40 2016
(r302194)
@@ -850,9 +850,12 @@ mutex_self_trylock(struct pthread_mutex

switch (PMUTEX_TYPE(m->m_flags)) {
case PTHREAD_MUTEX_ERRORCHECK:
-   case PTHREAD_MUTEX_NORMAL:
case PTHREAD_MUTEX_ADAPTIVE_NP:
-   ret = EBUSY;
+   ret = EDEADLK;
+   break;
+
+   case PTHREAD_MUTEX_NORMAL:
+   ret = EBUSY;
break;

case PTHREAD_MUTEX_RECURSIVE:


I think POSIX (SUSv4tc1, XSH 3 pthread_mutex_lock) is clear that only
pthread_mutex_lock() can fail with [EDEADLK], not
pthread_mutex_trylock(). Instead, the error [EBUSY] listed for
pthread_mutex_trylock() applies whenever the mutex could not be acquired
because it was already locked. This includes the case where the mutex is
owned by the current thread. Note that POSIX intends to allow not
storing the owning thread's ID in non-recursive non-robust mutexes.

Failing pthread_mutex_trylock() on owned mutexes only with [EBUSY] also
matches our code before this commit and NetBSD's code, and is apparently
expected by other code.

Therefore, I think this commit should be reverted.



I already asked re for approval of the reversal and got it.  But I am still
hesitating doing the revert vs. returning EDEADLK for error-checking
mutexes.

My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK
returning EDEADLK as the requirement for both functions.  It was induced
by reading the following code in samba:
https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928
I did extracted this into stand-alone test and checked that glibc does
return EDEADLK in this case.  BTW, if somebody has Solaris machine available
to test this, I would be grateful.  Code is available at
https://www.kib.kiev.ua/kib/pshared/pthread_samba.c

I.e., plain revert would disable the only known to me consumer of the
robust mutexes. The patch which I mailed last time, returns EDEADLK for
trylock on ERRORCHECKed mutexes only. And I am tending toward glibc
compatibility there, over the literal POSIX compliance, but I want to
see the confirmation from the Klimenko' test first.


That doesn't make glibc correct.  Unless the standards change,
we should return EBUSY in this case.  It is also unexpected if an
implementation's default mutex scheme is PTHREAD_MUTEX_ERRORCHECK
and it returns EDEADLK in this case.  It's not mentioned in the
standard, and no portable application will be expecting it.

--
DE
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 21:06:57 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 09:05:43PM +0300, Konstantin Belousov wrote:
> > On Sat, Jun 25, 2016 at 08:43:17PM +0300, Ivan Klymenko wrote:  
> > > ./thr_mutex_test
> > > thr_mutex_test: mutex_trylock 2: No error: 0  
> > 
> > Ok, there is a bug in my test, it must use errc(3) and not err(3).
> > Please retest wth the updated code below.  But I am sure that you
> > would see EDEADLK (Resource deadlock avoided) error, which means
> > that you have wrong, i.e. unpatched libthr, installed.
> > 
> > For me, the output is 
> > sandy% ./pthread_errrecurse
> > sandy% echo $?
> > 0
> >   
> Err, the updated test.
> 
> /* $Id: pthread_errrecurse.c,v 1.2 2016/06/25 18:02:54 kostik Exp
> kostik $ */
> 
> #include 
> #include 
> #include 
> 
> int
> main(void)
> {
>   pthread_mutex_t m;
>   pthread_mutexattr_t ma;
>   int error;
> 
>   error = pthread_mutexattr_init(&ma);
>   if (error != 0)
>   errc(1, error, "mutexattr_init");
>   error = pthread_mutexattr_settype(&ma,
> PTHREAD_MUTEX_ADAPTIVE_NP); if (error != 0)
>   errc(1, error, "mutexattr_settype");
>   error = pthread_mutex_init(&m, &ma);
>   if (error != 0)
>   errc(1, error, "mutex_init");
>   error = pthread_mutex_trylock(&m);
>   if (error != 0)
>   errc(1, error, "mutex_trylock 1");
>   error = pthread_mutex_trylock(&m);
>   if (error != EBUSY)
>   errc(1, error, "mutex_trylock 2");
>   else if (error == 0)
>   errx(1, "mutex_trylock 2 succeeded");
>   return (0);
> }

1. Patched & installed libthr r302195
2. test for other soft:
mousepad 
GLib (gthread-posix.c): Unexpected error from C library during
'pthread_mutex_trylock': Уникнуто взаємне блокування ресурсів.
Aborting. Аварійне завершення(записано core)
3.test new ./thr_mutex_test 
thr_mutex_test: mutex_trylock 2: No error: 0
4. restore patch & install original libthr r302195
5. test for other soft:
mousepad
GLib (gthread-posix.c): Unexpected error from C library during
'pthread_mutex_trylock': Уникнуто взаємне блокування ресурсів.
Aborting. Аварійне завершення(записано core)
6. test new ./thr_mutex_test 
thr_mutex_test: mutex_trylock 2: No error: 0
7. restore & install libthr r302191
8. test for other soft:
mousepad - complete run
9. test new ./thr_mutex_test 
thr_mutex_test: mutex_trylock 2: No error: 0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 09:05:43PM +0300, Konstantin Belousov wrote:
> On Sat, Jun 25, 2016 at 08:43:17PM +0300, Ivan Klymenko wrote:
> > ./thr_mutex_test
> > thr_mutex_test: mutex_trylock 2: No error: 0
> 
> Ok, there is a bug in my test, it must use errc(3) and not err(3).  Please
> retest wth the updated code below.  But I am sure that you would see
> EDEADLK (Resource deadlock avoided) error, which means that you have
> wrong, i.e. unpatched libthr, installed.
> 
> For me, the output is 
> sandy% ./pthread_errrecurse
> sandy% echo $?
> 0
> 
Err, the updated test.

/* $Id: pthread_errrecurse.c,v 1.2 2016/06/25 18:02:54 kostik Exp kostik $ */

#include 
#include 
#include 

int
main(void)
{
pthread_mutex_t m;
pthread_mutexattr_t ma;
int error;

error = pthread_mutexattr_init(&ma);
if (error != 0)
errc(1, error, "mutexattr_init");
error = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ADAPTIVE_NP);
if (error != 0)
errc(1, error, "mutexattr_settype");
error = pthread_mutex_init(&m, &ma);
if (error != 0)
errc(1, error, "mutex_init");
error = pthread_mutex_trylock(&m);
if (error != 0)
errc(1, error, "mutex_trylock 1");
error = pthread_mutex_trylock(&m);
if (error != EBUSY)
errc(1, error, "mutex_trylock 2");
else if (error == 0)
errx(1, "mutex_trylock 2 succeeded");
return (0);
}

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 08:43:17PM +0300, Ivan Klymenko wrote:
> ./thr_mutex_test
> thr_mutex_test: mutex_trylock 2: No error: 0

Ok, there is a bug in my test, it must use errc(3) and not err(3).  Please
retest wth the updated code below.  But I am sure that you would see
EDEADLK (Resource deadlock avoided) error, which means that you have
wrong, i.e. unpatched libthr, installed.

For me, the output is 
sandy% ./pthread_errrecurse
sandy% echo $?
0

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 19:16:15 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 07:03:46PM +0300, Ivan Klymenko wrote:
> > On Sat, 25 Jun 2016 18:20:06 +0300
> > Konstantin Belousov  wrote:  
> > > diff --git a/lib/libthr/thread/thr_mutex.c
> > > b/lib/libthr/thread/thr_mutex.c index 2ad05ca..1ae75fb 100644
> > > --- a/lib/libthr/thread/thr_mutex.c
> > > +++ b/lib/libthr/thread/thr_mutex.c
> > > @@ -850,10 +871,10 @@ mutex_self_trylock(struct pthread_mutex *m)
> > >  
> > >   switch (PMUTEX_TYPE(m->m_flags)) {
> > >   case PTHREAD_MUTEX_ERRORCHECK:
> > > - case PTHREAD_MUTEX_ADAPTIVE_NP:
> > >   ret = EDEADLK;
> > >   break;
> > >  
> > > + case PTHREAD_MUTEX_ADAPTIVE_NP:
> > >   case PTHREAD_MUTEX_NORMAL:
> > >   ret = EBUSY;
> > >   break;  
> > 
> > Strange, it's not helped http://pastebin.com/jbzP0JW2  
> 
> Are you sure that the new libthr was installed ?  Compile and run the
> following test, please, and show me the results.  On the patched
> libthr, the program must not output anything and exits with error
> code 0.
> 
> /* $Id: pthread_errrecurse.c,v 1.1 2016/06/25 16:12:41 kostik Exp
> kostik $ */
> 
> #include 
> #include 
> #include 
> 
> int
> main(void)
> {
>   pthread_mutex_t m;
>   pthread_mutexattr_t ma;
>   int error;
> 
>   error = pthread_mutexattr_init(&ma);
>   if (error != 0)
>   err(1, "mutexattr_init");
>   error = pthread_mutexattr_settype(&ma,
> PTHREAD_MUTEX_ADAPTIVE_NP); if (error != 0)
>   err(1, "mutexattr_settype");
>   error = pthread_mutex_init(&m, &ma);
>   if (error != 0)
>   err(1, "mutex_init");
>   error = pthread_mutex_trylock(&m);
>   if (error != 0)
>   err(1, "mutex_trylock 1");
>   error = pthread_mutex_trylock(&m);
>   if (error != EBUSY)
>   err(1, "mutex_trylock 2");
>   else if (error == 0)
>   errx(1, "mutex_trylock 2 succeeded");
>   return (0);
> }
> 

./thr_mutex_test
thr_mutex_test: mutex_trylock 2: No error: 0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 07:14:40PM +0200, Jilles Tjoelker wrote:
> On Sat, Jun 25, 2016 at 11:30:40AM +, Konstantin Belousov wrote:
> > Author: kib
> > Date: Sat Jun 25 11:30:40 2016
> > New Revision: 302194
> > URL: https://svnweb.freebsd.org/changeset/base/302194
> 
> > Log:
> >   For pthread_mutex_trylock() call on owned error-check or non-portable
> >   adaptive mutex, return EDEADLK as required by POSIX.  The
> >   pthread_mutex_lock() is already compliant.
> 
> >   Tested by:Guy Yur 
> >   Sponsored by: The FreeBSD Foundation
> >   MFC after:2 weeks
> >   Approved by:  re (gjb)
> 
> > Modified:
> >   head/lib/libthr/thread/thr_mutex.c
> 
> > Modified: head/lib/libthr/thread/thr_mutex.c
> > ==
> > --- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 10:08:04 2016
> > (r302193)
> > +++ head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 11:30:40 2016
> > (r302194)
> > @@ -850,9 +850,12 @@ mutex_self_trylock(struct pthread_mutex 
> >  
> > switch (PMUTEX_TYPE(m->m_flags)) {
> > case PTHREAD_MUTEX_ERRORCHECK:
> > -   case PTHREAD_MUTEX_NORMAL:
> > case PTHREAD_MUTEX_ADAPTIVE_NP:
> > -   ret = EBUSY; 
> > +   ret = EDEADLK;
> > +   break;
> > +
> > +   case PTHREAD_MUTEX_NORMAL:
> > +   ret = EBUSY;
> > break;
> >  
> > case PTHREAD_MUTEX_RECURSIVE:
> 
> I think POSIX (SUSv4tc1, XSH 3 pthread_mutex_lock) is clear that only
> pthread_mutex_lock() can fail with [EDEADLK], not
> pthread_mutex_trylock(). Instead, the error [EBUSY] listed for
> pthread_mutex_trylock() applies whenever the mutex could not be acquired
> because it was already locked. This includes the case where the mutex is
> owned by the current thread. Note that POSIX intends to allow not
> storing the owning thread's ID in non-recursive non-robust mutexes.
> 
> Failing pthread_mutex_trylock() on owned mutexes only with [EBUSY] also
> matches our code before this commit and NetBSD's code, and is apparently
> expected by other code.
> 
> Therefore, I think this commit should be reverted.
> 

I already asked re for approval of the reversal and got it.  But I am still
hesitating doing the revert vs. returning EDEADLK for error-checking
mutexes.

My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK
returning EDEADLK as the requirement for both functions.  It was induced
by reading the following code in samba:
https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928
I did extracted this into stand-alone test and checked that glibc does
return EDEADLK in this case.  BTW, if somebody has Solaris machine available
to test this, I would be grateful.  Code is available at
https://www.kib.kiev.ua/kib/pshared/pthread_samba.c

I.e., plain revert would disable the only known to me consumer of the
robust mutexes. The patch which I mailed last time, returns EDEADLK for
trylock on ERRORCHECKed mutexes only. And I am tending toward glibc
compatibility there, over the literal POSIX compliance, but I want to
see the confirmation from the Klimenko' test first.

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Jilles Tjoelker
On Sat, Jun 25, 2016 at 11:30:40AM +, Konstantin Belousov wrote:
> Author: kib
> Date: Sat Jun 25 11:30:40 2016
> New Revision: 302194
> URL: https://svnweb.freebsd.org/changeset/base/302194

> Log:
>   For pthread_mutex_trylock() call on owned error-check or non-portable
>   adaptive mutex, return EDEADLK as required by POSIX.  The
>   pthread_mutex_lock() is already compliant.

>   Tested by:  Guy Yur 
>   Sponsored by:   The FreeBSD Foundation
>   MFC after:  2 weeks
>   Approved by:re (gjb)

> Modified:
>   head/lib/libthr/thread/thr_mutex.c

> Modified: head/lib/libthr/thread/thr_mutex.c
> ==
> --- head/lib/libthr/thread/thr_mutex.cSat Jun 25 10:08:04 2016
> (r302193)
> +++ head/lib/libthr/thread/thr_mutex.cSat Jun 25 11:30:40 2016
> (r302194)
> @@ -850,9 +850,12 @@ mutex_self_trylock(struct pthread_mutex 
>  
>   switch (PMUTEX_TYPE(m->m_flags)) {
>   case PTHREAD_MUTEX_ERRORCHECK:
> - case PTHREAD_MUTEX_NORMAL:
>   case PTHREAD_MUTEX_ADAPTIVE_NP:
> - ret = EBUSY; 
> + ret = EDEADLK;
> + break;
> +
> + case PTHREAD_MUTEX_NORMAL:
> + ret = EBUSY;
>   break;
>  
>   case PTHREAD_MUTEX_RECURSIVE:

I think POSIX (SUSv4tc1, XSH 3 pthread_mutex_lock) is clear that only
pthread_mutex_lock() can fail with [EDEADLK], not
pthread_mutex_trylock(). Instead, the error [EBUSY] listed for
pthread_mutex_trylock() applies whenever the mutex could not be acquired
because it was already locked. This includes the case where the mutex is
owned by the current thread. Note that POSIX intends to allow not
storing the owning thread's ID in non-recursive non-robust mutexes.

Failing pthread_mutex_trylock() on owned mutexes only with [EBUSY] also
matches our code before this commit and NetBSD's code, and is apparently
expected by other code.

Therefore, I think this commit should be reverted.

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Daniel Eischen

On Sat, 25 Jun 2016, Konstantin Belousov wrote:


On Sat, Jun 25, 2016 at 07:03:46PM +0300, Ivan Klymenko wrote:

On Sat, 25 Jun 2016 18:20:06 +0300
Konstantin Belousov  wrote:

diff --git a/lib/libthr/thread/thr_mutex.c
b/lib/libthr/thread/thr_mutex.c index 2ad05ca..1ae75fb 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -850,10 +871,10 @@ mutex_self_trylock(struct pthread_mutex *m)

switch (PMUTEX_TYPE(m->m_flags)) {
case PTHREAD_MUTEX_ERRORCHECK:
-   case PTHREAD_MUTEX_ADAPTIVE_NP:
ret = EDEADLK;
break;

+   case PTHREAD_MUTEX_ADAPTIVE_NP:
case PTHREAD_MUTEX_NORMAL:
ret = EBUSY;
break;


Strange, it's not helped http://pastebin.com/jbzP0JW2


Are you sure that the new libthr was installed ?  Compile and run the
following test, please, and show me the results.  On the patched libthr,
the program must not output anything and exits with error code 0.


Sorry for not noticing and coming in late, but I think the
original change is wrong.  I don't see in the 2013 POSIX spec
or Solaris 11 man page (haven't checked Linux yet) where
pthread_mutex_trylock() returns EDEADLK under any
circumstance.

  
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_trylock.html
  
http://docs.oracle.com/cd/E23824_01/html/821-1465/pthread-mutex-trylock-3c.html#scrolltoc

--
DE
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 07:03:46PM +0300, Ivan Klymenko wrote:
> On Sat, 25 Jun 2016 18:20:06 +0300
> Konstantin Belousov  wrote:
> > diff --git a/lib/libthr/thread/thr_mutex.c
> > b/lib/libthr/thread/thr_mutex.c index 2ad05ca..1ae75fb 100644
> > --- a/lib/libthr/thread/thr_mutex.c
> > +++ b/lib/libthr/thread/thr_mutex.c
> > @@ -850,10 +871,10 @@ mutex_self_trylock(struct pthread_mutex *m)
> >  
> > switch (PMUTEX_TYPE(m->m_flags)) {
> > case PTHREAD_MUTEX_ERRORCHECK:
> > -   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > ret = EDEADLK;
> > break;
> >  
> > +   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > case PTHREAD_MUTEX_NORMAL:
> > ret = EBUSY;
> > break;
> 
> Strange, it's not helped http://pastebin.com/jbzP0JW2

Are you sure that the new libthr was installed ?  Compile and run the
following test, please, and show me the results.  On the patched libthr,
the program must not output anything and exits with error code 0.

/* $Id: pthread_errrecurse.c,v 1.1 2016/06/25 16:12:41 kostik Exp kostik $ */

#include 
#include 
#include 

int
main(void)
{
pthread_mutex_t m;
pthread_mutexattr_t ma;
int error;

error = pthread_mutexattr_init(&ma);
if (error != 0)
err(1, "mutexattr_init");
error = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ADAPTIVE_NP);
if (error != 0)
err(1, "mutexattr_settype");
error = pthread_mutex_init(&m, &ma);
if (error != 0)
err(1, "mutex_init");
error = pthread_mutex_trylock(&m);
if (error != 0)
err(1, "mutex_trylock 1");
error = pthread_mutex_trylock(&m);
if (error != EBUSY)
err(1, "mutex_trylock 2");
else if (error == 0)
errx(1, "mutex_trylock 2 succeeded");
return (0);
}

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 18:20:06 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 05:55:03PM +0300, Ivan Klymenko wrote:
> > On Sat, 25 Jun 2016 17:29:15 +0300
> > Konstantin Belousov  wrote:
> >   
> > > On Sat, Jun 25, 2016 at 05:18:00PM +0300, Ivan Klymenko wrote:  
> > > > On Sat, 25 Jun 2016 17:05:29 +0300
> > > > Konstantin Belousov  wrote:
> > > > 
> > > > > On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko
> > > > > wrote:
> > > > > > On Sat, 25 Jun 2016 16:55:09 +0300
> > > > > > Konstantin Belousov  wrote:
> > > > > >   
> > > > > > > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko
> > > > > > > wrote:  
> > > > > > > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > > > > > > Konstantin Belousov  wrote:
> > > > > > > > 
> > > > > > > > > Author: kib
> > > > > > > > > Date: Sat Jun 25 11:30:40 2016
> > > > > > > > > New Revision: 302194
> > > > > > > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > > > > > > 
> > > > > > > > > Log:
> > > > > > > > >   For pthread_mutex_trylock() call on owned
> > > > > > > > > error-check or non-portable adaptive mutex, return
> > > > > > > > > EDEADLK as required by POSIX.  The
> > > > > > > > > pthread_mutex_lock() is already compliant. 
> > > > > > > > >   Tested by:  Guy Yur 
> > > > > > > > >   Sponsored by:   The FreeBSD Foundation
> > > > > > > > >   MFC after:  2 weeks
> > > > > > > > >   Approved by:re (gjb)
> > > > > > > > > 
> > > > > > > > > Modified:
> > > > > > > > >   head/lib/libthr/thread/thr_mutex.c
> > > > > > > > > 
> > > > > > > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > > > > > > ==
> > > > > > > > > --- head/lib/libthr/thread/thr_mutex.cSat Jun
> > > > > > > > > 25 10:08:04 2016  (r302193) +++
> > > > > > > > > head/lib/libthr/thread/thr_mutex.c Sat Jun 25 11:30:40
> > > > > > > > > 2016  (r302194) @@ -850,9 +850,12 @@
> > > > > > > > > mutex_self_trylock(struct pthread_mutex switch
> > > > > > > > > (PMUTEX_TYPE(m->m_flags)) { case
> > > > > > > > > PTHREAD_MUTEX_ERRORCHECK:
> > > > > > > > > - case PTHREAD_MUTEX_NORMAL:
> > > > > > > > >   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > > > > > > - ret = EBUSY; 
> > > > > > > > > + ret = EDEADLK;
> > > > > > > > > + break;
> > > > > > > > > +
> > > > > > > > > + case PTHREAD_MUTEX_NORMAL:
> > > > > > > > > + ret = EBUSY;
> > > > > > > > >   break;
> > > > > > > > >  
> > > > > > > > >   case PTHREAD_MUTEX_RECURSIVE:
> > > > > > > > 
> > > > > > > > Update for r302191 to r302196 console-kit-daemon:
> > > > > > > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > > 
> > > > > > > > Xorg session after authorization not started - black
> > > > > > > > screen.
> > > > > > > 
> > > > > > > Why did you replied to r302194 with this information ?
> > > > > > > Does reverting r302194 (and only this revision) restores
> > > > > > > console-kit functionality ?  
> > > > > > 
> > > > > > I do not know which one commits it breaks r302194 or next
> > > > > > 302195. I returned to r302191 for restores console-kit
> > > > > > functionality.  
> > > > > Can you test, please ?  Use r302195 kernel and previous
> > > > > libthr.
> > > > 
> > > > Kernel r302195, world r302191 - works fine - the problem can not
> > > > reproduce.
> > > 
> > > Thank you.
> > > 
> > > Could you get backtrace from the console-kit-daemon ?  Only
> > > rebuild libthr: cd src/lib/libthr && make DEBUG_FLAGS=-g
> > > WITHOUT_TESTS=yes all install then gather coredump and load it in
> > > gdb.  Then you can revert the commit and rebuild working libthr.
> > >   
> > 
> > http://pastebin.com/wgmmicC3 If this information will be useful.  
> 
> Yes, it is useful, thank you.  Please try this instead of reverting.
> 
> diff --git a/lib/libthr/thread/thr_mutex.c
> b/lib/libthr/thread/thr_mutex.c index 2ad05ca..1ae75fb 100644
> --- a/lib/libthr/thread/thr_mutex.c
> +++ b/lib/libthr/thread/thr_mutex.c
> @@ -850,10 +871,10 @@ mutex_self_trylock(struct pthread_mutex *m)
>  
>   switch (PMUTEX_TYPE(m->m_flags)) {
>   case PTHREAD_MUTEX_ERRORCHECK:
> - case PTHREAD_MUTEX_ADAPTIVE_NP:
>   ret = EDEADLK;
>   break;
>  
> + case PTHREAD_MUTEX_ADAPTIVE_NP:
>   case PTHREAD_MUTEX_NORMAL:
>   ret = EBUSY;
>   break;

Strange, it's not helped http://pastebin.com/jbzP0JW2
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head

Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 05:55:03PM +0300, Ivan Klymenko wrote:
> On Sat, 25 Jun 2016 17:29:15 +0300
> Konstantin Belousov  wrote:
> 
> > On Sat, Jun 25, 2016 at 05:18:00PM +0300, Ivan Klymenko wrote:
> > > On Sat, 25 Jun 2016 17:05:29 +0300
> > > Konstantin Belousov  wrote:
> > >   
> > > > On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko wrote:  
> > > > > On Sat, 25 Jun 2016 16:55:09 +0300
> > > > > Konstantin Belousov  wrote:
> > > > > 
> > > > > > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko
> > > > > > wrote:
> > > > > > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > > > > > Konstantin Belousov  wrote:
> > > > > > >   
> > > > > > > > Author: kib
> > > > > > > > Date: Sat Jun 25 11:30:40 2016
> > > > > > > > New Revision: 302194
> > > > > > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > > > > > 
> > > > > > > > Log:
> > > > > > > >   For pthread_mutex_trylock() call on owned error-check or
> > > > > > > > non-portable adaptive mutex, return EDEADLK as required by
> > > > > > > > POSIX.  The pthread_mutex_lock() is already compliant.
> > > > > > > >   
> > > > > > > >   Tested by:Guy Yur 
> > > > > > > >   Sponsored by: The FreeBSD Foundation
> > > > > > > >   MFC after:2 weeks
> > > > > > > >   Approved by:  re (gjb)
> > > > > > > > 
> > > > > > > > Modified:
> > > > > > > >   head/lib/libthr/thread/thr_mutex.c
> > > > > > > > 
> > > > > > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > > > > > ==
> > > > > > > > --- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25
> > > > > > > > 10:08:04 2016   (r302193) +++
> > > > > > > > head/lib/libthr/thread/thr_mutex.c Sat Jun 25 11:30:40
> > > > > > > > 2016(r302194) @@ -850,9 +850,12 @@
> > > > > > > > mutex_self_trylock(struct pthread_mutex switch
> > > > > > > > (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK:
> > > > > > > > -   case PTHREAD_MUTEX_NORMAL:
> > > > > > > > case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > > > > > -   ret = EBUSY; 
> > > > > > > > +   ret = EDEADLK;
> > > > > > > > +   break;
> > > > > > > > +
> > > > > > > > +   case PTHREAD_MUTEX_NORMAL:
> > > > > > > > +   ret = EBUSY;
> > > > > > > > break;
> > > > > > > >  
> > > > > > > > case PTHREAD_MUTEX_RECURSIVE:  
> > > > > > > 
> > > > > > > Update for r302191 to r302196 console-kit-daemon:
> > > > > > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > > 
> > > > > > > Xorg session after authorization not started - black
> > > > > > > screen.  
> > > > > > 
> > > > > > Why did you replied to r302194 with this information ?  Does
> > > > > > reverting r302194 (and only this revision) restores
> > > > > > console-kit functionality ?
> > > > > 
> > > > > I do not know which one commits it breaks r302194 or next
> > > > > 302195. I returned to r302191 for restores console-kit
> > > > > functionality.
> > > > Can you test, please ?  Use r302195 kernel and previous libthr.  
> > > 
> > > Kernel r302195, world r302191 - works fine - the problem can not
> > > reproduce.  
> > 
> > Thank you.
> > 
> > Could you get backtrace from the console-kit-daemon ?  Only rebuild
> > libthr: cd src/lib/libthr && make DEBUG_FLAGS=-g WITHOUT_TESTS=yes
> > all install then gather coredump and load it in gdb.  Then you can
> > revert the commit and rebuild working libthr.
> > 
> 
> http://pastebin.com/wgmmicC3 If this information will be useful.

Yes, it is useful, thank you.  Please try this instead of reverting.

diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 2ad05ca..1ae75fb 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -850,10 +871,10 @@ mutex_self_trylock(struct pthread_mutex *m)
 
switch (PMUTEX_TYPE(m->m_flags)) {
case PTHREAD_MUTEX_ERRORCHECK:
-   case PTHREAD_MUTEX_ADAPTIVE_NP:
ret = EDEADLK;
break;
 
+   case PTHREAD_MUTEX_ADAPTIVE_NP:
case PTHREAD_MUTEX_NORMAL:
ret = EBUSY;
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 17:29:15 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 05:18:00PM +0300, Ivan Klymenko wrote:
> > On Sat, 25 Jun 2016 17:05:29 +0300
> > Konstantin Belousov  wrote:
> >   
> > > On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko wrote:  
> > > > On Sat, 25 Jun 2016 16:55:09 +0300
> > > > Konstantin Belousov  wrote:
> > > > 
> > > > > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko
> > > > > wrote:
> > > > > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > > > > Konstantin Belousov  wrote:
> > > > > >   
> > > > > > > Author: kib
> > > > > > > Date: Sat Jun 25 11:30:40 2016
> > > > > > > New Revision: 302194
> > > > > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > > > > 
> > > > > > > Log:
> > > > > > >   For pthread_mutex_trylock() call on owned error-check or
> > > > > > > non-portable adaptive mutex, return EDEADLK as required by
> > > > > > > POSIX.  The pthread_mutex_lock() is already compliant.
> > > > > > >   
> > > > > > >   Tested by:  Guy Yur 
> > > > > > >   Sponsored by:   The FreeBSD Foundation
> > > > > > >   MFC after:  2 weeks
> > > > > > >   Approved by:re (gjb)
> > > > > > > 
> > > > > > > Modified:
> > > > > > >   head/lib/libthr/thread/thr_mutex.c
> > > > > > > 
> > > > > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > > > > ==
> > > > > > > --- head/lib/libthr/thread/thr_mutex.cSat Jun 25
> > > > > > > 10:08:04 2016 (r302193) +++
> > > > > > > head/lib/libthr/thread/thr_mutex.c Sat Jun 25 11:30:40
> > > > > > > 2016  (r302194) @@ -850,9 +850,12 @@
> > > > > > > mutex_self_trylock(struct pthread_mutex switch
> > > > > > > (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK:
> > > > > > > - case PTHREAD_MUTEX_NORMAL:
> > > > > > >   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > > > > - ret = EBUSY; 
> > > > > > > + ret = EDEADLK;
> > > > > > > + break;
> > > > > > > +
> > > > > > > + case PTHREAD_MUTEX_NORMAL:
> > > > > > > + ret = EBUSY;
> > > > > > >   break;
> > > > > > >  
> > > > > > >   case PTHREAD_MUTEX_RECURSIVE:  
> > > > > > 
> > > > > > Update for r302191 to r302196 console-kit-daemon:
> > > > > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > > > > 
> > > > > > Xorg session after authorization not started - black
> > > > > > screen.  
> > > > > 
> > > > > Why did you replied to r302194 with this information ?  Does
> > > > > reverting r302194 (and only this revision) restores
> > > > > console-kit functionality ?
> > > > 
> > > > I do not know which one commits it breaks r302194 or next
> > > > 302195. I returned to r302191 for restores console-kit
> > > > functionality.
> > > Can you test, please ?  Use r302195 kernel and previous libthr.  
> > 
> > Kernel r302195, world r302191 - works fine - the problem can not
> > reproduce.  
> 
> Thank you.
> 
> Could you get backtrace from the console-kit-daemon ?  Only rebuild
> libthr: cd src/lib/libthr && make DEBUG_FLAGS=-g WITHOUT_TESTS=yes
> all install then gather coredump and load it in gdb.  Then you can
> revert the commit and rebuild working libthr.
> 

http://pastebin.com/wgmmicC3 If this information will be useful.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 05:18:00PM +0300, Ivan Klymenko wrote:
> On Sat, 25 Jun 2016 17:05:29 +0300
> Konstantin Belousov  wrote:
> 
> > On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko wrote:
> > > On Sat, 25 Jun 2016 16:55:09 +0300
> > > Konstantin Belousov  wrote:
> > >   
> > > > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko wrote:  
> > > > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > > > Konstantin Belousov  wrote:
> > > > > 
> > > > > > Author: kib
> > > > > > Date: Sat Jun 25 11:30:40 2016
> > > > > > New Revision: 302194
> > > > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > > > 
> > > > > > Log:
> > > > > >   For pthread_mutex_trylock() call on owned error-check or
> > > > > > non-portable adaptive mutex, return EDEADLK as required by
> > > > > > POSIX.  The pthread_mutex_lock() is already compliant.
> > > > > >   
> > > > > >   Tested by:Guy Yur 
> > > > > >   Sponsored by: The FreeBSD Foundation
> > > > > >   MFC after:2 weeks
> > > > > >   Approved by:  re (gjb)
> > > > > > 
> > > > > > Modified:
> > > > > >   head/lib/libthr/thread/thr_mutex.c
> > > > > > 
> > > > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > > > ==
> > > > > > --- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25
> > > > > > 10:08:04 2016   (r302193) +++
> > > > > > head/lib/libthr/thread/thr_mutex.c Sat Jun 25 11:30:40
> > > > > > 2016(r302194) @@ -850,9 +850,12 @@
> > > > > > mutex_self_trylock(struct pthread_mutex switch
> > > > > > (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK:
> > > > > > -   case PTHREAD_MUTEX_NORMAL:
> > > > > > case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > > > -   ret = EBUSY; 
> > > > > > +   ret = EDEADLK;
> > > > > > +   break;
> > > > > > +
> > > > > > +   case PTHREAD_MUTEX_NORMAL:
> > > > > > +   ret = EBUSY;
> > > > > > break;
> > > > > >  
> > > > > > case PTHREAD_MUTEX_RECURSIVE:
> > > > > 
> > > > > Update for r302191 to r302196 console-kit-daemon:
> > > > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > > > 
> > > > > Xorg session after authorization not started - black screen.
> > > > 
> > > > Why did you replied to r302194 with this information ?  Does
> > > > reverting r302194 (and only this revision) restores console-kit
> > > > functionality ?  
> > > 
> > > I do not know which one commits it breaks r302194 or next 302195.
> > > I returned to r302191 for restores console-kit functionality.  
> > Can you test, please ?  Use r302195 kernel and previous libthr.
> 
> Kernel r302195, world r302191 - works fine - the problem can not
> reproduce.

Thank you.

Could you get backtrace from the console-kit-daemon ?  Only rebuild libthr:
   cd src/lib/libthr && make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all install
then gather coredump and load it in gdb.  Then you can revert the commit
and rebuild working libthr.

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 17:05:29 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko wrote:
> > On Sat, 25 Jun 2016 16:55:09 +0300
> > Konstantin Belousov  wrote:
> >   
> > > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko wrote:  
> > > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > > Konstantin Belousov  wrote:
> > > > 
> > > > > Author: kib
> > > > > Date: Sat Jun 25 11:30:40 2016
> > > > > New Revision: 302194
> > > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > > 
> > > > > Log:
> > > > >   For pthread_mutex_trylock() call on owned error-check or
> > > > > non-portable adaptive mutex, return EDEADLK as required by
> > > > > POSIX.  The pthread_mutex_lock() is already compliant.
> > > > >   
> > > > >   Tested by:  Guy Yur 
> > > > >   Sponsored by:   The FreeBSD Foundation
> > > > >   MFC after:  2 weeks
> > > > >   Approved by:re (gjb)
> > > > > 
> > > > > Modified:
> > > > >   head/lib/libthr/thread/thr_mutex.c
> > > > > 
> > > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > > ==
> > > > > --- head/lib/libthr/thread/thr_mutex.cSat Jun 25
> > > > > 10:08:04 2016 (r302193) +++
> > > > > head/lib/libthr/thread/thr_mutex.c Sat Jun 25 11:30:40
> > > > > 2016  (r302194) @@ -850,9 +850,12 @@
> > > > > mutex_self_trylock(struct pthread_mutex switch
> > > > > (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK:
> > > > > - case PTHREAD_MUTEX_NORMAL:
> > > > >   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > > - ret = EBUSY; 
> > > > > + ret = EDEADLK;
> > > > > + break;
> > > > > +
> > > > > + case PTHREAD_MUTEX_NORMAL:
> > > > > + ret = EBUSY;
> > > > >   break;
> > > > >  
> > > > >   case PTHREAD_MUTEX_RECURSIVE:
> > > > 
> > > > Update for r302191 to r302196 console-kit-daemon:
> > > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > > 
> > > > Xorg session after authorization not started - black screen.
> > > 
> > > Why did you replied to r302194 with this information ?  Does
> > > reverting r302194 (and only this revision) restores console-kit
> > > functionality ?  
> > 
> > I do not know which one commits it breaks r302194 or next 302195.
> > I returned to r302191 for restores console-kit functionality.  
> Can you test, please ?  Use r302195 kernel and previous libthr.

Kernel r302195, world r302191 - works fine - the problem can not
reproduce.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 05:04:06PM +0300, Ivan Klymenko wrote:
> On Sat, 25 Jun 2016 16:55:09 +0300
> Konstantin Belousov  wrote:
> 
> > On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko wrote:
> > > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > > Konstantin Belousov  wrote:
> > >   
> > > > Author: kib
> > > > Date: Sat Jun 25 11:30:40 2016
> > > > New Revision: 302194
> > > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > > 
> > > > Log:
> > > >   For pthread_mutex_trylock() call on owned error-check or
> > > > non-portable adaptive mutex, return EDEADLK as required by
> > > > POSIX.  The pthread_mutex_lock() is already compliant.
> > > >   
> > > >   Tested by:Guy Yur 
> > > >   Sponsored by: The FreeBSD Foundation
> > > >   MFC after:2 weeks
> > > >   Approved by:  re (gjb)
> > > > 
> > > > Modified:
> > > >   head/lib/libthr/thread/thr_mutex.c
> > > > 
> > > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > > ==
> > > > --- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 10:08:04
> > > > 2016(r302193) +++ head/lib/libthr/thread/thr_mutex.c
> > > > Sat Jun 25 11:30:40 2016(r302194) @@ -850,9 +850,12 @@
> > > > mutex_self_trylock(struct pthread_mutex 
> > > > switch (PMUTEX_TYPE(m->m_flags)) {
> > > > case PTHREAD_MUTEX_ERRORCHECK:
> > > > -   case PTHREAD_MUTEX_NORMAL:
> > > > case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > > -   ret = EBUSY; 
> > > > +   ret = EDEADLK;
> > > > +   break;
> > > > +
> > > > +   case PTHREAD_MUTEX_NORMAL:
> > > > +   ret = EBUSY;
> > > > break;
> > > >  
> > > > case PTHREAD_MUTEX_RECURSIVE:  
> > > 
> > > Update for r302191 to r302196 console-kit-daemon:
> > > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > > 
> > > Xorg session after authorization not started - black screen.  
> > 
> > Why did you replied to r302194 with this information ?  Does reverting
> > r302194 (and only this revision) restores console-kit functionality ?
> 
> I do not know which one commits it breaks r302194 or next 302195.
> I returned to r302191 for restores console-kit functionality.
Can you test, please ?  Use r302195 kernel and previous libthr.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 16:55:09 +0300
Konstantin Belousov  wrote:

> On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko wrote:
> > On Sat, 25 Jun 2016 11:30:40 + (UTC)
> > Konstantin Belousov  wrote:
> >   
> > > Author: kib
> > > Date: Sat Jun 25 11:30:40 2016
> > > New Revision: 302194
> > > URL: https://svnweb.freebsd.org/changeset/base/302194
> > > 
> > > Log:
> > >   For pthread_mutex_trylock() call on owned error-check or
> > > non-portable adaptive mutex, return EDEADLK as required by
> > > POSIX.  The pthread_mutex_lock() is already compliant.
> > >   
> > >   Tested by:  Guy Yur 
> > >   Sponsored by:   The FreeBSD Foundation
> > >   MFC after:  2 weeks
> > >   Approved by:re (gjb)
> > > 
> > > Modified:
> > >   head/lib/libthr/thread/thr_mutex.c
> > > 
> > > Modified: head/lib/libthr/thread/thr_mutex.c
> > > ==
> > > --- head/lib/libthr/thread/thr_mutex.cSat Jun 25 10:08:04
> > > 2016  (r302193) +++ head/lib/libthr/thread/thr_mutex.c
> > > Sat Jun 25 11:30:40 2016  (r302194) @@ -850,9 +850,12 @@
> > > mutex_self_trylock(struct pthread_mutex 
> > >   switch (PMUTEX_TYPE(m->m_flags)) {
> > >   case PTHREAD_MUTEX_ERRORCHECK:
> > > - case PTHREAD_MUTEX_NORMAL:
> > >   case PTHREAD_MUTEX_ADAPTIVE_NP:
> > > - ret = EBUSY; 
> > > + ret = EDEADLK;
> > > + break;
> > > +
> > > + case PTHREAD_MUTEX_NORMAL:
> > > + ret = EBUSY;
> > >   break;
> > >  
> > >   case PTHREAD_MUTEX_RECURSIVE:  
> > 
> > Update for r302191 to r302196 console-kit-daemon:
> > pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> > pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> > pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> > pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> > pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> > 
> > Xorg session after authorization not started - black screen.  
> 
> Why did you replied to r302194 with this information ?  Does reverting
> r302194 (and only this revision) restores console-kit functionality ?

I do not know which one commits it breaks r302194 or next 302195.
I returned to r302191 for restores console-kit functionality.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
On Sat, Jun 25, 2016 at 04:44:03PM +0300, Ivan Klymenko wrote:
> On Sat, 25 Jun 2016 11:30:40 + (UTC)
> Konstantin Belousov  wrote:
> 
> > Author: kib
> > Date: Sat Jun 25 11:30:40 2016
> > New Revision: 302194
> > URL: https://svnweb.freebsd.org/changeset/base/302194
> > 
> > Log:
> >   For pthread_mutex_trylock() call on owned error-check or
> > non-portable adaptive mutex, return EDEADLK as required by POSIX.  The
> >   pthread_mutex_lock() is already compliant.
> >   
> >   Tested by:Guy Yur 
> >   Sponsored by: The FreeBSD Foundation
> >   MFC after:2 weeks
> >   Approved by:  re (gjb)
> > 
> > Modified:
> >   head/lib/libthr/thread/thr_mutex.c
> > 
> > Modified: head/lib/libthr/thread/thr_mutex.c
> > ==
> > --- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 10:08:04
> > 2016(r302193) +++ head/lib/libthr/thread/thr_mutex.c
> > Sat Jun 25 11:30:40 2016(r302194) @@ -850,9 +850,12 @@
> > mutex_self_trylock(struct pthread_mutex 
> > switch (PMUTEX_TYPE(m->m_flags)) {
> > case PTHREAD_MUTEX_ERRORCHECK:
> > -   case PTHREAD_MUTEX_NORMAL:
> > case PTHREAD_MUTEX_ADAPTIVE_NP:
> > -   ret = EBUSY; 
> > +   ret = EDEADLK;
> > +   break;
> > +
> > +   case PTHREAD_MUTEX_NORMAL:
> > +   ret = EBUSY;
> > break;
> >  
> > case PTHREAD_MUTEX_RECURSIVE:
> 
> Update for r302191 to r302196 console-kit-daemon:
> pid 1496 (console-kit-daemon), uid 0: exited on signal 6
> pid 1581 (console-kit-daemon), uid 0: exited on signal 6
> pid 5954 (console-kit-daemon), uid 0: exited on signal 6
> pid 6010 (console-kit-daemon), uid 0: exited on signal 6
> pid 6016 (console-kit-daemon), uid 0: exited on signal 6
> 
> Xorg session after authorization not started - black screen.

Why did you replied to r302194 with this information ?  Does reverting
r302194 (and only this revision) restores console-kit functionality ?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Ivan Klymenko
On Sat, 25 Jun 2016 11:30:40 + (UTC)
Konstantin Belousov  wrote:

> Author: kib
> Date: Sat Jun 25 11:30:40 2016
> New Revision: 302194
> URL: https://svnweb.freebsd.org/changeset/base/302194
> 
> Log:
>   For pthread_mutex_trylock() call on owned error-check or
> non-portable adaptive mutex, return EDEADLK as required by POSIX.  The
>   pthread_mutex_lock() is already compliant.
>   
>   Tested by:  Guy Yur 
>   Sponsored by:   The FreeBSD Foundation
>   MFC after:  2 weeks
>   Approved by:re (gjb)
> 
> Modified:
>   head/lib/libthr/thread/thr_mutex.c
> 
> Modified: head/lib/libthr/thread/thr_mutex.c
> ==
> --- head/lib/libthr/thread/thr_mutex.cSat Jun 25 10:08:04
> 2016  (r302193) +++ head/lib/libthr/thread/thr_mutex.c
> Sat Jun 25 11:30:40 2016  (r302194) @@ -850,9 +850,12 @@
> mutex_self_trylock(struct pthread_mutex 
>   switch (PMUTEX_TYPE(m->m_flags)) {
>   case PTHREAD_MUTEX_ERRORCHECK:
> - case PTHREAD_MUTEX_NORMAL:
>   case PTHREAD_MUTEX_ADAPTIVE_NP:
> - ret = EBUSY; 
> + ret = EDEADLK;
> + break;
> +
> + case PTHREAD_MUTEX_NORMAL:
> + ret = EBUSY;
>   break;
>  
>   case PTHREAD_MUTEX_RECURSIVE:

Update for r302191 to r302196 console-kit-daemon:
pid 1496 (console-kit-daemon), uid 0: exited on signal 6
pid 1581 (console-kit-daemon), uid 0: exited on signal 6
pid 5954 (console-kit-daemon), uid 0: exited on signal 6
pid 6010 (console-kit-daemon), uid 0: exited on signal 6
pid 6016 (console-kit-daemon), uid 0: exited on signal 6

Xorg session after authorization not started - black screen.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302194 - head/lib/libthr/thread

2016-06-25 Thread Konstantin Belousov
Author: kib
Date: Sat Jun 25 11:30:40 2016
New Revision: 302194
URL: https://svnweb.freebsd.org/changeset/base/302194

Log:
  For pthread_mutex_trylock() call on owned error-check or non-portable
  adaptive mutex, return EDEADLK as required by POSIX.  The
  pthread_mutex_lock() is already compliant.
  
  Tested by:Guy Yur 
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Approved by:  re (gjb)

Modified:
  head/lib/libthr/thread/thr_mutex.c

Modified: head/lib/libthr/thread/thr_mutex.c
==
--- head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 10:08:04 2016
(r302193)
+++ head/lib/libthr/thread/thr_mutex.c  Sat Jun 25 11:30:40 2016
(r302194)
@@ -850,9 +850,12 @@ mutex_self_trylock(struct pthread_mutex 
 
switch (PMUTEX_TYPE(m->m_flags)) {
case PTHREAD_MUTEX_ERRORCHECK:
-   case PTHREAD_MUTEX_NORMAL:
case PTHREAD_MUTEX_ADAPTIVE_NP:
-   ret = EBUSY; 
+   ret = EDEADLK;
+   break;
+
+   case PTHREAD_MUTEX_NORMAL:
+   ret = EBUSY;
break;
 
case PTHREAD_MUTEX_RECURSIVE:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"