From owner-freebsd-current@freebsd.org Tue Dec 20 10:55:29 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FAEBC897E8 for ; Tue, 20 Dec 2016 10:55:29 +0000 (UTC) (envelope-from jpa@semihalf.com) Received: from mail-ua0-x22b.google.com (mail-ua0-x22b.google.com [IPv6:2607:f8b0:400c:c08::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 10B8F358 for ; Tue, 20 Dec 2016 10:55:28 +0000 (UTC) (envelope-from jpa@semihalf.com) Received: by mail-ua0-x22b.google.com with SMTP id 44so5702326uak.1 for ; Tue, 20 Dec 2016 02:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oItRfyKn9+I7b1sZksQMowzDW/7J6CwDpGEpCUS9dac=; b=ZMWjfwxPf9fLZpgsstyey3ilFA9PWoNe48A4QPlRdQDDh52i2443/7ify7M4dRaN46 6cmdL0BRQ62tQ+jJscBScAusbsOS6+Yv24npk5RzXJN5TTg0Q3I7457+vk5rHm6tPofK ZDwU6MhnIZydyYM1QaiKkW7a1FEjrBo97JVQEcl3/OwrC49nkH/1DTSpNtnhvZjOgEZi o1lDXSGUnIu7AOWoF6OHoYaTGY/qiLvZ4hYiUZdTRKxH+Ogknqn0WjRcd4nlEQDX/4IK 0ZgkE/6knAHm1X1UL+v1dJDRfIFkhkTovikSAVfkYv7TqArN8MiWMm2pDzpIBUNuP9hB wgog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oItRfyKn9+I7b1sZksQMowzDW/7J6CwDpGEpCUS9dac=; b=Ybk1hukatGFdhsYIlCI3KOByxzWTR/f0EhR4fUN7TPxUH6XZuO+r/wbO9nK+kJn0Vf IB5dJ99igG/Qd1wrHBdr6/X4E9n+riBxLRAeIjq4WoaWTDpmDEAV8EeHQKzmxo0nEsJ0 62U+3VEzG8Uar8blyHS1zCcOjIuQmG0YAJEkWqhPEcuU3iOx0VJt82f0Q4gTI3XvueoZ DGrqNrDmL7JsB7mUTcneHf9hQ03v+Xnv7BRWieZjTdjYmQ48SYHWV1N7e3n3149t6thH 8bvYkMT0OuQn28FPGpGw/IaLpOxBnFvzuXORgdDSlf4aIog759cwK5qP3WbfZSaPeqZl FoHw== X-Gm-Message-State: AKaTC02vIYTKV89PB7S7Hoxytsot1HI+vItLx/vUFhDrN8IY9ha3qVVHNwhMbGM9+fIqyTvpXVcDMr/uLv2L7A== X-Received: by 10.159.48.145 with SMTP id j17mr13045074uab.43.1482231328158; Tue, 20 Dec 2016 02:55:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.46.18 with HTTP; Tue, 20 Dec 2016 02:54:57 -0800 (PST) In-Reply-To: <78FB227F-3542-452F-9A16-4FB0E0E698AC@FreeBSD.org> References: <01000158c7252f0c-6c3198b0-fbef-4a60-ade9-e3b91d9e83bd-000000@email.amazonses.com> <78FB227F-3542-452F-9A16-4FB0E0E698AC@FreeBSD.org> From: Jakub Palider Date: Tue, 20 Dec 2016 11:54:57 +0100 Message-ID: Subject: Re: clang/llvm 3.9.0 mysteriously zeroing variables? To: Dimitry Andric Cc: Hans Petter Selasky , Colin Percival , freebsd-current@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 10:55:29 -0000 Hi, do you still observe this behaviour? Which type of EC2 instances were affected? I tried to reproduce with kernel/tools from Dec 15 and did not manage to crash the machine. Jakub On Sun, Dec 4, 2016 at 5:38 PM, Dimitry Andric wrote: > On 04 Dec 2016, at 10:52, Hans Petter Selasky wrote: > > > > On 12/04/16 01:04, Colin Percival wrote: > >> Starting with r309124 (when clang/llvm 3.9.0 was imported) I'm seeing > EC2 > >> instances panic on boot with a division-by-zero error; the code in > question > >> is in blkfront.c, printing out the size of disks: > >> > >>> device_printf(dev, "%juMB <%s> at %s", > >>> (uintmax_t) sectors / (1048576 / sector_size), > >>> device_get_desc(dev), > >>> xenbus_get_node(dev)); > >> > >> My first thought was that 'sector_size' must be either zero or very > large... > >> but no, when I add printf("sector_size = %ju\n", > (uintmax_t)sector_size), it's > >> entirely normal. What's more, adding that printf makes the > division-by-zero > >> panic go away. > >> > >> I'd think I was just hallucinating, but earlier today I heard that a > similarly > >> "impossible" panic had been observed in the NFS client code when > compiled with > >> clang/llvm 3.9.0. > >> > >> So... is anyone else seeing unexpected panics or other odd behaviour > starting > >> after clang/llvm 3.9.0 was imported? > >> > > > > Hi, > > > > Can you look at the code with "objdump -Dx --source" and see what is > going on there? Might it be the "sector" variable is shadowed? > > I don't see anything in the generated code for the call that can cause > this, except for sector_size really being zero, or the result of > 1048576/sector_size being zero. > > On i386, you get this: > > .loc 1 1349 19 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:19 > movl -56(%ebp), %ecx # -56(%rbp) = sectors > .Ltmp1148: > #DEBUG_VALUE: xbd_connect:sectors <- %ECX > .loc 1 1349 38 is_stmt 0 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:38 > movl $1048576, %eax # imm = 0x100000 > xorl %edx, %edx > divl -52(%ebp) # -52(%ebp) = sector_size > movl %eax, %edi > .loc 1 1349 27 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:27 > xorl %edx, %edx > movl %ecx, %eax > divl %edi > movl %eax, -32(%ebp) # 4-byte Spill > > On amd64, it looks pretty similar: > > .loc 1 1349 19 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:19 > movq -112(%rbp), %rcx # -112(%rbp) = sectors > .Ltmp1128: > #DEBUG_VALUE: xbd_connect:sectors <- %RCX > .loc 1 1349 38 is_stmt 0 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:38 > movl $1048576, %eax # imm = 0x100000 > xorl %edx, %edx > divq -88(%rbp) # -88(%rbp) = sector_size > movq %rax, %rsi > .loc 1 1349 27 # /usr/src/sys/dev/xen/blkfront/ > blkfront.c:1349:27 > xorl %edx, %edx > movq %rcx, %rax > divq %rsi > movq %rax, %r15 > > Colin, does it panic for you in the first or the second div? > > -Dimitry > >