From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 05/15] build: syscalls: Add clone syscall wrapper. Date: Sat, 11 Jul 2015 12:18:37 +0200 Message-ID: <87fv4v575u.fsf@gnu.org> References: <1436188604-2813-1-git-send-email-dthompson2@worcester.edu> <1436188604-2813-5-git-send-email-dthompson2@worcester.edu> <87r3okje4c.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDrru-00005u-Rr for guix-devel@gnu.org; Sat, 11 Jul 2015 06:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDrrp-0007qo-OL for guix-devel@gnu.org; Sat, 11 Jul 2015 06:18:50 -0400 In-Reply-To: (David Thompson's message of "Tue, 7 Jul 2015 20:28:16 -0400") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: "Thompson, David" Cc: guix-devel , David Thompson There=E2=80=99s something fishy when running the tests. If you comment out= the =E2=80=9Csetns=E2=80=9D and =E2=80=9Cpivot-root=E2=80=9D tests, you=E2=80= =99ll see that syscalls.log reads this: --8<---------------cut here---------------start------------->8--- %%%% Starting test syscalls Group begin: syscalls Test begin: test-name: "mount, ENOENT" source-file: "tests/syscalls.scm" source-line: 34 source-form: (test-equal "mount, ENOENT" ENOENT (catch (quote system-erro= r) (lambda () (mount "/dev/null" "/does-not-exist" "ext2") #f) (compose sys= tem-error-errno list))) [...] Test begin: test-name: "clone" source-file: "tests/syscalls.scm" source-line: 86 source-form: (test-assert "clone" (match (clone (logior CLONE_NEWUSER SIG= CHLD)) (0 (primitive-exit 42)) (pid (and (not (equal? (readlink (user-names= pace pid)) (readlink (user-namespace (getpid))))) (match (waitpid pid) ((_ = . status) (=3D 42 (status:exit-val status)))))))) %%%% Starting test syscalls Group begin: syscalls Test begin: test-name: "mount, ENOENT" source-file: "tests/syscalls.scm" source-line: 34 source-form: (test-equal "mount, ENOENT" ENOENT (catch (quote system-erro= r) (lambda () (mount "/dev/null" "/does-not-exist" "ext2") #f) (compose sys= tem-error-errno list))) [...] Group end: syscalls # of expected passes 14 --8<---------------cut here---------------end--------------->8--- Notice the second =E2=80=9CStarting test syscalls=E2=80=9D in the middle of= the =E2=80=9Cclone=E2=80=9D test. So it looks as though the child process started execution from the beginning of the file, yet somehow finished as expected (there=E2=80=99s on= ly one occurrence of =E2=80=9CGroup end=E2=80=9D.) Ideas? Another issue is the return value of =E2=80=98getpid=E2=80=99 in the child = process, which is the PID of the parent process as I reported earlier. This issue is actually documented in clone(2): Versions of the GNU C library that include the NPTL threading library contain a wrapper function for getpid(2) that performs caching of PIDs. This caching relies on support in the glibc wrapper for clone(), but as currently implemented, the cache may not be up to date in some circumstances. I wonder if there are other parts of libc state that may be broken after a raw =E2=80=98clone=E2=80=99. This may be fine if we call =E2=80=98exec= =E2=80=99 soon after =E2=80=98clone=E2=80=99, but otherwise could be problematic=E2=80=93e.g., for =E2=80=98call-with-con= tainer=E2=80=99. Perhaps we=E2=80=99ll have to revisit the syscall vs. wrapper choice? Ludo=E2=80=99.