Commit graph

26850 commits

Author SHA1 Message Date
Andreas Kling 2f790cf78f Kernel: Make MM.commit_user_physical_pages() return KResultOr
..and use TRY() at call sites. :^)
2021-09-06 01:55:27 +02:00
Andreas Kling 98dc08fe56 Kernel: Use KResultOr better in ProcessGroup construction
This allows us to use TRY() more.
2021-09-06 01:55:27 +02:00
Andreas Kling 540d62d3b2 Kernel: Simplify WatchDescription::create() 2021-09-06 01:55:27 +02:00
Andreas Kling 5e2bae700d Kernel: Use TRY() in PTYMultiplexer::open() 2021-09-06 01:55:27 +02:00
Andreas Kling 4d961387c1 Kernel: Use TRY() some more in USB::Hub 2021-09-06 01:55:27 +02:00
Andreas Kling 8ceff65161 Kernel: Use TRY() some more in FileDescription 2021-09-06 01:55:27 +02:00
Andreas Kling 5516592748 Kernel: Use TRY() in BlockBasedFileSystem 2021-09-06 01:55:27 +02:00
Andrew Kaster fe701052ea LibC: Expand region for global destructors when it reaches capacity
In 553361d we started mprotecting the atexit handlers when they are not
being modified or executed. As part of that commit, we unintentionally
changed the max number of global destructors from 1024 to 256 (on x86,
only 128 on x86_64). This patch expands the initial size of the global
destructors page to 2 pages from 1, and allows the pool to be expanded
at runtime by mapping a new set of pages and copying the AtExitEntries
over.
2021-09-06 01:55:14 +02:00
Ali Mohammad Pur 7589cc2494 LibJS: Handle possible allocation failure in ArrayBuffer(size_t)
...by replacing it with a ctor that takes the buffer instead, and
handling the allocation failure in ArrayBuffer::create(size_t) by
throwing a RangeError as specified by the spec.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur d20fc922c5 Meta: Correct misuse of ByteBuffer::resize() as grow() in FuzziliJS 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur 97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +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
Ali Mohammad Pur 6606993432 AK: Add OOM-safe ByteBuffer::try_{resize,append,ensure_capacity}() APIs 2021-09-06 01:53:26 +02:00
Linus Groh 6ffc8f389e LibJS: Use different stack space limit values for with and without ASAN
Instead of having a single limit here, which we had to increase once to
work with ASAN enabled, check whether HAS_ADDRESS_SANITIZER is defined
and use 32 KiB, and 16 KiB otherwise (which is what we used previously).

This idea is shamelessly stolen from V8:
https://github.com/v8/v8/blob/b2b44af/src/execution/isolate.cc#L1381-L1387
2021-09-05 22:17:09 +01:00
Linus Groh 941ff0cf60 LibJS: Prevent stack overflow if Proxy handler's __proto__ is the Proxy
Fixes #9322.
2021-09-05 22:17:09 +01:00
Linus Groh 9998a2c91e LibJS: Add ErrorType::CallStackSizeExceeded
I'm about to add another use of this, so let's add an ErrorType for it
instead of hardcoding the message for a third time.
2021-09-05 22:17:09 +01:00
Brian Gianforcaro 782e7834c3 Tests: Reduce the execution time of the LibC TestQSort test
Executing 100 times vs 10 times doesn't increase test coverage
substantial, this API is stable and more iterations is just a
waste of time.

Without KVM this test is a clear outlier in runtime during CI:

```
START  LibC/TestQsort (106/172)
PASS   LibC/TestQsort (41.233692s)
```
2021-09-05 22:17:28 +02:00
Brian Gianforcaro bb58a4d943 Kernel: Make all Spinlocks use u8 for storage, remove template
The default template argument is only used in one place, and it
looks like it was probably just an oversight. The rest of the Kernel
code all uses u8 as the type. So lets make that the default and remove
the unused template argument, as there doesn't seem to be a reason to
allow the size to be customizable.
2021-09-05 20:46:02 +02:00
Brian Gianforcaro 5905d2e9e9 RequestServer: Exit early to avoid executing protocol destructors
I broke this when I made the protocol objects be wrapped by smart
pointers to appease static analysis.

