From owner-freebsd-threads@FreeBSD.ORG Tue Jul 25 20:00:34 2006 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org 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 478BC16A4E1 for ; Tue, 25 Jul 2006 20:00:34 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A04243D58 for ; Tue, 25 Jul 2006 20:00:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k6PK0XoC099115 for ; Tue, 25 Jul 2006 20:00:33 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k6PK0X4D099109; Tue, 25 Jul 2006 20:00:33 GMT (envelope-from gnats) Resent-Date: Tue, 25 Jul 2006 20:00:33 GMT Resent-Message-Id: <200607252000.k6PK0X4D099109@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, Michael Scheidell Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5C9D716A4E7; Tue, 25 Jul 2006 19:58:40 +0000 (UTC) (envelope-from scheidell@secnap.net) Received: from scanner.secnap.net (scanner.secnap.net [204.89.241.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1BC2D43D46; Tue, 25 Jul 2006 19:58:40 +0000 (GMT) (envelope-from scheidell@secnap.net) Received: by scanner.secnap.net (Postfix, from userid 1001) id 4E5CF137BB7; Tue, 25 Jul 2006 15:58:39 -0400 (EDT) Message-Id: <20060725195839.4E5CF137BB7@scanner.secnap.net> Date: Tue, 25 Jul 2006 15:58:39 -0400 (EDT) From: Michael Scheidell To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: freebsd-hackers@FreeBSD.org Subject: threads/100815: FBSD 5.5 broke nanosleep in libc_r X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2006 20:00:34 -0000 >Number: 100815 >Category: threads >Synopsis: FBSD 5.5 broke nanosleep in libc_r >Confidential: yes >Severity: serious >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jul 25 20:00:32 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Michael Scheidel >Release: FreeBSD 5.5-RELEASE-p2 i386 >Organization: SECNAP Network Security >Environment: System: FreeBSD audit18.hackertrap.net 5.5-RELEASE-p2 FreeBSD 5.5-RELEASE-p2 #6: Tue Jul 25 10:34:16 EDT 2006 admin@audit18.hackertrap.net:/usr/obj/usr/src/sys/HACKERTRAP_305 i386 >Description: nanosleep returns after time+delta if wallclock changed with libc_r >How-To-Repeat: 5.4 works, not including libc_r in 5.5 works Given this POC: int main( int argc, char **argv ) { char execs1[256] = "/bin/date +A%Y%m%d%H%M.%S"; char execs2[256] = "/bin/date +B%Y%m%d%H%M.%S"; int a; while ( 1) { system( execs1 ); usleep( 500*1000); system( execs2 ); } return 0; } /* main */ compile with: cc -g -c nanotest.c cc -g -o nanotest nanotest.o -lc_r run it, set clock back 45 seconds, observe 45 second delay >Fix: compile with: cc -g -c nanotest.c cc -g -o nanotest nanotest.o or compile on 5.4 system. (I have only tried compiling and running on 5.4 system. I have not yet tried compiling on 5.4 and running on 5.5 or visa versa) I used ntpdate -su to change clock. (I have an internal system that is 45 seconds behind, just for this test) output with 5.4 or without libc_r shows wallclock 'stepping' when you change time no delay in display. 5.5 with libc_r shows stepping if moving clock head, but if you move wallclock back 45 seconds, display stops for 45 seconds. >Release-Note: >Audit-Trail: >Unformatted: