kernel panic cause file change to many "^@^@^@^@"

62 views
Skip to first unread message

Insuper Chang

unread,
Dec 8, 2021, 5:01:01 AM12/8/21
to Chromium OS Development
I write a shell script to do unit test with Linux commands (ex: ifconfig, insmod/rmmod),
but in some test case will cause kernel panic,
and the panic will cause the config file which uses to read/write for saving test state change to
"^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@".
Does anyone know how to avoid kernel modify the file when crash?
Thanks!

ggg

unread,
Dec 8, 2021, 2:52:23 PM12/8/21
to Chromium OS Development, gary8...@gmail.com
On Wednesday, December 8, 2021 at 2:01:01 AM UTC-8 gary8...@gmail.com wrote:
I write a shell script to do unit test with Linux commands (ex: ifconfig, insmod/rmmod),
but in some test case will cause kernel panic,
and the panic will cause the config file which uses to read/write for saving test state change to
"^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@".

FTR, "^@" is ASCII for 0x00 byte value.
 
Does anyone know how to avoid kernel modify the file when crash?
 
1) Modify the test framework to use the config file to be read-only and write the test state to a different file?

2) Use O_DSYNC?

Otherwise I don't. We often see this in the pstore buffer dumps described here:

My theory is this happens when the meta data (file length) is updated (and stored "on disk") and the payload data is not.  This is an "artifact" of asynchronous IO.

I suspect you are asking this since you aren't able to determine which syscall (or other beharior) is triggering the kernel panic. You'll have to learn how to use kdump or printk + pstore to unravel what is causing the kernel panic.

cheers,
grant
 
Thanks!

Oleg Davydov

unread,
Dec 10, 2021, 9:38:24 AM12/10/21
to Chromium OS Development, ggg, gary8...@gmail.com
A lot of zeros in the file sounds like an expected behaviour in case of kernel panic during writing to that file, unfortunately. Imagine, for example, that kernel panic happens right after we've dumped metadata (allocated blocks or something like that) on the disk, but before we've writed actual data (from the cache)...

I'd suggest trying a different write strategies. Like, write to a temporary file in the same directory, fsync it, then rename to the target file (in hope that renaming a file is an atomic operation for the file system).

Insuper Chang

unread,
Dec 20, 2021, 7:30:04 AM12/20/21
to Chromium OS Development, buru...@google.com, ggg, Insuper Chang
Thank guys suggestion,

I use the file name to save test state, and use the "mv" command to update test state,
and use the "sync" command to flush data to disk, it records more data before kernel crash.

Thanks !

buru...@google.com 在 2021年12月10日 星期五下午10:38:24 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages