Commit graph

20641 commits

Author SHA1 Message Date
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
kleines Filmröllchen
601ede331b LibThreading: Add a thread state enum
This will later be used by Thread to keep track of its state more simply
and obviously.
2022-12-11 19:07:20 -07:00
kleines Filmröllchen
fe004d3389 LibThreading: Add Thread formatter
Printing a thread for debugging is used quite often.
2022-12-11 19:07:20 -07:00
kleines Filmröllchen
9e40d4ccd6 LibThreading: Move now-trivial accessors of Thread to cpp file
Some of these might be changed in the future, and because Thread.h is a
commonly included header file, we don't want to change it as much as
possible.
2022-12-11 19:07:20 -07:00
kleines Filmröllchen
7fd7562140 LibThreading: Use Threading namespace in Thread.cpp 2022-12-11 19:07:20 -07:00
Timothy Flynn
8997d825d5 LibSQL: Don't use the SQL socket file path as its descriptor
This is just used to key the socket fd for system server takeover. On
macOS, this file path has a space in it, which trips up the parsing as
it splits on spaces. That parsing should be fixed (probably shouldn't
rely on spaces as a delimter), but for now, we can change the key to
avoid spaces.
2022-12-11 19:05:07 -07:00
Timothy Flynn
4d3bb5ada4 LibSQL: Do not fchmod the SQL socket on macOS
Similar to: 9a4ee9aa1a.
2022-12-11 19:05:07 -07:00
Arda Cinar
1d687b0b31 MasterWord: Display the last word in a different color for short input
Previously, the word was highlighted red in case it was not found in the
dictionary. That color was repurposed as a general "invalid input" color
to nudge the player that something was wrong with the last input.
Accordingly, the field m_last_word_not_in_dictionary was renamed to
m_last_word_invalid
2022-12-11 22:10:37 +01:00
Arda Cinar
cc5ea3aa4c MasterWord: Display messages in a statusbar
In the "inspiration" for this game, messages are displayed on top of the
game area in case an invalid guess is inputted. After a few seconds,
they disappear. In a similar fashion, a statusbar is created on the game
window and similar messages are outputted there.
2022-12-11 22:10:37 +01:00
MacDue
d3588a9a2b LibWeb: Support calc() values in background-position 2022-12-11 22:09:24 +01:00
Aliaksandr Kalenik
3922349b71 LibWeb: Use space_used_by_floats to get x offset of box that creates BFC
y of box should be taken in account while calculating space
used by floats.
2022-12-11 22:08:44 +01:00
Aliaksandr Kalenik
daece542f5 LibWeb: Check if block creates BFC even if all it's children are inline
Even if block has all children inline there need to be a check
if it creates BFC because otherwise IFC will be looking in
wrong parent BFC to calculate space used by floats.
2022-12-11 22:08:44 +01:00
Itamar
108a8e4c88 LibX86: Only pass ProcessorMode to Instruction constructor
We previously passed both OperandSize and AddressSize to the
constructor.

Both values were only ever 32-bit at construction.
We used AddressSize::Size64 to signify Long mode which was needlessly
complicated.
2022-12-11 22:06:30 +01:00
Itamar
9a136e354d LibX86: Use AddressSize::32 in Long mode
As the existing near-by comment says, the default size of displacements
& immediates is 32 bits even in Long mode.

This makes `disasm` work on our binaries in x86-64 builds.
2022-12-11 22:06:30 +01:00
kleines Filmröllchen
dd66f5e838 Help: Link to LibLocale
This managed to fly under my radar for the LibManual PR, and somehow it
only happens for the Clang build but doesn't always trigger on CI.
2022-12-11 13:59:41 -07:00
Snow
2f8c7b1b30 LibGUI: Add shortcut for inserting new line
This adds shortcut for inserting a new empty indented line
above/below current cursor position.

- <Ctrl-Return> for inserting line below.
- <Ctrl-Shift-Return> for inserting line above.
2022-12-11 19:47:42 +00:00
thankyouverycool
e06f9174a1 WindowServer: Remove unused bools in Menu::draw()
Added in d522a6f and 1e604b7, their purpose snuffed out in 11bb88f
like the faint pulse of a pleading candle, two lives of short excess,
doomed to itemize their sins to no effect and for all eternity...
2022-12-11 20:25:58 +01:00
thankyouverycool
d80c520a92 WindowServer: Include missing visibility argument when making MenuItem
Fixes checkable MenuItems drawing incorrectly due to shifted defaults.
2022-12-11 20:25:58 +01:00
kleines Filmröllchen
b65258c093 Help+man+LibManual: Move argument handling to LibManual
This deduplicates argument handling logic from Help and man and makes it
more modular for future use cases. The argument handling works as
before: two arguments specify section and page (in this order), one
argument specifies either a page (the first section that it's found in
is used) or a path to a manpage markdown file.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
64ca546a06 man: Refactor with LibManual and Core::Stream 2022-12-11 16:05:23 +00:00
kleines Filmröllchen
146bce53dd Help: Fix search query parsing
This was failing probably because AK::URL was being too strict; and the
query emptyness check was flipped.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
a438c4d568 Help+LibManual: Move all manpage path handling to LibManual
This way, we'll have an easier time changing these paths.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
4625f7aab5 LibManual: Refactor SectionNode in preparation for subsections
- Calculate the full name on demand
- Make section and name protected
- Reorder some members logically
- Change the name getter to be fallible, as some implementors need to
  allocate
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
ad6a55e1f0 Help+LibManual: Move non-UI-specific manual handling to LibManual
This is a first step in deduplicating code within and across Help and
man.

