Commit graph

20682 commits

Author SHA1 Message Date
Linus Groh
947ea92bf6 LibJS: Convert ArrayBuffer::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
91b0123eaf LibJS: Convert Array::create{,_from}() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
0c50751c13 LibJS: Convert AggregateError::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
2b92c15b34 LibJS: Convert Accessor::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Timothy Flynn
0ec433edce LibJS: Explictly assert that a null GCPtr is not dereferenced 2022-12-14 09:59:35 +00:00
Luke Wilde
ce39c907fd LibJS: Support MM/DD/YYYY HH:MM <timezone-offset> format for Date
Required by Discord to determine if it should show Christmas themed
loading tips on the loading screen.
Fixes #16473.
2022-12-13 21:42:28 +00:00
Drew DeVault
c7f8d74c1c LibCore: Fix struct msghdr initialization
The previous approach could leave behind uninitialized fields on
platforms which have additional fields in this structure (e.g. padding
fields on musl libc).
2022-12-13 10:12:59 -08:00
kleines Filmröllchen
a06b277471 LibIPC: Support sending Variants over IPC
The format is quite simply the type index followed by the type in its
own native encoding; just implementing the receive side with static
typing is a bit convoluted. The only limitation of this implementation
is that the variant type has to contain an Empty somewhere as it is not
default constructible otherwise.

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2022-12-13 10:24:59 -05:00
Cody Hein
8855334fcc PixelPaint: Use source alpha for CloneTool drawing
Prior to this change when using CloneTool on a transparent background
the output was a solid black brush stroke. Now it is based on the
source content alpha as well as it's color blended with the target.
2022-12-13 11:35:25 +01:00
Daniel Bertalan
24d2c90a28 BindingsGenerator+CMake: Keep track of IDL dependencies
This commit teaches BindingsGenerator to generate depfiles, which can be
used by CMake to ensure that bindings are properly regenerated when
imported IDL files change.

Two new options, `--depfile` and `--depfile-target` are added.
- `--depfile` sets the path for the dependency file.
- `--depfile-target` lets us set a target name different than the output
  file in the depfile. This option is needed because generated files are
  first written to a temporary file, but depfiles have to refer to the
  final location.
These are analogous to GCC's `-MF` and `-MT` options respectively. The
depfile's syntax matches the ones generated by GCC.

Note: This changes the minimal required CMake version to 3.20 if the
Make generator is used, and to 3.21 for the Xcode generator. Ninja is
not affected.
2022-12-13 11:31:24 +01:00
Tim Schumacher
0bd9a94bea LibHTTP: Don't read and drop data if status line can't be read
The idea of reading some amount of data presumably was to check if the
stream is still operable. However, this permanently breaks the request
format, as those 64 bytes are just lost forever.

Instead, just let the request fail instantly for now and think about
making it retry some time in the future. Since `can_read_line` updates
the read buffer beforehand, this should only happen in the rarest of
cases anyways.
2022-12-12 20:59:03 -07:00
Linus Groh
3b64610834 LibJS: Add spec comments to AggregateErrorConstructor 2022-12-12 21:26:12 +00:00
Linus Groh
172738222c LibJS: Update get_substitution() section number & parameter name 2022-12-12 21:26:12 +00:00
Linus Groh
19ea0d8dcf LibJS: Add spec comments to get_this_environment() 2022-12-12 21:26:12 +00:00
Linus Groh
c6638f53c0 LibJS: Add spec comments to new_object_environment() 2022-12-12 21:26:12 +00:00
Linus Groh
1cd46af7b0 LibJS: Add spec comments to new_declarative_environment() 2022-12-12 21:26:12 +00:00
Linus Groh
d51ab20aaa LibJS: Add spec comment to length_of_array_like() 2022-12-12 21:26:12 +00:00
Linus Groh
e4b388ea5a LibJS: Use modulo() for modulo operations in Value.cpp 2022-12-12 21:26:12 +00:00
Cody Hein
074ba104c8 PixelPaint: Single-clicking the BrushTool now adds to undo_stack
Simple change, prior to this BrushTool and EraseTool would not
have update the undo_stack for the ImageEditor unless you were
clicking and dragging.
2022-12-12 17:34:35 +00:00
Oleg Kosenkov
28bb3367cb Games: Add ColorLines 2022-12-12 17:30:04 +00:00
Arda Cinar
a559e26f68 shuf: Use the newly introduced AK::shuffle function 2022-12-12 16:23:03 +00:00
Arda Cinar
352048ce0e Minesweeper: Revise the maximum mine limit in custom game settings
After improving the mine field generation method, fields with greater
than 50% mines no longer take too long to generate. So, the mine limit
for a given size can be increased to its maximum possible value.
2022-12-12 16:23:03 +00:00
Arda Cinar
71537f4903 Minesweeper: Make sure icons of cells are set after generating field
In reset() function, the icons of labels in the game area were initially
set as mine icon or null. And then, after generation, only the number
icon was set. In the old field generation algorithm, this did not cause
a very visible issue (The displayed mine icons in the game over screen
were from a previously generated game field, which was only slightly
wrong).

