From owner-freebsd-stable@FreeBSD.ORG Sat Mar 10 11:17:46 2007 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5731416A401; Sat, 10 Mar 2007 11:17:46 +0000 (UTC) (envelope-from mb@imp.ch) Received: from pop.imp.ch (mx2.imp.ch [157.161.9.17]) by mx1.freebsd.org (Postfix) with ESMTP id E9D6913C467; Sat, 10 Mar 2007 11:17:45 +0000 (UTC) (envelope-from mb@imp.ch) Received: from godot.imp.ch (godot.imp.ch [157.161.4.8]) by pop.imp.ch (8.13.8/8.13.8/Submit_imp) with ESMTP id l2ABHgKt001152; Sat, 10 Mar 2007 12:17:43 +0100 (CET) (envelope-from mb@imp.ch) Date: Sat, 10 Mar 2007 12:17:42 +0100 (CET) From: Martin Blapp To: ClamAV Development In-Reply-To: <1173106098.8193.6.camel@syntax.dstl.gov.uk> Message-ID: <20070310121342.I6787@godot.imp.ch> References: <20070305152453.H18301@godot.imp.ch> <1173106098.8193.6.camel@syntax.dstl.gov.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Daniel Eischen , freebsd-stable@freebsd.org Subject: Re: Clamav-90_2 Lockup with freebsd 6.2 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2007 11:17:46 -0000 Hi, > Don't use it, it's broken. > > -trog Nope, it looks like a race in cli_scanmail() which deadlocks somewhere with libpthread.so. This workaround fixes the problem for me. I'm still investigating where the real cause for this problem is. --- libclamav/scanners.c Tue Feb 13 02:06:28 2007 +++ libclamav/scanners.c Sat Mar 10 12:00:16 2007 @@ -38,6 +38,9 @@ #include #endif +# include +static pthread_mutex_t extractmail_mutex = PTHREAD_MUTEX_INITIALIZER; + #if HAVE_MMAP #if HAVE_SYS_MMAN_H #include @@ -1652,12 +1655,16 @@ /* * Extract the attachments into the temporary directory */ + pthread_mutex_lock(&extractmail_mutex); if((ret = cli_mbox(dir, desc, ctx))) { - if(!cli_leavetemps_flag) + if(!cli_leavetemps_flag) { + pthread_mutex_unlock(&extractmail_mutex); cli_rmdirs(dir); + } free(dir); return ret; } + pthread_mutex_unlock(&extractmail_mutex); ret = cli_scandir(dir, ctx);