mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts: decode_stacktrace: preserve input while reading lines
@ 2026-11-03 16:42 Hamdy Abou El Anein
  2026-11-03 17:26 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Hamdy Abou El Anein @ 2026-11-03 16:42 UTC (permalink / raw)
  To: sashal; +Cc: hamdy.aea, linux-kernel

From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>

Plain read strips leading and trailing whitespace and interprets
backslashes before the decoder sees a line. It also drops a final line
without a newline. This loses log text and defeats the alignment
preservation in handle_line().

Read with an empty IFS and -r, and process a nonempty final fragment.

Tested passthrough text with indentation, backslashes and trailing
spaces, plus a real debug-enabled object and stack entries terminated
by LF, CRLF or EOF. All three stack entries decode with their original
indentation.

AI assistance: ChatGPT/Codex identified the issue and prepared the
change, commit message and executable regression tests.

Fixes: dbd1abb20971 ("decode_stacktrace: make stack dump output useful again")
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
 scripts/decode_stacktrace.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 39d60d477bf..8b06810d463 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -346,7 +346,7 @@ handle_line() {
 	echo "${spaces[$last]}${symbol}${module:+ ${module}}${info_str:+ ${info_str}}"
 }
 
-while read line; do
+while IFS= read -r line || [[ -n $line ]]; do
 	# Strip unexpected carriage return at end of line
 	line=${line%$'\r'}
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts: decode_stacktrace: preserve input while reading lines
  2026-11-03 16:42 [PATCH] scripts: decode_stacktrace: preserve input while reading lines Hamdy Abou El Anein
@ 2026-11-03 17:26 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-03 17:26 UTC (permalink / raw)
  To: Hamdy Abou El Anein
  Cc: Hamdy Abou El Anein, Andrew Morton, Matthieu Baerts (NGI0),
	linux-kernel, Sasha Levin

On Tue, Nov 03, 2026 at 05:42:03PM +0100, Hamdy Abou El Anein wrote:
>Plain read strips leading and trailing whitespace and interprets
>backslashes before the decoder sees a line. It also drops a final line
>without a newline. This loses log text and defeats the alignment
>preservation in handle_line().
>
>Read with an empty IFS and -r, and process a nonempty final fragment.

One optional follow-up: debuginfod_get_vmlinux() takes the build ID with ${1##*
}, so trailing whitespace after the build ID now gives an empty ID and the
lookup fails. The kernel never prints that, since the build ID always ends the
line, so it only matters for logs edited after the fact.

Acked-by: Sasha Levin <sashal@kernel.org>

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-03 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 16:42 [PATCH] scripts: decode_stacktrace: preserve input while reading lines Hamdy Abou El Anein
2026-11-03 17:26 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®