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.