Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-13 23:57 UTC

Thread

Milter Greylist's use of POSIX threads is seriously broken

Milter Greylist's use of POSIX threads is seriously broken

2004-06-07 by Matthias Scheler

Hello,

I cannot get Milter Greylist to work with NetBSD 2.0's pthread library.
It dies very quickly because of incorrect use of POSIX thread functions,
apparently because of uninitialized condition variables:

maillog:Jun  7 20:58:22 colwyn milter-greylist: pthread_cond_wait failed: Undefined error: 0 

If I start it with "-D" it comes up. But it dies like this on shutdown:

milter-greylist: Error detected by libpthread: Destroying locked mutex.
Detected by file "pthread_mutex.c", line 135, function "pthread_mutex_destroy".
See pthread(3) for information.
zsh: abort      /usr/pkg/bin/milter-greylist -D -p /var/milter-greylist/milter-greylist.sock 

This happens with version 1.2 and 1.3.8. Right now Milter Greylist is
completely broken under NetBSD 2.0 and above.

	Kind regards

-- 
Matthias Scheler                                  http://scheler.de/~matthias/

Re: [milter-greylist] Milter Greylist's use of POSIX threads is seriously broken

2004-06-07 by manu@netbsd.org

Matthias Scheler <tron@...> wrote:

> maillog:Jun  7 20:58:22 colwyn milter-greylist: pthread_cond_wait failed:
> Undefined error: 0

How do you explain the errno being equal to 0?
 
> If I start it with "-D" it comes up. But it dies like this on shutdown:
> 
> milter-greylist: Error detected by libpthread: Destroying locked mutex.
> Detected by file "pthread_mutex.c", line 135, function
> "pthread_mutex_destroy". See pthread(3) for information. zsh: abort
> /usr/pkg/bin/milter-greylist -D -p
> /var/milter-greylist/milter-greylist.sock

Um, okay, I wasn't aware it was forbidden to destroy a locked mutex. But
I have a good excuse for that: I never destroyed a mutex in
milter-greyist code. Have you got an idea where is this comming from?
(Yes, I have a NetBSD-current at home and I could be looking into this
problem, but I'm also trying to get my iBook G4 supported by NetBSD, it
consumes some time :o)

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@...

Re: [milter-greylist] Milter Greylist's use of POSIX threads is seriously broken

2004-06-07 by Matthias Scheler

On Mon, Jun 07, 2004 at 10:16:29PM +0200, Emmanuel Dreyfus wrote:
> > maillog:Jun  7 20:58:22 colwyn milter-greylist: pthread_cond_wait failed:
> > Undefined error: 0
> How do you explain the errno being equal to 0?

Bad result checking?

And there more error in version 1.2 which I don't have at hand any more.

> > If I start it with "-D" it comes up. But it dies like this on shutdown:
> > 
> > milter-greylist: Error detected by libpthread: Destroying locked mutex.
> > Detected by file "pthread_mutex.c", line 135, function
> > "pthread_mutex_destroy". See pthread(3) for information. zsh: abort
> > /usr/pkg/bin/milter-greylist -D -p
> > /var/milter-greylist/milter-greylist.sock
> 
> Um, okay, I wasn't aware it was forbidden to destroy a locked mutex. But
> I have a good excuse for that: I never destroyed a mutex in
> milter-greyist code. Have you got an idea where is this comming from?

No, I'm still investigating.

	Kind regards

-- 
Matthias Scheler                                  http://scheler.de/~matthias/

Re: [milter-greylist] Milter Greylist's use of POSIX threads is seriously broken

2004-06-07 by manu@netbsd.org

Matthias Scheler <tron@...> wrote:

> > How do you explain the errno being equal to 0? 
> Bad result checking? 

It looks okay:

$ grep cond_wait *
dump.c:                 if (pthread_cond_wait(&dump_sleepflag, &mutex) != 0)
dump.c:                     syslog(LOG_ERR, "pthread_cond_wait failed: %s\n",
sync.c:         if (pthread_cond_wait(&sync_sleepflag, &mutex) != 0)
sync.c:                 syslog(LOG_ERR, "pthread_cond_wait failed: %s\n", 

So pthread_cond_wait retunrs != 0 and doesn't set errno. I removed the return
value check in pthread_*_init for exactly the same reason. 

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@...

Re: [milter-greylist] Milter Greylist's use of POSIX threads is seriously broken

2004-06-07 by Matthias Scheler

On Mon, Jun 07, 2004 at 10:39:07PM +0200, Emmanuel Dreyfus wrote:
> $ grep cond_wait *
> dump.c:                 if (pthread_cond_wait(&dump_sleepflag, &mutex) != 0)
> dump.c:                     syslog(LOG_ERR, "pthread_cond_wait failed: %s\n",

The error is one the line below:

                case 0:
                        if (pthread_cond_wait(&dump_sleepflag, &mutex) != 0)
                            syslog(LOG_ERR, "pthread_cond_wait failed: %s\n",
                                strerror(errno));
                                         ^^^^^

> So pthread_cond_wait retunrs != 0 and doesn't set errno. I removed the return
> value check in pthread_*_init for exactly the same reason. 

pthread_cond_wait() does *not* set "errno". Please check the manual page
under either Solaris or NetBSD. The error number is returned instead.
So the code should read:

                case 0: {
			int error;

			error = pthread_cond_wait(&dump_sleepflag, &mutex);
                        if (error != 0)
                            syslog(LOG_ERR, "pthread_cond_wait failed: %s\n",
                                strerror(error));
		}

Please check also for uninitialized condition variables because that's
what "libpthread" complained about in Milter Greylist 1.2.

	Kind regards

-- 
Matthias Scheler                                  http://scheler.de/~matthias/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.