From owner-freebsd-threads@FreeBSD.ORG Sun Sep 19 02:34:35 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B19D516A4CE; Sun, 19 Sep 2004 02:34:35 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6911243D45; Sun, 19 Sep 2004 02:34:35 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i8J2YWJE028156; Sat, 18 Sep 2004 21:34:32 -0500 (CDT) (envelope-from dan) Date: Sat, 18 Sep 2004 21:34:32 -0500 From: Dan Nelson To: timh@tjhawkins.com Message-ID: <20040919023432.GA7981@dan.emsphone.com> References: <010801c49dee$72cc5eb0$6401a8c0@yourw92p4bhlzg> <1095546154.671.6.camel@elemental.DashEvil> <010e01c49df0$a5b79400$6401a8c0@yourw92p4bhlzg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <010e01c49df0$a5b79400$6401a8c0@yourw92p4bhlzg> X-OS: FreeBSD 5.3-BETA4 X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-threads@freebsd.org Subject: Re: Please explain. X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Sep 2004 02:34:36 -0000 In the last episode (Sep 18), timh@tjhawkins.com said: > Your taking it the wrong way, I was simply asking a question to the > developers to confirm this. > > I have standardized on FreeBSD. > > I apologized if I made it seem like I was trolling, not my intention. > > If a business were to standardize on FreeBSD, they would love to know if the > multithreading issues would be fixed completely correctly not just > 'work-arounds'. So far you have only mentioned the word "issues". Do you have a particular one in mind? Maybe your questions would be better answered on the freebsd-threads list. Make sure you include your OS version, threads library you are using, the application you are using, and your specific problem. CC: redirected appropriately. -- Dan Nelson dnelson@allantgroup.com From owner-freebsd-threads@FreeBSD.ORG Mon Sep 20 11:02:28 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2678316A4D4 for ; Mon, 20 Sep 2004 11:02:28 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0230F43D48 for ; Mon, 20 Sep 2004 11:02:28 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i8KB2RnP001540 for ; Mon, 20 Sep 2004 11:02:27 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8KB2P4E001534 for freebsd-threads@freebsd.org; Mon, 20 Sep 2004 11:02:25 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 20 Sep 2004 11:02:25 GMT Message-Id: <200409201102.i8KB2P4E001534@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Sep 2004 11:02:28 -0000 Current FreeBSD problem reports Critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2004/04/22] threads/65883threads libkse's sigwait does not work after fork 1 problem total. Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/07/18] kern/20016 threads pthreads: Cannot set scheduling timer/Can o [2000/08/26] kern/20861 threads libc_r does not honor socket timeouts o [2001/01/20] threads/24472threads libc_r does not honor SO_SNDTIMEO/SO_RCVT o [2001/01/25] threads/24632threads libc_r delicate deviation from libc in ha o [2001/01/25] kern/24641 threads pthread_rwlock_rdlock can deadlock o [2001/11/26] bin/32295 threads pthread dont dequeue signals o [2002/02/01] threads/34536threads accept() blocks other threads o [2002/05/25] kern/38549 threads the procces compiled whith pthread stoppe o [2002/06/27] threads/39922threads [PATCH?] Threaded applications executed w o [2002/08/04] kern/41331 threads Pthread library open sets O_NONBLOCK flag o [2003/03/02] threads/48856threads Setting SIGCHLD to SIG_IGN still leaves z o [2003/03/10] threads/49087threads Signals lost in programs linked with libc o [2003/05/08] threads/51949threads thread in accept cannot be cancelled s [2004/03/15] kern/64313 threads FreeBSD (OpenBSD) pthread implicit set/un o [2004/08/26] threads/70975threads unexpected and unreliable behaviour when o [2004/09/14] threads/71725threads Mysql Crashes frequently giving Sock Erro 16 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/05/26] kern/18824 threads gethostbyname is not thread safe o [2000/06/13] kern/19247 threads uthread_sigaction.c does not do anything o [2000/10/21] kern/22190 threads A threaded read(2) from a socketpair(2) f o [2001/09/09] threads/30464threads pthread mutex attributes -- pshared o [2002/05/02] threads/37676threads libc_r: msgsnd(), msgrcv(), pread(), pwri s [2002/07/16] threads/40671threads pthread_cancel doesn't remove thread from o [2004/07/13] threads/69020threads pthreads library leaks _gc_mutex 7 problems total. From owner-freebsd-threads@FreeBSD.ORG Tue Sep 21 10:40:19 2004 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A78A16A4CE for ; Tue, 21 Sep 2004 10:40:19 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7258B43D55 for ; Tue, 21 Sep 2004 10:40:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i8LAeJOR038248 for ; Tue, 21 Sep 2004 10:40:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8LAeJNq038200; Tue, 21 Sep 2004 10:40:19 GMT (envelope-from gnats) Resent-Date: Tue, 21 Sep 2004 10:40:19 GMT Resent-Message-Id: <200409211040.i8LAeJNq038200@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, aude Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3AE6916A4CE for ; Tue, 21 Sep 2004 10:32:26 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2517B43D4C for ; Tue, 21 Sep 2004 10:32:26 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i8LAWPm6049620 for ; Tue, 21 Sep 2004 10:32:25 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.11/8.12.11/Submit) id i8LAWPfX049619; Tue, 21 Sep 2004 10:32:25 GMT (envelope-from nobody) Message-Id: <200409211032.i8LAWPfX049619@www.freebsd.org> Date: Tue, 21 Sep 2004 10:32:25 GMT From: aude To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: threads/71966: Mlnet Core Dumped : Fatal error '_pq_insert_head: prioq not protected!' X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 10:40:19 -0000 >Number: 71966 >Category: threads >Synopsis: Mlnet Core Dumped : Fatal error '_pq_insert_head: prioq not protected!' >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 21 10:40:18 GMT 2004 >Closed-Date: >Last-Modified: >Originator: aude >Release: 5.2 >Organization: >Environment: FreeBSD aude.brozs.net 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #1: Fri Aug 13 19:17:15 CEST 2004 root@aude.brozs.net:/usr/src/sys/i386/compile/AUDE i386 >Description: Running mlnet from a pre compiled version, after a while I've got this issue : Fatal error '_pq_insert_head: prioq not protected!' at line 185 in file /usr/src/lib/libc_r/uthread/uthread_priority_queue.c (errno = 22) Abort (core dumped) >How-To-Repeat: use mlnet2.5-21g.tar.gz version just run ./mlnet >Fix: >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-threads@FreeBSD.ORG Tue Sep 21 11:00:46 2004 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 81F1716A4CE for ; Tue, 21 Sep 2004 11:00:46 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7863543D48 for ; Tue, 21 Sep 2004 11:00:46 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i8LB0kCJ040667 for ; Tue, 21 Sep 2004 11:00:46 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8LB0ke0040666; Tue, 21 Sep 2004 11:00:46 GMT (envelope-from gnats) Date: Tue, 21 Sep 2004 11:00:46 GMT Message-Id: <200409211100.i8LB0ke0040666@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Daniel Eischen Subject: Re: threads/71966: Mlnet Core Dumped : Fatal error'_pq_insert_head: prioq not protected!' X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 11:00:46 -0000 The following reply was made to PR threads/71966; it has been noted by GNATS. From: Daniel Eischen To: aude Cc: freebsd-gnats-submit@freebsd.org Subject: Re: threads/71966: Mlnet Core Dumped : Fatal error '_pq_insert_head: prioq not protected!' Date: Tue, 21 Sep 2004 06:57:54 -0400 (EDT) On Tue, 21 Sep 2004, aude wrote: > > Running mlnet from a pre compiled version, after a while I've got this issue : > > Fatal error '_pq_insert_head: prioq not protected!' at line 185 in file /usr/src/lib/libc_r/uthread/uthread_priority_queue.c (errno = 22) > Abort (core dumped) Show 'ldd mlnet' please. > >How-To-Repeat: > use mlnet2.5-21g.tar.gz version > just run ./mlnet What precompiled version? Is this a port? Where did you get it. From owner-freebsd-threads@FreeBSD.ORG Tue Sep 21 13:35:55 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B71416A4CE for ; Tue, 21 Sep 2004 13:35:55 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 977DD43D4C for ; Tue, 21 Sep 2004 13:35:54 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8LDZoeT030087 for ; Tue, 21 Sep 2004 17:35:52 +0400 Message-ID: <41502E36.8070403@orel.ru> Date: Tue, 21 Sep 2004 17:35:50 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: freebsd-threads@freebsd.org X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru Subject: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 13:35:55 -0000 Hello! See sys/kern/kern_kse.c In line with "suword32(&uap->tmbx->tm_lwp, td->td_tid)" kernel not check return value (error state). This is correct? ---[sys/kern/kern_kse.c]-------------------------------------- int kse_switchin(struct thread *td, struct kse_switchin_args *uap) { struct kse_thr_mailbox tmbx; struct kse_upcall *ku; int error; if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) return (EINVAL); error = (uap->tmbx == NULL) ? EINVAL : 0; if (!error) error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); if (!error && (uap->flags & KSE_SWITCHIN_SETTMBX)) error = (suword(&ku->ku_mailbox->km_curthread, (long)uap->tmbx) != 0 ? EINVAL : 0); if (!error) error = set_mcontext(td, &tmbx.tm_context.uc_mcontext); if (!error) { suword32(&uap->tmbx->tm_lwp, td->td_tid); if (uap->flags & KSE_SWITCHIN_SETTMBX) { td->td_mailbox = uap->tmbx; td->td_pflags |= TDP_CAN_UNBIND; } if (td->td_proc->p_flag & P_TRACED) { if (tmbx.tm_dflags & TMDF_SSTEP) ptrace_single_step(td); else ptrace_clear_single_step(td); if (tmbx.tm_dflags & TMDF_SUSPEND) { mtx_lock_spin(&sched_lock); /* fuword can block, check again */ if (td->td_upcall) ku->ku_flags |= KUF_DOUPCALL; mtx_unlock_spin(&sched_lock); } } } return ((error == 0) ? EJUSTRETURN : error); } -------------------------------------------------------------- On FreeBSD/sparc64 suword32() in this place generate trap "memory address not aligned (kernel)", and kse_switchin() returning EJUSTRETURN. How it to correct? -- With best regards, Andrew Belashov. From owner-freebsd-threads@FreeBSD.ORG Tue Sep 21 18:45:05 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1A3D516A4CE for ; Tue, 21 Sep 2004 18:45:05 +0000 (GMT) Received: from mail.vicor-nb.com (bigwoop.vicor-nb.com [208.206.78.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id E549D43D5E for ; Tue, 21 Sep 2004 18:45:04 +0000 (GMT) (envelope-from julian@elischer.org) Received: from elischer.org (julian.vicor-nb.com [208.206.78.97]) by mail.vicor-nb.com (Postfix) with ESMTP id 9380D7A3D2; Tue, 21 Sep 2004 11:45:04 -0700 (PDT) Message-ID: <415076B0.2050401@elischer.org> Date: Tue, 21 Sep 2004 11:45:04 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3.1) Gecko/20030516 X-Accept-Language: en, hu MIME-Version: 1.0 To: Andrew Belashov References: <41502E36.8070403@orel.ru> In-Reply-To: <41502E36.8070403@orel.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 18:45:05 -0000 Andrew Belashov wrote: > Hello! > > See sys/kern/kern_kse.c > > In line with "suword32(&uap->tmbx->tm_lwp, td->td_tid)" kernel > not check return value (error state). This is correct? yes and no. You are correct. It is never correct to "not check" however we have just looked at that location 7 lines earlier, so we know that the page in question is loaded and valid. This is is "prbably safe". Probably we should look at the error value also, even if this is true. > > ---[sys/kern/kern_kse.c]-------------------------------------- > int > kse_switchin(struct thread *td, struct kse_switchin_args *uap) > { > struct kse_thr_mailbox tmbx; > struct kse_upcall *ku; > int error; > > if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) > return (EINVAL); > error = (uap->tmbx == NULL) ? EINVAL : 0; > if (!error) > error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); > if (!error && (uap->flags & KSE_SWITCHIN_SETTMBX)) > error = (suword(&ku->ku_mailbox->km_curthread, > (long)uap->tmbx) != 0 ? EINVAL : 0); > if (!error) > error = set_mcontext(td, &tmbx.tm_context.uc_mcontext); > if (!error) { > suword32(&uap->tmbx->tm_lwp, td->td_tid); > if (uap->flags & KSE_SWITCHIN_SETTMBX) { > td->td_mailbox = uap->tmbx; > td->td_pflags |= TDP_CAN_UNBIND; > } > if (td->td_proc->p_flag & P_TRACED) { > if (tmbx.tm_dflags & TMDF_SSTEP) > ptrace_single_step(td); > else > ptrace_clear_single_step(td); > if (tmbx.tm_dflags & TMDF_SUSPEND) { > mtx_lock_spin(&sched_lock); > /* fuword can block, check again */ > if (td->td_upcall) > ku->ku_flags |= KUF_DOUPCALL; > mtx_unlock_spin(&sched_lock); > } > } > } > return ((error == 0) ? EJUSTRETURN : error); > } > -------------------------------------------------------------- > > On FreeBSD/sparc64 suword32() in this place generate trap "memory address > not aligned (kernel)", and kse_switchin() returning EJUSTRETURN. > > How it to correct? > > -- > With best regards, > Andrew Belashov. > _______________________________________________ > freebsd-threads@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to > "freebsd-threads-unsubscribe@freebsd.org" From owner-freebsd-threads@FreeBSD.ORG Tue Sep 21 20:13:26 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 52B4716A4CE for ; Tue, 21 Sep 2004 20:13:26 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id E63DB43D46 for ; Tue, 21 Sep 2004 20:13:25 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8LKDFKi022333; Tue, 21 Sep 2004 16:13:15 -0400 (EDT) Date: Tue, 21 Sep 2004 16:13:15 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Julian Elischer In-Reply-To: <415076B0.2050401@elischer.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 20:13:26 -0000 On Tue, 21 Sep 2004, Julian Elischer wrote: > > Andrew Belashov wrote: > > > Hello! > > > > See sys/kern/kern_kse.c > > > > In line with "suword32(&uap->tmbx->tm_lwp, td->td_tid)" kernel > > not check return value (error state). This is correct? > > > yes and no. > > You are correct. > It is never correct to "not check" however we have just looked at that > location 7 lines earlier, so we know > that the page in question is loaded and valid. This is is "prbably safe". > > Probably we should look at the error value also, even if this is true. Julian, you missed an important question below. It looks like he's trying to get this working with sparc64 and the suword32 is generating an alignment exception. Is lwpid_t 64-bit on sparc64 or is it somehow not being aligned properly within the mailbox? > > > > ---[sys/kern/kern_kse.c]-------------------------------------- > > int > > kse_switchin(struct thread *td, struct kse_switchin_args *uap) > > { > > struct kse_thr_mailbox tmbx; > > struct kse_upcall *ku; > > int error; > > > > if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) > > return (EINVAL); > > error = (uap->tmbx == NULL) ? EINVAL : 0; > > if (!error) > > error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); > > if (!error && (uap->flags & KSE_SWITCHIN_SETTMBX)) > > error = (suword(&ku->ku_mailbox->km_curthread, > > (long)uap->tmbx) != 0 ? EINVAL : 0); > > if (!error) > > error = set_mcontext(td, &tmbx.tm_context.uc_mcontext); > > if (!error) { > > suword32(&uap->tmbx->tm_lwp, td->td_tid); > > if (uap->flags & KSE_SWITCHIN_SETTMBX) { > > td->td_mailbox = uap->tmbx; > > td->td_pflags |= TDP_CAN_UNBIND; > > } > > if (td->td_proc->p_flag & P_TRACED) { > > if (tmbx.tm_dflags & TMDF_SSTEP) > > ptrace_single_step(td); > > else > > ptrace_clear_single_step(td); > > if (tmbx.tm_dflags & TMDF_SUSPEND) { > > mtx_lock_spin(&sched_lock); > > /* fuword can block, check again */ > > if (td->td_upcall) > > ku->ku_flags |= KUF_DOUPCALL; > > mtx_unlock_spin(&sched_lock); > > } > > } > > } > > return ((error == 0) ? EJUSTRETURN : error); > > } > > -------------------------------------------------------------- > > > > On FreeBSD/sparc64 suword32() in this place generate trap "memory address > > not aligned (kernel)", and kse_switchin() returning EJUSTRETURN. > > > > How it to correct? > > > > -- > > With best regards, > > Andrew Belashov. -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 00:37:51 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1B89616A4CE; Wed, 22 Sep 2004 00:37:51 +0000 (GMT) Received: from mail.vicor-nb.com (bigwoop.vicor-nb.com [208.206.78.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id D4D4F43D31; Wed, 22 Sep 2004 00:37:50 +0000 (GMT) (envelope-from julian@elischer.org) Received: from elischer.org (julian.vicor-nb.com [208.206.78.97]) by mail.vicor-nb.com (Postfix) with ESMTP id 907E47A41E; Tue, 21 Sep 2004 17:37:50 -0700 (PDT) Message-ID: <4150C95E.4030407@elischer.org> Date: Tue, 21 Sep 2004 17:37:50 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3.1) Gecko/20030516 X-Accept-Language: en, hu MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: davidxu@freebsd.org cc: threads@freebsd.org Subject: Re: SIGILL @ pthread_create() after execv X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 00:37:51 -0000 Daniel Eischen wrote: >This looks OK to me. > > Ok, so what happens if 2 threads call execve() at the same time and the first one in fails but the second one would succeed? By the time we've discovered that the first would have failed, we've probably already told the second that it was too late. In this case teh second thread has 2 options (assuming 2 processors) 1/ on dicovering that P_INEXEC is already set, it could just die, (i.e release locks it has and call thread_exit(). 2/ it could sleep on something, knowing that the leading thread will wake it up and force it to return (and thus call thread_exit() in userret) when it eventually calls thread_single() after it has passed all the permissions tests. >>I'm tempted to say that after a certain point the failure results in an >>exit().. >> >> I can't find any reference as to what other OS's do but I'll keep looking. >Sure. If it does manage to return to userland with an error, though, >the program should behave just as it did before the exec() call. That >means that anything that the UTS does in preparing for the exec() >should be undoable after a failed exec(). That's why I want to avoid >stopping or killing threads in the UTS prior to the exec(); it's just >plain messy, and then even worse trying to undo it. > From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 00:45:55 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 267CD16A4CE; Wed, 22 Sep 2004 00:45:55 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id BA18243D5A; Wed, 22 Sep 2004 00:45:54 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8M0jpKi007725; Tue, 21 Sep 2004 20:45:51 -0400 (EDT) Date: Tue, 21 Sep 2004 20:45:51 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Julian Elischer In-Reply-To: <4150C95E.4030407@elischer.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: davidxu@freebsd.org cc: threads@freebsd.org Subject: Re: SIGILL @ pthread_create() after execv X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 00:45:55 -0000 On Tue, 21 Sep 2004, Julian Elischer wrote: > > > Daniel Eischen wrote: > > >This looks OK to me. > > > > > > Ok, so what happens if 2 threads call execve() at the same time and the > first one in fails > but the second one would succeed? > By the time we've discovered that the first would have failed, we've > probably already > told the second that it was too late. Well, we can easily stop that in userland by taking a mutex or lock before the exec() then releasing it if the exec fails. Both libthr and libpthread would have to do this, I think. > In this case teh second thread has 2 options > (assuming 2 processors) > 1/ on dicovering that P_INEXEC is already set, it could just die, (i.e > release locks it has and call thread_exit(). > 2/ it could sleep on something, knowing that the leading thread will > wake it up and force it to > return (and thus call thread_exit() in userret) when it eventually calls > thread_single() > after it has passed all the permissions tests. Probably #2, but you could just disregard this situation if you want to put the onus on userland. I think an msleep() or CV would work if you want to block in the kernel. If the exec fails(), you can just wakeup() any waiters. -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 05:52:55 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A395616A4CE; Wed, 22 Sep 2004 05:52:55 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id CCEBA43D48; Wed, 22 Sep 2004 05:52:54 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8M5qkeT014374; Wed, 22 Sep 2004 09:52:47 +0400 Message-ID: <4151132E.8030904@orel.ru> Date: Wed, 22 Sep 2004 09:52:46 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: freebsd-threads@freebsd.org References: In-Reply-To: X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru cc: Daniel Eischen cc: Julian Elischer Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 05:52:55 -0000 Daniel Eischen wrote: > On Tue, 21 Sep 2004, Julian Elischer wrote: > >>Andrew Belashov wrote: >> >> >>>See sys/kern/kern_kse.c >>> >>>In line with "suword32(&uap->tmbx->tm_lwp, td->td_tid)" kernel >>>not check return value (error state). This is correct? >> >> >>yes and no. >> >>You are correct. >>It is never correct to "not check" however we have just looked at that >>location 7 lines earlier, so we know >>that the page in question is loaded and valid. This is is "prbably safe". >> >>Probably we should look at the error value also, even if this is true. > > > Julian, you missed an important question below. It looks > like he's trying to get this working with sparc64 and the > suword32 is generating an alignment exception. > > Is lwpid_t 64-bit on sparc64 or is it somehow not being aligned > properly within the mailbox? lwpid_t on sparc64 is 32-bit (typedef __int32_t __lwpid_t). What about using copyout? -- With best regards, Andrew Belashov. From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 08:05:54 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C83A16A4CE; Wed, 22 Sep 2004 08:05:54 +0000 (GMT) Received: from smtp.enta.net (smtp.enta.net [195.74.97.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC0D443D2D; Wed, 22 Sep 2004 08:05:53 +0000 (GMT) (envelope-from jacs@gnome.co.uk) Received: from hawk.gnome.co.uk (81-31-113-153.adsl.entanet.co.uk [81.31.113.153]) by smtp.enta.net (Postfix) with SMTP id 4D33299F3C; Wed, 22 Sep 2004 09:14:45 +0100 (BST) Received: from [192.168.123.12] (hawk.gnome.co.uk [192.168.123.12]) by hawk.gnome.co.uk (8.13.1/8.12.10) with ESMTP id i8M85mKn023670; Wed, 22 Sep 2004 09:05:48 +0100 (BST) (envelope-from jacs@gnome.co.uk) From: Chris Stenton To: freebsd-current@freebsd.org Content-Type: text/plain Message-Id: <1095840348.23443.14.camel@hawk.gnome.co.uk> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 22 Sep 2004 09:05:48 +0100 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.44 cc: threads@freebsd.org Subject: daemon threads bug with libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 08:05:54 -0000 If you create a thread before calling daemon then the next thread you create after the daemon call will cause the following error from the libpthread library. Fatal error 'mutex is on list' at line 516 in file /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0) This error does not occur if you link with -lc_r, linking with -lthr causes a core dump. -lthr does not look very stable. Here is some test code. I am running FreeBSD 5.3-beta Please reply directly as I am not on the mailing list Thanks Chris #include #include #include #include void *slave (void *args); void *slave2 (void *args); typedef struct { int data; pthread_mutex_t *mut; } simple; simple status; int main () { pthread_t sla, sla2; pthread_create (&sla, NULL, slave, &status); pthread_join(sla, NULL); daemon(0,1); pthread_create (&sla2, NULL, slave2, &status); for(;;){ } return 0; } void *slave (void *arg) { simple *status; status = (simple *)arg; pthread_mutex_lock (status->mut); status->data++; usleep(500000); printf("******slave me me me %d *********** \n",status->data ); pthread_mutex_unlock (status->mut); return (NULL); } void *slave2 (void *arg) { simple *status; status = (simple *)arg; for(; /* ever */ ;) { pthread_mutex_lock (status->mut); status->data++; usleep(500000); printf("******slave2 me me me %d \n",status->data ); pthread_mutex_unlock (status->mut); } return (NULL); } From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 11:46:20 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4675D16A4CE for ; Wed, 22 Sep 2004 11:46:20 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id E444743D46 for ; Wed, 22 Sep 2004 11:46:19 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8MBkHKi000332; Wed, 22 Sep 2004 07:46:17 -0400 (EDT) Date: Wed, 22 Sep 2004 07:46:17 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Andrew Belashov In-Reply-To: <4151132E.8030904@orel.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: Julian Elischer cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 11:46:20 -0000 On Wed, 22 Sep 2004, Andrew Belashov wrote: > Daniel Eischen wrote: > > On Tue, 21 Sep 2004, Julian Elischer wrote: > > > >>Andrew Belashov wrote: > >> > >> > >>>See sys/kern/kern_kse.c > >>> > >>>In line with "suword32(&uap->tmbx->tm_lwp, td->td_tid)" kernel > >>>not check return value (error state). This is correct? > >> > >> > >>yes and no. > >> > >>You are correct. > >>It is never correct to "not check" however we have just looked at that > >>location 7 lines earlier, so we know > >>that the page in question is loaded and valid. This is is "prbably safe". > >> > >>Probably we should look at the error value also, even if this is true. > > > > > > Julian, you missed an important question below. It looks > > like he's trying to get this working with sparc64 and the > > suword32 is generating an alignment exception. > > > > Is lwpid_t 64-bit on sparc64 or is it somehow not being aligned > > properly within the mailbox? > > lwpid_t on sparc64 is 32-bit (typedef __int32_t __lwpid_t). > > What about using copyout? Does it have to be 64-bit aligned in order to use suword32()? I believe you can use copyout, but perhaps the mailbox should be laid out so that fields are better aligned (doing this would break ABI). -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 11:59:36 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD3CC16A4CE; Wed, 22 Sep 2004 11:59:35 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 85D9B43D5C; Wed, 22 Sep 2004 11:59:35 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8MBxYKi021181; Wed, 22 Sep 2004 07:59:34 -0400 (EDT) Date: Wed, 22 Sep 2004 07:59:34 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Chris Stenton In-Reply-To: <1095840348.23443.14.camel@hawk.gnome.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: threads@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: daemon threads bug with libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 11:59:36 -0000 On Wed, 22 Sep 2004, Chris Stenton wrote: > If you create a thread before calling daemon then the next thread you > create after the daemon call will cause the following error from the > libpthread library. daemon() calls fork(). I don't think you can create a threaded program after a fork if you are already threaded. You have to wait to do any threading (including mutexes and stuff) until after the fork. When you call daemon() there is already a thread and perhaps some locks in the library (libc and libpthread). After the fork, the parent exits and the child is left. You are single threaded after the fork (as defined by POSIX), but libpthread and libc have locks that may be locked by threads created before the fork. > Fatal error 'mutex is on list' at line 516 in file > /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0) > > This error does not occur if you link with -lc_r, linking with -lthr > causes a core dump. -lthr does not look very stable. > > Here is some test code. I am running FreeBSD 5.3-beta > > Please reply directly as I am not on the mailing list -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 13:42:16 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F1D1216A4CE; Wed, 22 Sep 2004 13:42:16 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id F264243D49; Wed, 22 Sep 2004 13:42:15 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8MDg8eT014238; Wed, 22 Sep 2004 17:42:10 +0400 Message-ID: <41518130.3000704@orel.ru> Date: Wed, 22 Sep 2004 17:42:08 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 13:42:17 -0000 Daniel Eischen wrote: > On Wed, 22 Sep 2004, Andrew Belashov wrote: > > >>Daniel Eischen wrote: [...] >> > >> > Is lwpid_t 64-bit on sparc64 or is it somehow not being aligned >> > properly within the mailbox? >> >>lwpid_t on sparc64 is 32-bit (typedef __int32_t __lwpid_t). >> >>What about using copyout? > > > Does it have to be 64-bit aligned in order to use suword32()? No, it should be 32-bit aligned. > I believe you can use copyout, but perhaps the mailbox should > be laid out so that fields are better aligned (doing this > would break ABI). The problem is deeper, than I thought. And it hard to debug without modifying kernel... -- With best regards, Andrew Belashov. From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 14:29:40 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B834816A4CE; Wed, 22 Sep 2004 14:29:40 +0000 (GMT) Received: from smtp.enta.net (smtp.enta.net [195.74.97.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id 780AF43D39; Wed, 22 Sep 2004 14:29:40 +0000 (GMT) (envelope-from jacs@gnome.co.uk) Received: from hawk.gnome.co.uk (81-31-113-153.adsl.entanet.co.uk [81.31.113.153]) by smtp.enta.net (Postfix) with SMTP id 781A899EFE; Wed, 22 Sep 2004 15:38:33 +0100 (BST) Received: from kite (kite.gnome.co.uk [192.168.123.3]) by hawk.gnome.co.uk (8.13.1/8.12.10) with SMTP id i8METWqa036020; Wed, 22 Sep 2004 15:29:32 +0100 (BST) (envelope-from jacs@gnome.co.uk) Message-ID: <00da01c4a0b0$93b46d60$037ba8c0@gnome.co.uk> From: "Chris Stenton" To: "Daniel Eischen" References: Date: Wed, 22 Sep 2004 15:29:32 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Scanned-By: MIMEDefang 2.44 cc: threads@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: daemon threads bug with libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 14:29:40 -0000 Thanks Dan, As you can see I do a pthread_join before the daemon call so all threads should be closed at that point. There must be some residual state left. Chris ----- Original Message ----- From: "Daniel Eischen" To: "Chris Stenton" Cc: ; Sent: Wednesday, September 22, 2004 12:59 PM Subject: Re: daemon threads bug with libpthread > On Wed, 22 Sep 2004, Chris Stenton wrote: > >> If you create a thread before calling daemon then the next thread you >> create after the daemon call will cause the following error from the >> libpthread library. > > daemon() calls fork(). I don't think you can create a threaded > program after a fork if you are already threaded. You have to > wait to do any threading (including mutexes and stuff) until > after the fork. > > When you call daemon() there is already a thread and perhaps > some locks in the library (libc and libpthread). After the > fork, the parent exits and the child is left. You are single > threaded after the fork (as defined by POSIX), but libpthread > and libc have locks that may be locked by threads created > before the fork. > >> Fatal error 'mutex is on list' at line 516 in file >> /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0) >> >> This error does not occur if you link with -lc_r, linking with -lthr >> causes a core dump. -lthr does not look very stable. >> >> Here is some test code. I am running FreeBSD 5.3-beta >> >> Please reply directly as I am not on the mailing list > > -- > Dan Eischen > From owner-freebsd-threads@FreeBSD.ORG Wed Sep 22 16:47:07 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 965FE16A4D1; Wed, 22 Sep 2004 16:47:07 +0000 (GMT) Received: from telecom.net.et (sparrow.telecom.net.et [213.55.64.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D9CE43D5D; Wed, 22 Sep 2004 16:47:03 +0000 (GMT) (envelope-from mtm@identd.net) Received: from [213.55.68.240] (HELO rogue.acs.lan) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP id 57966412; Wed, 22 Sep 2004 19:39:57 +0300 Received: by rogue.acs.lan (Postfix, from userid 1000) id 69110B86E; Wed, 22 Sep 2004 19:47:09 +0300 (EAT) Date: Wed, 22 Sep 2004 19:47:09 +0300 From: Mike Makonnen To: Chris Stenton Message-ID: <20040922164709.GA14929@rogue.acs.lan> References: <1095840348.23443.14.camel@hawk.gnome.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <1095840348.23443.14.camel@hawk.gnome.co.uk> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD/6.0-CURRENT (i386) cc: threads@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: daemon threads bug with libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2004 16:47:07 -0000 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 22, 2004 at 09:05:48AM +0100, Chris Stenton wrote: > If you create a thread before calling daemon then the next thread you > create after the daemon call will cause the following error from the > libpthread library. > > Fatal error 'mutex is on list' at line 516 in file > /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0) > > This error does not occur if you link with -lc_r, linking with -lthr > causes a core dump. -lthr does not look very stable. Do you have any specific gripes with it? If so, please let me know. > > Here is some test code. I am running FreeBSD 5.3-beta > > Please reply directly as I am not on the mailing list The problem is with your test program. See the attached diff. After you apply it, it should work as expected. Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon ! --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="daemontest.diff" --- daemontest.c Wed Sep 22 18:43:36 2004 +++ daemontest2.c Wed Sep 22 19:43:11 2004 @@ -9,7 +9,7 @@ typedef struct { int data; - pthread_mutex_t *mut; + pthread_mutex_t mut; } simple; @@ -41,11 +41,11 @@ status = (simple *)arg; - pthread_mutex_lock (status->mut); + pthread_mutex_lock (&status->mut); status->data++; usleep(500000); printf("******slave me me me %d *********** \n",status->data ); - pthread_mutex_unlock (status->mut); + pthread_mutex_unlock (&status->mut); return (NULL); } @@ -59,11 +59,11 @@ for(; /* ever */ ;) { - pthread_mutex_lock (status->mut); + pthread_mutex_lock (&status->mut); status->data++; usleep(500000); printf("******slave2 me me me %d \n",status->data ); - pthread_mutex_unlock (status->mut); + pthread_mutex_unlock (&status->mut); } return (NULL); --jRHKVT23PllUwdXP-- From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 10:20:55 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CFC5116A4CE; Thu, 23 Sep 2004 10:20:55 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0F8F443D1D; Thu, 23 Sep 2004 10:20:55 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8NAKpBm006528; Thu, 23 Sep 2004 14:20:52 +0400 Message-ID: <4152A383.3090901@orel.ru> Date: Thu, 23 Sep 2004 14:20:51 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: freebsd-threads@freebsd.org References: <41518130.3000704@orel.ru> In-Reply-To: <41518130.3000704@orel.ru> X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru cc: freebsd-sparc64@freebsd.org Subject: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 10:20:56 -0000 Hello! I long time work on libkse library for FreeBSD/sparc64. Some work is done. Recently I have found a bug in kernel. Here details. From sys/kern/kern_kse.c: --------------------------------------------------------------------------- 1 int 2 kse_switchin(struct thread *td, struct kse_switchin_args *uap) 3 { 4 struct kse_thr_mailbox tmbx; 5 struct kse_upcall *ku; 6 int error; 7 8 if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) 9 return (EINVAL); 10 error = (uap->tmbx == NULL) ? EINVAL : 0; 11 if (!error) 12 error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); 13 if (!error && (uap->flags & KSE_SWITCHIN_SETTMBX)) 14 error = (suword(&ku->ku_mailbox->km_curthread, 15 (long)uap->tmbx) != 0 ? EINVAL : 0); 16 if (!error) 17 error = set_mcontext(td, &tmbx.tm_context.uc_mcontext); 18 if (!error) { 19 suword32(&uap->tmbx->tm_lwp, td->td_tid); 20 if (uap->flags & KSE_SWITCHIN_SETTMBX) { 21 td->td_mailbox = uap->tmbx; 22 td->td_pflags |= TDP_CAN_UNBIND; 23 } 24 if (td->td_proc->p_flag & P_TRACED) { 25 if (tmbx.tm_dflags & TMDF_SSTEP) 26 ptrace_single_step(td); 27 else 28 ptrace_clear_single_step(td); 29 if (tmbx.tm_dflags & TMDF_SUSPEND) { 30 mtx_lock_spin(&sched_lock); 31 /* fuword can block, check again */ 32 if (td->td_upcall) 33 ku->ku_flags |= KUF_DOUPCALL; 34 mtx_unlock_spin(&sched_lock); 35 } 36 } 37 } 38 return ((error == 0) ? EJUSTRETURN : error); 39 } --------------------------------------------------------------------------- 1. On FreeBSD/sparc64 uap structure (line 2) is stored in trap stack frame, if number of syscall arguments is 6 or less (see: sys/sparc64/sparc64/trap.c). 2. set_mcontext() function overwriting trap stack frame for restore saved context (line 17). 3. uap structure used after overwriting by set_mcontext() in following lines: 19, 20, 21. Same problem in thr_create() (see sys/kern/kern_thr.c). Where bug? - In sparc64 specific core? - In kern/kern_kse.c and kern/kern_thr.c code? -- With best regards, Andrew Belashov. From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 11:25:03 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C1AD16A4CF; Thu, 23 Sep 2004 11:25:03 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1504C43D1D; Thu, 23 Sep 2004 11:25:03 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8NBP194028609; Thu, 23 Sep 2004 07:25:01 -0400 (EDT) Date: Thu, 23 Sep 2004 07:25:01 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Andrew Belashov In-Reply-To: <4152A383.3090901@orel.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-sparc64@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 11:25:03 -0000 On Thu, 23 Sep 2004, Andrew Belashov wrote: > Hello! > > I long time work on libkse library for FreeBSD/sparc64. Some work is done. > Recently I have found a bug in kernel. > > Here details. > > From sys/kern/kern_kse.c: > --------------------------------------------------------------------------- > 1 int > 2 kse_switchin(struct thread *td, struct kse_switchin_args *uap) > 3 { > 4 struct kse_thr_mailbox tmbx; > 5 struct kse_upcall *ku; > 6 int error; > 7 > 8 if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) > 9 return (EINVAL); > 10 error = (uap->tmbx == NULL) ? EINVAL : 0; > 11 if (!error) > 12 error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); > 13 if (!error && (uap->flags & KSE_SWITCHIN_SETTMBX)) > 14 error = (suword(&ku->ku_mailbox->km_curthread, > 15 (long)uap->tmbx) != 0 ? EINVAL : 0); > 16 if (!error) > 17 error = set_mcontext(td, &tmbx.tm_context.uc_mcontext); > 18 if (!error) { > 19 suword32(&uap->tmbx->tm_lwp, td->td_tid); > 20 if (uap->flags & KSE_SWITCHIN_SETTMBX) { > 21 td->td_mailbox = uap->tmbx; > 22 td->td_pflags |= TDP_CAN_UNBIND; > 23 } > 24 if (td->td_proc->p_flag & P_TRACED) { > 25 if (tmbx.tm_dflags & TMDF_SSTEP) > 26 ptrace_single_step(td); > 27 else > 28 ptrace_clear_single_step(td); > 29 if (tmbx.tm_dflags & TMDF_SUSPEND) { > 30 mtx_lock_spin(&sched_lock); > 31 /* fuword can block, check again */ > 32 if (td->td_upcall) > 33 ku->ku_flags |= KUF_DOUPCALL; > 34 mtx_unlock_spin(&sched_lock); > 35 } > 36 } > 37 } > 38 return ((error == 0) ? EJUSTRETURN : error); > 39 } > --------------------------------------------------------------------------- > > 1. On FreeBSD/sparc64 uap structure (line 2) is stored in trap stack frame, if number of > syscall arguments is 6 or less (see: sys/sparc64/sparc64/trap.c). > > 2. set_mcontext() function overwriting trap stack frame for restore saved > context (line 17). > > 3. uap structure used after overwriting by set_mcontext() in following lines: > 19, 20, 21. > > Same problem in thr_create() (see sys/kern/kern_thr.c). > > Where bug? > - In sparc64 specific core? > - In kern/kern_kse.c and kern/kern_thr.c code? Wouldn't you also see same behavior (bugs) in other things, like getcontext(), setcontext(), and swapcontext() (kern_context.c)? -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 12:17:22 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7009C16A4CE; Thu, 23 Sep 2004 12:17:22 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E2B243D54; Thu, 23 Sep 2004 12:17:21 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8NCHIBm009576; Thu, 23 Sep 2004 16:17:19 +0400 Message-ID: <4152BECE.5080202@orel.ru> Date: Thu, 23 Sep 2004 16:17:18 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru cc: freebsd-sparc64@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 12:17:22 -0000 Daniel Eischen wrote: > Wouldn't you also see same behavior (bugs) in other things, like > getcontext(), setcontext(), and swapcontext() (kern_context.c)? No. uap structure is not used after set_mcontext(). From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 12:49:08 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C9DF16A4CE; Thu, 23 Sep 2004 12:49:08 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1E7B43D41; Thu, 23 Sep 2004 12:49:07 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) i8NCn694028202; Thu, 23 Sep 2004 08:49:07 -0400 (EDT) Date: Thu, 23 Sep 2004 08:49:06 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Andrew Belashov In-Reply-To: <4152BECE.5080202@orel.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-sparc64@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 12:49:08 -0000 On Thu, 23 Sep 2004, Andrew Belashov wrote: > Daniel Eischen wrote: > > Wouldn't you also see same behavior (bugs) in other things, like > > getcontext(), setcontext(), and swapcontext() (kern_context.c)? > > No. uap structure is not used after set_mcontext(). Have you tried copying the uap (flags, tmbx) before setting the context and using the copy thereafter? -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 13:24:39 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D51816A4CE; Thu, 23 Sep 2004 13:24:39 +0000 (GMT) Received: from tts.orel.ru (tts.orel.ru [213.59.64.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E57843D45; Thu, 23 Sep 2004 13:24:38 +0000 (GMT) (envelope-from bel@orel.ru) Received: from orel.ru (lg.orel.ru [62.33.11.59]) by tts.orel.ru (8.12.10/8.12.10/bel) with ESMTP id i8NDOYBm030978; Thu, 23 Sep 2004 17:24:35 +0400 Message-ID: <4152CE93.4050908@orel.ru> Date: Thu, 23 Sep 2004 17:24:35 +0400 From: Andrew Belashov Organization: ORIS User-Agent: Mozilla/5.0 (X11; U; FreeBSD sparc64; en-US; rv:1.6) Gecko/20040407 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: X-Enigmail-Version: 0.83.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Zombi-Check: on netra2.orel.ru cc: freebsd-sparc64@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 13:24:39 -0000 Daniel Eischen wrote: > On Thu, 23 Sep 2004, Andrew Belashov wrote: > > >>Daniel Eischen wrote: >> >>>Wouldn't you also see same behavior (bugs) in other things, like >>>getcontext(), setcontext(), and swapcontext() (kern_context.c)? >> >>No. uap structure is not used after set_mcontext(). > > > Have you tried copying the uap (flags, tmbx) before setting > the context and using the copy thereafter? Yes. It solves a problem in this place. However libkse does not work again... From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 13:51:59 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C763A16A4CE for ; Thu, 23 Sep 2004 13:51:59 +0000 (GMT) Received: from mx0-a.inoc.net (mx0-a.inoc.net [64.246.130.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4863F43D53 for ; Thu, 23 Sep 2004 13:51:59 +0000 (GMT) (envelope-from rblayzor@inoc.net) Received: from [192.168.0.16] (noc-gw0-fe.dc1-alb.inoc.net [64.246.129.30]) by mx0-a.inoc.net (build v4.8.10) with ESMTP id 23412264 for ; Thu, 23 Sep 2004 09:51:58 -0400 Message-ID: <4152D4FC.6080803@inoc.net> Date: Thu, 23 Sep 2004 09:51:56 -0400 From: Robert Blayzor Organization: Independent Network Operations Consortium, LLC User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-threads@freebsd.org X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Problem with fclose() returning error (EBADF) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 13:51:59 -0000 I have a multithreaded application running on FreeBSD 4.9, .10 and -STABLE that I'm having an issue with. The application writes large amounts of small files over an NFS mount and randomly we're seeing fclose() return a failure code, -1 and errorno, EBADF. We have no idea what may be causing the problem. The NFS server appears to be functioning fine, no errors at all, it runs perfectly over tons of other clients. At first we thought maybe that the fd was getting munged somehow, but here is the weird part. If the code is changed to do an fflush() on the fd immediately before we issue an fclose(), fflush NEVER returns an error and always completes successfully. However, completely rnadomly fclose() will return an error condition and errno of EBADF. There are hundreds of gigs and inodes available on the NFS server and writes work fine from all other NFS clients at the time. (this is a six server mail cluster) We've double checked the compile flags and I've gone through all the libc calls I can think of. And I've linked my own debugging into the libc_r close function and it's not showing 'any' closes occuring between the fopen and fclose that fails. We've also checked the flags of the FILE *f, structure, it is still correct so it has not been munged by anything. There are lots of conditions where the error EBADF is returned by the kernel etc... and I suspect one of them is not really a sign of a bad file handle but means something else, but I don't know any way to find what is really occuring and if it is serious or just a faulty return code. Doing a KTRACE on this may be the only option, but the problem is, the application is SO busy and the problem only happens randomly it'd be impossible to find if/when it happens. ie: thousands and thousands of files can be written successfully before we actually see a failed one. Any help or guidance would be greatly apprecaited. TIA -- Robert Blayzor, BOFH INOC, LLC rblayzor@inoc.net PGP: http://www.inoc.net/~dev/ Key fingerprint = 1E02 DABE F989 BC03 3DF5 0E93 8D02 9D0B CB1A A7B0 Quality assurance: A way to ensure you never deliver shoddy goods accidentally. From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 15:08:50 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7BA8716A4CE; Thu, 23 Sep 2004 15:08:50 +0000 (GMT) Received: from telecom.net.et (sparrow.telecom.net.et [213.55.64.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id F197343D1D; Thu, 23 Sep 2004 15:08:46 +0000 (GMT) (envelope-from mtm@identd.net) Received: from [213.55.68.64] (HELO rogue.acs.lan) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP id 58067787; Thu, 23 Sep 2004 18:01:41 +0300 Received: by rogue.acs.lan (Postfix, from userid 1000) id 42F1DB86E; Thu, 23 Sep 2004 18:08:58 +0300 (EAT) Date: Thu, 23 Sep 2004 18:08:58 +0300 From: Mike Makonnen To: Andrew Belashov Message-ID: <20040923150857.GA51350@rogue.acs.lan> References: <4152BECE.5080202@orel.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" Content-Disposition: inline In-Reply-To: <4152BECE.5080202@orel.ru> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD/6.0-CURRENT (i386) cc: Daniel Eischen cc: freebsd-sparc64@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: Bug in kse_switchin()? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 15:08:50 -0000 --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 23, 2004 at 04:17:18PM +0400, Andrew Belashov wrote: > Daniel Eischen wrote: > >Wouldn't you also see same behavior (bugs) in other things, like > >getcontext(), setcontext(), and swapcontext() (kern_context.c)? > > No. uap structure is not used after set_mcontext(). So, the attached change to thr_create should work as far as libthr is concerned then? BTW, have you tried libthr on sparc64, and if so how does it work? Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon ! --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff Index: sys/kern/kern_thr.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_thr.c,v retrieving revision 1.27 diff -u -r1.27 kern_thr.c --- sys/kern/kern_thr.c 7 Sep 2004 07:04:47 -0000 1.27 +++ sys/kern/kern_thr.c 23 Sep 2004 15:06:04 -0000 @@ -76,9 +76,11 @@ int error; struct ksegrp *kg, *newkg; struct proc *p; + int flags; p = td->td_proc; kg = td->td_ksegrp; + flags = uap->flags; if ((error = copyin(uap->ctx, &ctx, sizeof(ctx)))) return (error); @@ -158,7 +160,7 @@ sched_fork_thread(td, newtd); TD_SET_CAN_RUN(newtd); - if ((uap->flags & THR_SUSPENDED) == 0) + if ((flags & THR_SUSPENDED) == 0) setrunqueue(newtd, SRQ_BORING); mtx_unlock_spin(&sched_lock); --wac7ysb48OaltWcw-- From owner-freebsd-threads@FreeBSD.ORG Sat Sep 25 13:15:36 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2C4C316A4CE for ; Sat, 25 Sep 2004 13:15:36 +0000 (GMT) Received: from exsmtp2.ntu.edu.sg (exsmtp2.ntu.edu.sg [155.69.5.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1A7443D48 for ; Sat, 25 Sep 2004 13:15:34 +0000 (GMT) (envelope-from gaoyandong@pmail.ntu.edu.sg) Received: from mail03.student.main.ntu.edu.sg ([155.69.5.167]) by exsmtp2.ntu.edu.sg with Microsoft SMTPSVC(6.0.3790.0); Sat, 25 Sep 2004 21:15:33 +0800 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Date: Sat, 25 Sep 2004 21:15:31 +0800 Message-ID: <052033A55521254893A4E2041957E1D01CB81B@mail03.student.main.ntu.edu.sg> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: a problem about pthread Thread-Index: AcSjAbpQgAczCu5rR86nVX3kIBu2hQ== From: "#GAO YANDONG#" To: X-OriginalArrivalTime: 25 Sep 2004 13:15:33.0054 (UTC) FILETIME=[BCC505E0:01C4A301] Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: a problem about pthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Sep 2004 13:15:36 -0000 Dear all, =20 I met a problem when I compile DEAL.II (a general finite element library) in FreeBSD 4.10. After I run "gmake", I got the following information =20 " /usr/.../deal/deal.II/lib/libdeal_II_2d.g.so: undefined reference to 'pthread_mutex_unlock' /usr/.../deal/deal.II/lib/libdeal_II_2d.g.so: undefined reference to 'pthread_mutex_destroy' /usr/.../deal/deal.II/lib/libdeal_II_2d.g.so: undefined reference to 'pthread_mutex_lock' /usr/.../deal/deal.II/lib/libdeal_II_2d.g.so: undefined reference to 'pthread_mutex_init' =20 " Someone tell me to use=20 "export LIBS=3D-lpthread" before compile the library, but it didn't work. =20 And, It's said on FreeBSD, "gcc -pthread " will generate some problem http://lists.freebsd.org/mailman/htdig/freebsd-threads/2003-September/00 1203.html =20 =20 What can I do? =20 Best Regards, =20 Yandong=20