From owner-freebsd-hackers@freebsd.org Fri Nov 8 10:50:50 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC5BD1AE0EA for ; Fri, 8 Nov 2019 10:50:50 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478cWG0K2Qz4B3b for ; Fri, 8 Nov 2019 10:50:49 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: by mail-pf1-f175.google.com with SMTP id 193so4257958pfc.13 for ; Fri, 08 Nov 2019 02:50:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=sEzPih84YDVnn3tQDizrPFc6jAULOgwGEYDS+Knpw2g=; b=fQ1f017LD2X2G4OL8qB08Oq4tYfn6D1fmmEF3A84kKhlUxefqfgc9iRBxD0kI1V2qV M5omDTc+gnb97YLnLvbevYd6Jw6agUbjEtmkiwuvdbPGWlLzsLv++UT7DKqUGwG69qN/ tHTmAhio0gRGwUuphIdJQI+3ZxCsztWVo7c/oqhWDO+TD8HSk4zTX6N2Bc9/n/rgnMkz 89i9tO0RVWsmsBuanm3IRugSIOP12VWA9AOL0509qQY0S2sgL5J/de4nFAjqstOFgz1W iaL1Yt+JISVotXjGJ7IuFoyHdl3OT/u6LA+/uvfzihKN1tvnbSkRFRycMkpePtSbK0v8 XUsA== X-Gm-Message-State: APjAAAWcyiswg6EdgKHMLynRxYwjN1ToAhkQ1cPR31xE2gwQxP63coU1 s95LwL+/ReNsBWdccHktLLSnaFAaLQ4= X-Google-Smtp-Source: APXvYqyWOLdi4jQ9MdhZQNzCdz+Zb9iowSvVw7nlw3PQ6jJviZZqzDpxyqQ5nfzrpDWSMaGgG5DZGA== X-Received: by 2002:aa7:92c9:: with SMTP id k9mr11026894pfa.155.1573210247680; Fri, 08 Nov 2019 02:50:47 -0800 (PST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com. [209.85.214.181]) by smtp.gmail.com with ESMTPSA id d9sm6732148pgc.80.2019.11.08.02.50.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Nov 2019 02:50:47 -0800 (PST) Received: by mail-pl1-f181.google.com with SMTP id l4so3883873plt.13 for ; Fri, 08 Nov 2019 02:50:47 -0800 (PST) X-Received: by 2002:a17:902:6807:: with SMTP id h7mr9907566plk.288.1573210246973; Fri, 08 Nov 2019 02:50:46 -0800 (PST) MIME-Version: 1.0 From: Gleb Popov Date: Fri, 8 Nov 2019 14:50:21 +0400 X-Gmail-Original-Message-ID: Message-ID: Subject: My code causes "ata0: already running" error and hang in VirtualBox VM To: freebsd-hackers X-Rspamd-Queue-Id: 478cWG0K2Qz4B3b X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of 6yearold@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=6yearold@gmail.com X-Spamd-Result: default: False [-4.02 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; URI_COUNT_ODD(1.00)[3]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[4]; MIME_TRACE(0.00)[0:+,1:+,2:~]; TO_DN_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_IN_DNSWL_NONE(0.00)[175.210.85.209.list.dnswl.org : 127.0.5.0]; IP_SCORE(-3.02)[ip: (-9.85), ipnet: 209.85.128.0/17(-3.20), asn: 15169(-2.01), country: US(-0.05)]; FORGED_SENDER(0.30)[arrowd@freebsd.org,6yearold@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[175.210.85.209.rep.mailspike.net : 127.0.0.17]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[arrowd@freebsd.org,6yearold@gmail.com]; RCVD_TLS_ALL(0.00)[]; TO_DOM_EQ_FROM_DOM(0.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Nov 2019 10:50:50 -0000 Hello, hackers@ I'm facing an issue that I'm unable to debug, so decided to ask for an advice here. The project I'm working on is bsdisks - an implementation of UDisks2 daemon for FreeBSD. Amongst other things it tries to find out if a gived disk (from a list reported by geom disk list) has "removable" property. For that, it run the same code that `camcontrol identify && camcontrol inquiry` runs [1]. However, I got reports that this code causes the following error message when bsdisks is run on a FreeBSD system virtualized under VirtualBox: ata0: already running! ata0: timeout waiting for ATAPI ready ata0: error issuing ATA PACKET command Right after this message the system goes into a strange state, when It can't run any new processes. After a while, the system hangs completely with additional message, something like "out of memory", but I can't reproduce it now. The strangest thing is that this error can be reproduced **once per host reboot**. That is, restarting a VM causes the problem to go away. To reproduce the hang again, I have to reboot host machine (even unloading/loading vbox kernel modules doesn't work). I tried to create a minimal reproducing program, but failed. Just calling cam_is_removable() from empty main() doesn't trigger the hang. I also tried simulating race conditions by calling cam_is_removalbe from different threads, as well as using mutex in bsdisks - still no luck. I'm completely lost there, so hoping someone can shed some light on this heisenbug. Reproduction steps are as simple as # pkg install bsdisks # bsdisks on both FreeBSD 11 and 12 in a VirtualBox VM. Thanks in advance. [1] https://bitbucket.org/arrowd/bsdisks/src/3e6fcb56763c14afb55c69cad3703543de41373f/camcontrol.c#lines-179