From patchwork Fri Apr 11 15:09:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 880388 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF3C71F461D; Fri, 11 Apr 2025 15:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; cv=none; b=Tyc+4k8O2rhbUoLi6uNuCgXa5FYYmNq5U8eVAWd3H+pX95bPzlnxGqV1nHn/Fe3SRu5HRKWmTKoU8b/lTzKuOkv8/Hq8pVR+LrqvWms2Onyr22dR+yjybp6gt5tdFBZ+MnX8z1UdZW1EH3Z0AekDawGoVTrX45if0ei+Og+4b/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; c=relaxed/simple; bh=d76UNAhJL2/CvDF5iXg10Cq43S1hVRfl9792k5Y/A0U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k+K4fzTyF8MIfgqkYezQbGGiOCnwyTJV+04RXD5QfbbI4a54G75hsBC/hg8UiTyv0tmYCTv+g4AOv0jrgm2PT39F8xiPG57whVGNGQLWNuIRn7GQ7A3yAjG+WAcZi5074ctJX8et24NLctaJcwN4h6qE2NBwpYqS2vhCO2WHmFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kAFYGY1g; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sdqL+MEy; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kAFYGY1g"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sdqL+MEy" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+on7q0d2sKsDinQinkGf21gwhzzeN5z9itT+eLeiG8=; b=kAFYGY1gu6Y1HDzU+BWH7JTJVf/lZgE9f2YKBKE4fD3C08q5v9cZI+Umc0oI4YzfR/ukfM 2b7XUYFIg4HybLgsZd/+Nhuaoaym8W5PrXQiMRh9sLdvavZi+wf0JOt3O6KPvwZ34uLvxH HPYNPxTebFKKVpPxAwZfkldY/R3XUjuYu3bXLzYSGb+abaKQBsyZmwAs8+CCCVD0KQOGXH B3u3Wci5ldL2sidJ4TgoR+tgRU+tGV4qbEUaL+CQjmNswaFUSQ1BQswW2qG2PiOedsyh6k 03bJzilk1pwzOF3wiYvL/LbQH1mCxnhfAGkwDQPdV27FYk9eof7z5TDWWL8Aeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+on7q0d2sKsDinQinkGf21gwhzzeN5z9itT+eLeiG8=; b=sdqL+MEyxoyCN2Wg6HKr3EESb75s7XE21+l21rQ/EQdtjWjihyhKNkYUyPrAwYjUXMIRzm Wi8KZSJK7mIEzhAw== To: Christian Brauner Cc: Shuah Khan , John Ogness , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nam Cao Subject: [PATCH v2 1/3] selftests: coredump: Properly initialize pointer Date: Fri, 11 Apr 2025 17:09:41 +0200 Message-Id: <4fb9b6fb3e0040481bacc258c44b4aab5c4df35d.1744383419.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The buffer pointer "line" is not initialized. This pointer is passed to getline(). It can still work if the stack is zero-initialized, because getline() can work with a NULL pointer as buffer. But this is obviously broken. This bug shows up while running the test on a riscv64 machine. Fix it by properly initializing the pointer. Fixes: 15858da53542 ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao --- tools/testing/selftests/coredump/stackdump_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c index 137b2364a082..c23cf95c3f6d 100644 --- a/tools/testing/selftests/coredump/stackdump_test.c +++ b/tools/testing/selftests/coredump/stackdump_test.c @@ -138,10 +138,12 @@ TEST_F(coredump, stackdump) ASSERT_NE(file, NULL); /* Step 4: Make sure all stack pointer values are non-zero */ + line = NULL; for (i = 0; -1 != getline(&line, &line_length, file); ++i) { stack = strtoull(line, NULL, 10); ASSERT_NE(stack, 0); } + free(line); ASSERT_EQ(i, 1 + NUM_THREAD_SPAWN); From patchwork Fri Apr 11 15:09:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 880654 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5571F204C09; Fri, 11 Apr 2025 15:09:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; cv=none; b=hVsbitNoVgkf5ap4pZb4irk9rnnFKiISpHHXMSAEu+l0C8Sa1fcZnrzVJVKDYQRdH5gbnJxT7t5jxTeFFIQnAsoe51dBr9ZO6FQng3eQSrHzSDSfxHSD0tIP0NUrYOYX7LRdqNloxaafxt6yqH+EGaUlBALnat02+5toJttauZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; c=relaxed/simple; bh=JegbAesfKsXVnJ7Bg4TxFD5E25Z3OL2aVo6miAOwyOE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z8vwCvEkqMNuR1epiThkLWo0RAKr5k53SuGWikKj17vzv3akcwa2W4coTF/cdq8ZznvHcqQoN/jEJQgXEWEvUsCLmKw8uD13ecb0QxI429lGJmpwsUvzrjgYKpUmn+RGqUycQ22G2mMKRa88+MOizFzBpfukMdK5uzmvyWx6vxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ruo6dH/x; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CqakS8R9; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ruo6dH/x"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CqakS8R9" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oYQXJ3zmI4IiPEkNK58wbFDZKNRbM19pIX0dWKh4BBs=; b=Ruo6dH/x1Ezha0DfOd6a6sukapG75VMltxom7mmAJ2dampz2cEW9tPiRD3GdsiGQCigtFv SYT0iop2Cx7JB3DHaZhPbZ0NfxeCx1Gg67Kc7MVOcTtWF1CHCz1oKHgMXUPlNOqYm8zo0+ WCrvBf61uyFn5QKzXHlV+rDLgC6oa2G37oqg7I7JRJ6x4/DmQxnGRDCw6TvdB5C20Zk7mM df14kKKpV3f/ytd6OHgRmSFWROhVvSdWxVMM1QUbI8+VvVDA2hh/b4XW3k271TyUN1VxzM tvFbUdp2/YFQfy2YxdaE9DR2F09tEmQMUIUw/Gx3nSmanMh4JtxBw16w/oSR3A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oYQXJ3zmI4IiPEkNK58wbFDZKNRbM19pIX0dWKh4BBs=; b=CqakS8R9lkjMMSd16aTHqSrr6OJUziqdUkHzEBAN6Rrf8TEIYBiPbU9mrraMHq0SxGTVNL giy0pFRpLd0COxBg== To: Christian Brauner Cc: Shuah Khan , John Ogness , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nam Cao Subject: [PATCH v2 2/3] selftests: coredump: Fix test failure for slow machines Date: Fri, 11 Apr 2025 17:09:42 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The test waits for coredump to finish by busy-waiting for the stack_values file to be created. The maximum wait time is 10 seconds. This doesn't work for slow machine (qemu-system-riscv64), because coredump takes longer. Fix it by waiting for the crashing child process to finish first. Fixes: 15858da53542 ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao --- tools/testing/selftests/coredump/stackdump_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c index c23cf95c3f6d..9da10fb5e597 100644 --- a/tools/testing/selftests/coredump/stackdump_test.c +++ b/tools/testing/selftests/coredump/stackdump_test.c @@ -96,7 +96,7 @@ TEST_F(coredump, stackdump) char *test_dir, *line; size_t line_length; char buf[PATH_MAX]; - int ret, i; + int ret, i, status; FILE *file; pid_t pid; @@ -129,6 +129,10 @@ TEST_F(coredump, stackdump) /* * Step 3: Wait for the stackdump script to write the stack pointers to the stackdump file */ + waitpid(pid, &status, 0); + ASSERT_TRUE(WIFSIGNALED(status)); + ASSERT_TRUE(WCOREDUMP(status)); + for (i = 0; i < 10; ++i) { file = fopen(STACKDUMP_FILE, "r"); if (file) From patchwork Fri Apr 11 15:09:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 880387 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 556C5204840; Fri, 11 Apr 2025 15:09:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; cv=none; b=JiWO0QsLZ5t1R9csN2k8atHuCQRJQLlnMQpaEkxgwfoKCA90o6yJ7MD2xppbybcFuYUm8bupM1/q+I/r96DrUfGxti9yL6TMJxb+Xg3vL/juDmXWggf6VZh1ZMYGV/ElkgDmMI4x8k1tnfjH4trEWgrAgTncx1X0NaZ0ZG5sN5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; c=relaxed/simple; bh=ug2x1eGGc/292yTUbC2yb/U4/i1fnrOBUIn136WaKcA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EXPRXGVyDp6uZZJWmPhv9uYZLXHch+oxzeTIHl7sNJAK+bn9MrbxNaXl6PB4isSAVeqq4qj/D9ArrG4AfuxpxG6uIXm1XGc0sFL5TyKfYMUltsdNV1yyhRJ6OkZlgiy372ilZC+pLaGo5+azkvWIxv9Epx2A1VeqLEEazZTQdX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GKqMeb/X; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=O3OuGrdY; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GKqMeb/X"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="O3OuGrdY" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=332I2pBj+SBhHax9EjMYVSa2gzrL4NUN8QjGS26dHIo=; b=GKqMeb/XR+JqRmUD+nJZeLoT0UC6xJTXpISZj3PT3EbgK2Y0Hh/a9nnsO1/2gq9Qj01aIf rk6PTTi0dBwFkC95eeJtYsnq4qyCOT7nT2RlfwHZTCqUIGzHVZstbNFnP9wrybDfsFoCMQ MdunhtyIjbifvMRjghDCEMldKkZDiE+PgLYzfaxUa+PpjgqcRIxlDjN4m2y/oKvmpmLnvE kpryZRGpJP4uBy+0zBQrTP9jNyHvoB2TJpjvAevbs/Zq0/lVePz12ATedcoBnm/1Et+GAT rt5V21OFe5hjyo0RccIpXOQnH7OqtSDeu37mNjfpg7FdJ2NIbo0Pq7CPS687fA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=332I2pBj+SBhHax9EjMYVSa2gzrL4NUN8QjGS26dHIo=; b=O3OuGrdY1JKU8Y3KijiyS9zzmzl5OILbG7Duu8Lh1ajgl8CNNzzr7aAglNrmN/oGseO9oi Gawd2fLmZQOoYKAw== To: Christian Brauner Cc: Shuah Khan , John Ogness , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nam Cao Subject: [PATCH v2 3/3] selftests: coredump: Raise timeout to 2 minutes Date: Fri, 11 Apr 2025 17:09:43 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The test's runtime (nearly 20s) is dangerously close to the limit (30s) on qemu-system-riscv64: $ time ./stackdump_test > /dev/null real 0m19.210s user 0m0.077s sys 0m0.359s There could be machines slower than qemu-system-riscv64. Therefore raise the test timeout to 2 minutes to be safe. Fixes: 15858da53542 ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao --- tools/testing/selftests/coredump/stackdump_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c index 9da10fb5e597..fe3c728cd6be 100644 --- a/tools/testing/selftests/coredump/stackdump_test.c +++ b/tools/testing/selftests/coredump/stackdump_test.c @@ -89,7 +89,7 @@ FIXTURE_TEARDOWN(coredump) fprintf(stderr, "Failed to cleanup stackdump test: %s\n", reason); } -TEST_F(coredump, stackdump) +TEST_F_TIMEOUT(coredump, stackdump, 120) { struct sigaction action = {}; unsigned long long stack;