The Protocol base class currently VERIFY's that it's never called.
So to have the best of both worlds until someone actually fixes
the code to do proper de-registration, just call `exit(..)` so the
smart pointers never go out of scope.
2021-09-05 20:12:09 +02:00
Brian Gianforcaro 293e7ccfc7 Documentation: Add Patterns.md
The purpose of this document is to track and describe the various
patterns used through the SerenityOS code base.
2021-09-05 20:08:57 +02:00
Brian Gianforcaro 3e45c3ed90 Userland: Switch static_assert of type sizes to AK::AssertSize 2021-09-05 20:08:57 +02:00
Brian Gianforcaro 472454cded Kernel: Switch static_asserts of a type size to AK::AssertSize
This will provide better debug ability when the size comparison fails.
2021-09-05 20:08:57 +02:00
Brian Gianforcaro 112de58fe0 AK: Add AssertSize utility template to provide rich type size assertions
This type is useful, as the sizes will be visible in the compiler error
messages, as they will be part of the template parameters. This is not
possible with a normal static_assert of the sizeof a type.
2021-09-05 20:08:57 +02:00
Andreas Kling 100b3835f0 Kernel: Use TRY() in DevFSLinkInode::write_bytes() 2021-09-05 19:02:57 +02:00
Andreas Kling 667a39df6b Kernel: Use TRY() in ProcFS 2021-09-05 19:01:38 +02:00
Andreas Kling caaeae9607 Kernel: Make FileSystem::get_inode() return KResultOr<NRP<Inode>>
This allows for natural error propagation in a bunch of new places.
2021-09-05 18:55:55 +02:00
Andreas Kling 12d9a6c1fa Kernel: Use TRY() in sys$waitid() 2021-09-05 18:42:32 +02:00
Andreas Kling c076d765c4 Kernel: Simplify sys$inode_watcher_remove_watch() a little bit 2021-09-05 18:41:28 +02:00
Andreas Kling d912bfdf38 Kernel: Use TRY() in sys$create_inode_watcher() and friends 2021-09-05 18:41:01 +02:00
Andreas Kling a9204510a4 Kernel: Make file description lookup return KResultOr
Instead of checking it at every call site (to generate EBADF), we make
file_description(fd) return a KResultOr<NonnullRefPtr<FileDescription>>.

This allows us to wrap all the calls in TRY(). :^)

The only place that got a little bit messier from this is sys$mount(),
and there's a whole bunch of things there in need of cleanup.
2021-09-05 18:36:13 +02:00
Andreas Kling 2d2ea05c97 Kernel: Use TRY() in sys$sethostname() 2021-09-05 18:22:18 +02:00
Andreas Kling 963f847579 Kernel: Use TRY() in sys$mount() 2021-09-05 18:20:57 +02:00
Andreas Kling 3580c5a72e Kernel: Use TRY() in sys$umount() 2021-09-05 18:18:23 +02:00
Andreas Kling 76f2596ce8 Kernel: Use TRY() in sys$set_process_name() 2021-09-05 18:17:06 +02:00
Andreas Kling 53aa01384d Kernel: Use TRY() in sys$set_coredump_metadata() 2021-09-05 18:15:42 +02:00
Andreas Kling bfe4c84541 Kernel: Use TRY() in sys$create_thread() 2021-09-05 18:15:05 +02:00
Andreas Kling 257fa80312 Kernel: Use TRY() in sys$set_thread_name() 2021-09-05 18:15:05 +02:00
Andreas Kling afc5bbd56b Kernel: Use TRY() in sys$write() 2021-09-05 18:15:05 +02:00
Andreas Kling 17933b193a Kernel: Use TRY() in sys$perf_register_string() 2021-09-05 18:15:05 +02:00
Andreas Kling 77b7a44691 Kernel: Use TRY() in sys$recvfd() 2021-09-05 18:15:05 +02:00
Andreas Kling ea911bc125 Kernel: Use TRY() in sys$pledge() 2021-09-05 18:15:05 +02:00
Andreas Kling 95e74d1776 Kernel: Use TRY() even more in sys$mmap() and friends :^) 2021-09-05 18:15:05 +02:00
Andreas Kling cf2c04eb13 Kernel: Use TRY() in sys$dbgputstr() 2021-09-05 18:15:05 +02:00
Andreas Kling 6dddd500bf Kernel: Use TRY() in sys$map_time_page() 2021-09-05 18:15:05 +02:00
Andreas Kling d53c60fd9f Kernel: Use TRY() in sys$setkeymap() 2021-09-05 18:15:05 +02:00
Andreas Kling 1f475f7bbc Kernel: Use TRY() in sys$realpath() 2021-09-05 18:15:05 +02:00
Andreas Kling 4ea3dc77f0 Kernel: Use TRY() in sys$statvfs() 2021-09-05 18:15:05 +02:00
Andreas Kling 7efa742a39 Kernel: Use TRY() in sys$stat() 2021-09-05 17:58:08 +02:00
Andreas Kling de2c1bc5c3 Kernel: Use TRY() in sys$unlink() 2021-09-05 17:56:40 +02:00
Andreas Kling 4e4b7c272c Kernel: Use TRY() in sys$readlink() 2021-09-05 17:55:43 +02:00