Page MenuHomeFreeBSD

savecore: uncompress cores
ClosedPublic

Authored by glebius on Nov 16 2020, 10:22 PM.
Tags
None
Referenced Files
F81677542: D27245.diff
Fri, Apr 19, 7:27 PM
Unknown Object (File)
Mar 11 2024, 6:17 PM
Unknown Object (File)
Mar 11 2024, 6:17 PM
Unknown Object (File)
Mar 11 2024, 6:17 PM
Unknown Object (File)
Mar 11 2024, 6:17 PM
Unknown Object (File)
Mar 11 2024, 6:17 PM
Unknown Object (File)
Mar 11 2024, 6:16 PM
Unknown Object (File)
Mar 8 2024, 3:07 AM
Subscribers

Details

Summary

A real life scenario is that cores are compressed to reduce
size of dumpon partition, but we either don't care about space
in the /var/crash or we have a filesystem level compression of
/var/crash. And we want cores to be uncompressed in /var/crash
because we'd like to instantily read them with kgdb.

In this case we want kernel to write cores compressed, but
savecore(1) write them uncompressed.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34866
Build 31889: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Nov 16 2020, 10:53 PM
bcr added a subscriber: bcr.

OK from manpages.

Shouldn't this also include a change to default savecore_flags in /etc/defaults/rc.conf?

This patch doesn't support ZSTD yet, since the library isn't yet installed in the base system and I'm reluctant to statically compile it into savecore(1).

It's there, it's just a private lib: /usr/lib/libprivatezstd.so.5

sbin/savecore/savecore.c
786

Why not set uncompress = false here too?

Add ZSTD support and address comments.

This revision now requires review to proceed.Nov 17 2020, 9:02 PM

Shouldn't this also include a change to default savecore_flags in /etc/defaults/rc.conf?

I don't want to change the default behavior.

Looks fine to except some nits.

sbin/savecore/savecore.c
594

The compression == KERNELDUMP_COMP_* cases should be lifted into their own subroutines IMO.

1024

It is easier to understand this when written as (iscompressed && !uncompress) || compress).

Separate decompression loops into their own subroutines. Reword
logical statement.

Some extra cruft slept in previous update.

glebius marked an inline comment as done.
markj added inline comments.
sbin/savecore/savecore.c
512

sizeof(z)

528

Static analyzers will complain that this buffer is leaked. I know it's not a real problem, but it's also easy to fix.

529

There's a missing newline here.

569

I think compression != KERNELDUMP_COMP_NONE is preferable.

This revision is now accepted and ready to land.Nov 19 2020, 2:13 AM
glebius added inline comments.
sbin/savecore/savecore.c
528

Yes. But function has several returns with different allocation conditions. Make it "right" everywhere would make it really hairy.

sbin/savecore/savecore.c
528

You would have to add three free(zbuf) calls, relying on the fact that zbuf is initialized to NULL and that free(NULL) is valid. Not really that hairy. Someone else is inevitably going to come along and fix it anyway, for better or worse, so IMO it's better to just do it now.

sbin/savecore/savecore.c
528

To do it properly the zstd context also needs to be freed, and this is where it gets hairy.