From patchwork Fri Apr 12 15:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1084792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=kalray.eu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kalray.eu header.i=@kalray.eu header.b="az+sueMt"; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44ghHq1FGlz9s47 for ; Sat, 13 Apr 2019 01:13:56 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 1BA4E10133; Fri, 12 Apr 2019 17:13:51 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from zimbra2.kalray.eu (zimbra2.kalray.eu [92.103.151.219]) by helium.openadk.org (Postfix) with ESMTPS id B13A81012C for ; Fri, 12 Apr 2019 17:13:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 344E327E0454 for ; Fri, 12 Apr 2019 17:13:50 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OBpYXVDF9Dz9; Fri, 12 Apr 2019 17:13:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id C8B5927E044D; Fri, 12 Apr 2019 17:13:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu C8B5927E044D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1555082029; bh=X2XMxwZ6eIHTMkM5QJWnUwhW7ohCT6nHqcYq8IFXbx8=; h=From:To:Date:Message-Id:MIME-Version; b=az+sueMtqjKmXf0OO1Mfz+v6h2BBKc3w/R29QgTvZAAPbKdxXCx1R+0pnjESx1uvw ikYUzlP7slgWpWlYSKerwVbk4Il8lh2HGZPs5B3IepZLGj7LYzk3WNjXwMFHesWQM+ P0A/nW+SXPVYXEJwUsi3TTwoh/WF7YiP83Zwdb94= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id siIR2oaO9h5u; Fri, 12 Apr 2019 17:13:49 +0200 (CEST) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id A6B2B27E03E9; Fri, 12 Apr 2019 17:13:49 +0200 (CEST) From: Yann Sionneau To: devel@uclibc-ng.org Date: Fri, 12 Apr 2019 17:13:22 +0200 Message-Id: <20190412151322.27082-1-ysionneau@kalray.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [uclibc-ng-devel] [PATCH] Fix tst-mallocfork test X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" This test was changed from using fork to vfork by: https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=822e4896c1072b9f84b17f4f7bcb7c51d1a57723 This change was wrong because man page says the child of vfork() must ONLY do either: - a call to one of exec(2) - a call to _exit(2) - get killed by a signal BUT the test case does: - a call to kill - and also a call to exit(3) and not _exit(2) This test produces a double free() causing assert in free because this is called several times: https://elixir.bootlin.com/uclibc-ng/latest/source/libc/stdlib/_atexit.c#L270 So, it seems wrong both in theory (according to man page) and in fact in practice (assert in free). Here I propose to get back to testing fork(), which is the original test case from: https://sourceware.org/bugzilla/show_bug.cgi?id=838 And to just "PASS" on no-mmu systems. For the record, here is the assert call stack: FAIL tst-mallocfork got 1 expected 0 ./tst-mallocfork: libc/stdlib/malloc-standard/malloc.c: 149: __do_check_inuse_chunk: Assertion `((((mchunkptr)(((char*)(p))+((p)->size & ~0x1)))->size) & 0x1)' failed. Didn't expect signal from child: got `Aborted' 0 free (mem=0x3a010) at libc/stdlib/malloc-standard/free.c:285 1 0x00000000000220c4 in __exit_handler (status=1) at libc/stdlib/_atexit.c:270 2 0x000000000001afa0 in __GI_exit (rv=1) at libc/stdlib/_atexit.c:301 3 0x0000000000010dcc in main (argc=1, argv=0x7ffffffd98) at ../test-skeleton.c:405 4 0x000000000001cba8 in __uClibc_main (main=0x10988
, argc=1, argv=0x7ffffffd98, app_init=0x100e8, app_fini=0x23918 <_fini>, rtld_fini=0x0 , stack_end=0x7ffffffd90) at libc/misc/internals/__uClibc_main.c:512 5 0x00000000000eb8b8 in ?? () Signed-off-by: Yann Sionneau --- test/malloc/tst-mallocfork.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/malloc/tst-mallocfork.c b/test/malloc/tst-mallocfork.c index edd9c39..e9e5133 100644 --- a/test/malloc/tst-mallocfork.c +++ b/test/malloc/tst-mallocfork.c @@ -9,10 +9,12 @@ #include #include "../test-skeleton.h" +#ifdef __ARCH_USE_MMU__ + static void sig_handler (int signum) { - pid_t child = vfork (); + pid_t child = fork (); if (child == 0) exit (0); TEMP_FAILURE_RETRY (waitpid (child, NULL, 0)); @@ -35,7 +37,7 @@ do_test (void) } /* Create a child that sends the signal to be caught. */ - pid_t child = vfork (); + pid_t child = fork (); if (child == 0) { if (kill (parent, SIGALRM) == -1) @@ -48,5 +50,16 @@ do_test (void) return 0; } +#else + +static int +do_test (void) +{ + printf("Skipping test on non-mmu host!\n"); + return EXIT_SUCCESS; +} + +#endif + #define TEST_FUNCTION do_test () #include "../test-skeleton.c"