Commit Graph

14 Commits

Author SHA1 Message Date
Andreas Kling
c0deafe457 Kernel: Avoid repeated memory zeroing while generating coredumps
Reuse the same buffer-full-of-zeroes for every un-paged-in page that we
dump out.
2021-11-21 20:22:48 +01:00
Andreas Kling
e1779b064a Kernel: Remove bogus TODO in coredump generation
When dumping the memory contents of a process, we should not page in
things from inodes that were not already paged in.
2021-11-21 20:22:48 +01:00
Andreas Kling
f2c3a41a8f Kernel: Make UserOrKernelBuffer::for_user_buffer() return ErrorOr<T>
This simplifies EFAULT propagation with TRY(). :^)
2021-11-21 20:22:48 +01:00
Andreas Kling
79fa9765ca Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace!
This was a slightly tedious refactoring that took a long time, so it's
not unlikely that some bugs crept in.

Nevertheless, it does pass basic functionality testing, and it's just
real nice to finally see the same pattern in all contexts. :^)
2021-11-08 01:10:53 +01:00
Andreas Kling
eeb4f2fa9b Kernel: Exclude userspace heap memory from coredumps by default
When a process with a large heap crashes (e.g WebContent), it gets very
cumbersome to dump out a huge amount of memory.

In the vast majority of cases, we're only interested in generating a
nice backtrace from the coredump, so let's have the kernel skip over
userspace heap regions when dumping memory for now.

This is not ideal, and almost a little bit ugly, but it does make
investigating 500 MiB WebContent crashes significantly easier for now.
2021-09-30 17:54:32 +02:00
Andreas Kling
dd82f68326 Kernel: Use KString all the way in sys$execve()
This patch converts all the usage of AK::String around sys$execve() to
using KString instead, allowing us to catch and propagate OOM errors.

It also required changing the kernel CommandLine helper class to return
a vector of KString for the userspace init program arguments.
2021-09-09 21:25:10 +02:00
Andreas Kling
300402cc14 Kernel: Make it possible for KBufferBuilder creation to fail
This patch adds KBufferBuilder::try_create() and treats it like anything
else that can fail. And so, failure to allocate the initial internal
buffer of the builder will now propagate an ENOMEM to the caller. :^)
2021-09-07 15:54:23 +02:00
Andreas Kling
4a9c18afb9 Kernel: Rename FileDescription => OpenFileDescription
Dr. POSIX really calls these "open file description", not just
"file description", so let's call them exactly that. :^)
2021-09-07 13:53:14 +02:00
Andreas Kling
69b9b2888c Kernel: Don't allocate so much when generating coredumps
Instead of creating a bunch of ByteBuffers and concatenating them to
generate the "notes" segment, we now simply create a KBufferBuilder
and tell each of the notes generator helpers to write into the builder.

This allows the code to flow more naturally, with some bonus additional
error propagation. :^)
2021-09-06 18:56:51 +02:00
Andreas Kling
60eea6940f Kernel: Tidy up Coredump construction
- Use KResultOr and TRY to propagate errors
- Return more specific errors now that they have a path out from here
2021-09-06 18:56:51 +02:00
Andreas Kling
c11c0fe453 Kernel: Use TRY() in Coredump 2021-09-06 18:56:51 +02:00
Andreas Kling
f16b9a691f Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcher 2021-09-06 18:56:51 +02:00
Ali Mohammad Pur
3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Andreas Kling
bcd2025311 Everywhere: Core dump => Coredump
We all know what a coredump is, and it feels more natural to refer to
it as a coredump (most code already does), so let's be consistent.
2021-08-23 00:02:09 +02:00