From owner-freebsd-questions@FreeBSD.ORG Mon Oct 8 19:03:38 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21A2616A417 for ; Mon, 8 Oct 2007 19:03:38 +0000 (UTC) (envelope-from mihai.dontu@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by mx1.freebsd.org (Postfix) with ESMTP id AFAE113C447 for ; Mon, 8 Oct 2007 19:03:37 +0000 (UTC) (envelope-from mihai.dontu@gmail.com) Received: by nf-out-0910.google.com with SMTP id b2so1047309nfb for ; Mon, 08 Oct 2007 12:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:organization:to:subject:user-agent:mime-version:content-disposition:date:cc:content-type:content-transfer-encoding:message-id; bh=W5EGiVnrrBa8X0/UqP9sQ4gOlQC2ZF8saxCySvX5wfw=; b=C1SBeIPS5/7JNQUUa/KRH1wuvN1A+JyDxdFeeV4eCY2sqKySv5Njy0BjQKukcQRe6HW8tI6nDZP/v6kkeisOFmYNaii02hFkfa9XBUyV8Cd9uBq0lM1CvDiCOR7cHlj36+a9/skwa31WEZBXxxH3gI3rgRUB6AZ57ZlPBjbR4nU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:organization:to:subject:user-agent:mime-version:content-disposition:date:cc:content-type:content-transfer-encoding:message-id; b=is3xyRMv1Jhm1qZg8kVvG3W78ZramcJYGwAnu8OibgGdMO77IMAAFsmr0asmhQrn/HmD1uLtqIDUNsuPkCrtfzL+ZLv8onVSUmizVOfbLlZChPLaIDxNSaaoIrX/s9yXEMJWQ+3R1hm2kPnBN6ZKLcNK50ssN262/7CbAiMQdEY= Received: by 10.82.111.8 with SMTP id j8mr23377265buc.1191868567750; Mon, 08 Oct 2007 11:36:07 -0700 (PDT) Received: from mdontu-l.dsd.ro ( [217.156.83.1]) by mx.google.com with ESMTPS id u9sm13618922muf.2007.10.08.11.36.06 (version=SSLv3 cipher=OTHER); Mon, 08 Oct 2007 11:36:06 -0700 (PDT) From: Mihai =?utf-8?q?Don=C8=9Bu?= Organization: Home To: freebsd-questions@freebsd.org User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Disposition: inline Date: Mon, 8 Oct 2007 21:35:57 +0300 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <200710082135.58099.mihai.dontu@gmail.com> Cc: freebsd-emulation@freebsd.org Subject: amd64_set_gsbase() X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Oct 2007 19:03:38 -0000 Hi, I have a "small" amd64 program that makes havy use of LDT (%GS to be more specific). The trouble is, in a multithreaded environment, the selector value gets lost (or reset?). The code *always* segfaults with this stack: 4 LWP 100126 0x0000000800dec07c in select () from /lib/libc.so.6 * 3 Thread 0x517000 (runnable) 0x000000080055cfbc in ?? () 2 Thread 0x517400 (LWP 100125) 0x0000000800c0d85c in pthread_testcancel () from /lib/libpthread.so.2 1 Thread 0x517800 (runnable) 0x0000000800d5d000 in makecontext () from /lib/libc.so.6 at this instruction: 0x000000080055cfbc: mov %gs:0x10,%r11 (gdb) p $gs $1 = 0 I've been reading on the net something about the kernel not preserving the GS across syscalls (or stmh). Is this true? and if so, is there a known workaround? I'm on a FreeBSD 6.2-STABLE-200706 (AMD64) machine. Thanks, -- Mihai Donțu