Because LibManual also doesn't contain any DeprecatedString, some
adjustments to Help's string handling is included, just to interoperate
with LibManual better. Further work in this area mostly requires String
APIs in LibGUI.
2022-12-11 16:05:23 +00:00
Timothy Flynn
78353ec184 sql: Support running the sql REPL on Lagom 2022-12-11 10:08:17 -05:00
Timothy Flynn
4e5f56f737 LibSQL: Support launching a singleton SQLServer instance for Lagom hosts
On Serenity, SQLServer is started by SystemServer. But on Lagom, it is
manually started by e.g. Ladybird when the application is started, and
killed when the application exits. This means every Ladybird process
starts its own SQLServer, which defeats the purpose of SQLServer acting
as the single process interacting with the database files.

This patch will allow SQLClient to start up a single SQLServer instance,
first checking if one already exists. If it does exist, SQLClient will
simply connect to SQLServer's socket. If it does not exist, SQLClient
will launch SQLServer much like SystemServer would (with a local socket
file, etc.).

The child SQLServer process is double-forked; the grandchild process
becomes the SQLServer process, which the middle child process simply
exits to "detach" the grandchild process from the SQLClient process.
2022-12-11 10:08:17 -05:00
Timothy Flynn
12152a4556 SQLServer: Re-use already opened SQL::Database objects
Currently, we create a new SQL::Database object for each database we are
requested to open. When multiple clients connect to the same database,
the same underlying database file is opened and cached each time. This
results in updates from one client not being propagated to others.

To prevent this, when a database is requested to be open, check if it is
already open. We can then re-use that SQL::Database object for the new
connection.
2022-12-11 10:08:17 -05:00
Timothy Flynn
6b64485b40 LibIPC: Add a hook to MultiServer to inform owners of new clients
This will allow the owner of the server to mutate the client after it
has been accepted.
2022-12-11 10:08:17 -05:00
Timothy Flynn
c46c3555a1 LibCore: Add a standard path for runtime communication files
This corresponds to XDG_RUNTIME_DIR, which is the path applications may
place runtime communication files, like local sockets.
2022-12-11 10:08:17 -05:00
Luke Wilde
eabb0be7ea LibWeb: Check HTML parser position is equal to or after insertion point
This used to be the other way around. If we just inserted input with
document.write, this would always be true and not allow document.write
to immediately parse its input (given that there's no pending parsing
blocking script)
2022-12-10 21:37:18 +00:00
Thomas Queiroz
eacfcac932 LibWeb: Use HashMap::try_ensure_capacity in StyleComputer 2022-12-10 14:29:46 +01:00
Andreas Kling
a3a5d2b27d SpaceAnalyzer: Consolidate the node context menus
Instead of having two separate context menus and popping up either the
"file" or "directory" one depending on the selected node, we now have a
single context menu and update it (before popping it up) to show the
context-appropriate actions.

This is achieved by simply updating the visibility of the actions.

This takes care of one TODO! :^)
2022-12-10 14:28:38 +01:00
Andreas Kling
49f5767789 LibGUI+WindowServer: Add "visible" state to GUI actions
This patch adds a visibility state to GUI::Action. All actions default
to being visible. When invisible, they do not show up in toolbars on
menus (and importantly, they don't occupy any space).

This can be used to hide/show context-sensitive actions dynamically
without rebuilding menus and toolbars.

Thanks to Tim Slater for assuming that action visibility was a thing,
which gave me a reason to implement it! :^)
2022-12-10 14:28:38 +01:00
Snow
df7c0eacd4 TextEditor: Fix commenting shortcut <Ctrl-/>
When you select a text area in "bottom-up" way (e.g. from line 10
to line 5), then type the shortcut, the text editor will not
comment those text for you.

Normalize the text range can easily fix this minor bug.
2022-12-10 14:04:51 +01:00
DragonAlex98
b8706729ba LibGUI: Disable corresponding Scrollbar button when reaching min or max 2022-12-10 14:03:27 +01:00
Andreas Oppebøen
4b12def5d8 LibWeb: Use start-of-line in hit test of position directly to the left
This fixes a bug where selecting from the left within a line would
begin the selection from the right, as pointed out by @AtkinsSJ in
https://github.com/SerenityOS/serenity/pull/16245#pullrequestreview-1197595820
2022-12-10 13:19:49 +01:00
Andreas Oppebøen
9cab5059f8 LibWeb: Use correct end-of-fragment node index for HitTestResult
The indexes are into the _node_, not in the fragment, so when a node is
split into multiple fragments, simply taking the length of the fragment
is incorrect. This patch corrects this mistake.
2022-12-10 13:19:49 +01:00
thankyouverycool
31f4ec66c5 Magnifier: Add a manual to Help menu and propagate construction errors 2022-12-10 13:15:35 +01:00
thankyouverycool
5e96ad0345 Magnifier: Standardize File menu
File->Quit should appear as the final item in its menu
2022-12-10 13:15:35 +01:00
thankyouverycool
0c2f36966c WindowServer: Update checked state of m_window_menu_always_on_top_item
when setting it programmatically.
2022-12-10 13:15:35 +01:00
thankyouverycool
f8e0bcbedf Magnifier: Remove always_on_top_action
This action was originally added so that Magnifier's window would
always be on top by default, but it's a redundant menu item and wasn't
actually setting itself at start-up. Instead, rely on the same menu
item provided to all Modeless windows by default for a more consistent
UX, and set the option after show() so it takes effect.
2022-12-10 13:15:35 +01:00
Tim Schumacher
f93c7fbb5e LibCompress: Port GzipDecompressor to Core::Stream 2022-12-10 12:05:55 +00:00