However, the newer field generation caused a "no mine icons are shown in
the game over screen" issue. To fix that, the label icon is set to null
initially, and then it is set to a mine or number bitmap.
2022-12-12 16:23:03 +00:00
Arda Cinar
5562ef6cc5 Minesweeper: Use a faster method to generate game field
The existing method was simply using a "randomly generate until it fits
our criteria" method to generate a game field. While this worked OK in
most cases, the run time was increasing seriously in boards whose
mine count / board size ratio was too big.

The new approach simply generates every possible mine location, shuffles
the array and picks its head. This uses more memory (shouldn't be a big
deal since minesweeper boards are generally miniscule) but runs much
quicker. The generation could still use some improvement (regarding
error handling), though :^)
2022-12-12 16:23:03 +00:00
Tim Schumacher
30abd47099 LibCompress: Port DeflateDecompressor to Core::Stream 2022-12-12 16:21:39 +00:00
Tim Schumacher
f909cfbe75 LibCore: Use the new Handle type for the BitStream types
This allows us to either pass a reference, which keeps compatibility
with old code, or to pass a NonnullOwnPtr, which allows us to
comfortably chain streams as usual.
2022-12-12 16:21:39 +00:00
Tim Schumacher
8b5df161af LibCore: Add Stream::Handle
This essentially wraps a `NonnullOwnPtr` or a reference, allowing us to
either have a stream own a dependent stream that it uses or to just hold
a reference if a stream is already owned by somebody else and we just
want to use it temporarily.
2022-12-12 16:21:39 +00:00
Lucas CHOLLET
3750687821 LibCore: Use Core::System::poll() in PosixSocketHelper 2022-12-12 16:14:11 +00:00
Lucas CHOLLET
5532640b71 LibCore: Add a wrapper for poll() 2022-12-12 16:14:11 +00:00
Snow
0049dfd717 LibGUI+TextEditor: Add a relative line number option for TextEditor
This adds an option for displaying relative line numbers in the ruler,
the line numbers are still absolute by default.
2022-12-12 16:02:06 +00:00
Baitinq
af1c26f05b Browser: Go back/forward when pressing back/forward mouse buttons
This currently doesn't work when running Serenity through QEMU, as it
doesn't pass the side button events over to Serenity due to some bug or
missing feature.
2022-12-12 15:00:08 +00:00
Luke Wilde
2f3ebce7c8 LibJS: Keep GeneratorObject's stored execution context's internals alive
This would previously crash with a heap UAF when storing the result of
`yield 1` into `e` on the second `next` call:
```js
function* a() { const e = yield 1; }
b = a();
b.next();
gc();
b.next();
```
2022-12-12 13:58:32 +00:00
Luke Wilde
6431dd7904 LibJS: Make it possible to visit the edges of an ExecutionContext 2022-12-12 13:58:32 +00:00
Luke Wilde
40cc38869e LibJS: Move ExecutionContext function implementations out of line 2022-12-12 13:58:32 +00:00
Ali Mohammad Pur
4311c2164e Shell: Disable interactive mode on '-c'
This also disables the full suite of interactive stuff in LibLine.
2022-12-12 13:57:06 +00:00
Tim Schumacher
3fccf2481c LibCore: Make not discarding all requested bytes from a stream an error 2022-12-12 14:16:42 +01:00
Tim Schumacher
9a3e95785e LibCore: Propagate errors from Stream::*_entire_buffer 2022-12-12 14:16:42 +01:00
Tim Schumacher
6c7c5a6786 LibCore: Rename Stream::*_or_error to *_entire_buffer
All of our functions are `_or_error` (or are about to be), and maybe
making it less reminiscient of AK::Stream will make people use it more.
2022-12-12 14:16:42 +01:00
Tim Schumacher
ed4c2f2f8e LibCore: Rename Stream::read_all to read_until_eof
This generally seems like a better name, especially if we somehow also
need a better name for "read the entire buffer, but not the entire file"
somewhere down the line.
2022-12-12 14:16:42 +01:00
Tim Schumacher
5061a905ff LibCore: Remove Stream::is_{readable,writable}
Next to functions like `is_eof` these were really confusing to use, and
the `read`/`write` functions should fail anyways if a stream is not
readable/writable.
2022-12-12 14:16:42 +01:00
kleines Filmröllchen
5a346c4297 Help+LibManual: Without arguments, open index page instead of crashing
This is the old behavior before the recent LibManual refactor. It also
moves the definition of the index page into LibManual for better reuse.
2022-12-12 00:37:29 -07:00
sin-ack
ef6921d7c7 Kernel+LibC+LibELF: Set stack size based on PT_GNU_STACK during execve
Some programs explicitly ask for a different initial stack size than
what the OS provides. This is implemented in ELF by having a
PT_GNU_STACK header which has its p_memsz set to the amount that the
program requires. This commit implements this policy by reading the
p_memsz of the header and setting the main thread stack size to that.
ELF::Image::validate_program_headers ensures that the size attribute is
a reasonable value.
2022-12-11 19:55:37 -07:00
sin-ack
9b425b860c Kernel+LibC+Tests: Implement pwritev(2)
While this isn't really POSIX, it's needed by the Zig port and was
simple enough to implement.
2022-12-11 19:55:37 -07:00
sin-ack
70337f3a4b Kernel+LibC: Implement setregid(2)
This copies and adapts the setresgid syscall, following in the footsteps
of setreuid and setresuid.
2022-12-11 19:55:37 -07:00
sin-ack
2a502fe232 Kernel+LibC+LibCore+UserspaceEmulator: Implement faccessat(2)
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-11 19:55:37 -07:00
sin-ack
d5fbdf1866 Kernel+LibC+LibCore: Implement renameat(2)
Now with the ability to specify different bases for the old and new
paths.
2022-12-11 19:55:37 -07:00
sin-ack
eb5389e933 Kernel+LibC+LibCore: Implement mkdirat(2) 2022-12-11 19:55:37 -07:00
sin-ack
6445a706cf Kernel+LibC: Implement readlinkat(2)
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-11 19:55:37 -07:00
sin-ack
9850a69cd1 Kernel+LibC+LibCore: Implement symlinkat(2)
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-11 19:55:37 -07:00
kleines Filmröllchen
2fcb713037 LibThreading: Overhaul thread behavior with ThreadState
This replaces all state-related variables with a single ThreadState.
These are simplified over what the Kernel has, but capture all
userspace-available thread state.

Locking the state behind an atomic and using proper atomic operations
also gets rid of quite some deadlocks and race conditions that have
existed around m_tid and others beforehand.

In terms of behavior, this introduces the following changes:
- All thread state mishandling (e.g. joining a detached thread) crashes
  the program. Mishandling thread state is a severe kind of concurrency
  bug that might also be indeterministic, so letting it silently
  disappear with the return value of pthread_ APIs is a bad idea. The
  thread state can always be checked beforehand to ensure that no crash
  happens.
- Destructing a still-running thread will crash in AK/Function, so the
  Thread destructor issues its own warning for debugging purposes.
- Thread issues warnings before crashes in many places to aid
  concurrency debugging (the most difficult kind of debugging).
- Joining dead but not detached threads is legal, as per POSIX APIs.
- The thread ID is never reset to 0 after the thread has been started
  and subsequently been assigned a valid thread ID. The thread's exit
  state is still obtainable.
- Detaching threads that are about to exit is considered a programming
  bug and will often (not always, as we can't catch all execution
  sequences involved in such a situation) crash the program on purpose.
  If you want to detach a thread that will definitely exit on its own,
  you have to prevent it from exiting before detach() was called (e.g.
  with an "exit requested" flag).
2022-12-11 19:07:20 -07:00