Commit Graph

638 Commits

Author SHA1 Message Date
Ben Wiederhake
1fd672c4c2 LibCore: Remove unused header in File 2026-02-23 12:15:23 +01:00
Ben Wiederhake
7093082d75 LibCore: Remove forward declaration of non-existent type 2026-02-23 12:15:23 +01:00
Ben Wiederhake
0206150b70 LibCore: Remove unused header in TimeZoneWatcherUnix 2026-02-21 19:27:35 +01:00
Ben Wiederhake
08f4cf10ed LibCore: Remove unused header in LocalServer 2026-02-21 19:27:35 +01:00
Ben Wiederhake
084f5ababd LibCore: Remove unused header in EventLoopImplementationUnix 2026-02-21 19:27:35 +01:00
Ben Wiederhake
ee5a6e1b28 LibCore: Remove unused header in AnonymousBuffer 2026-02-21 19:27:35 +01:00
Ben Wiederhake
6a34849238 LibCore: Remove unused header in ThreadEventQueue 2026-02-21 19:27:35 +01:00
Ben Wiederhake
e27bdaafe7 LibCore: Remove unused header in ResourceImplementationFile 2026-02-21 19:27:35 +01:00
Ben Wiederhake
387f378f45 LibCore: Remove unused header in ResourceImplementation 2026-02-21 19:27:35 +01:00
Ben Wiederhake
fb7095ab88 LibCore: Remove unused header in Resource 2026-02-21 19:27:35 +01:00
Ben Wiederhake
6335f4745f LibCore: Remove unused header in MimeData 2026-02-21 19:27:35 +01:00
Ben Wiederhake
b33b08050a LibCore: Remove unused header in EventReceiver 2026-02-21 19:27:35 +01:00
Ben Wiederhake
ca28b98b83 LibCore: Remove unused header in EventLoopImplementation 2026-02-21 19:27:35 +01:00
Ben Wiederhake
a929850fdb LibCore: Remove unused header in EventLoop 2026-02-21 19:27:35 +01:00
Ben Wiederhake
543fb77e5d LibCore: Remove unused header in ConfigFile 2026-02-21 19:27:35 +01:00
Ben Wiederhake
94dee9bea2 LibCore: Remove unused header in System 2026-02-21 19:27:35 +01:00
Ben Wiederhake
e0f39d5114 LibCore: Remove unused header in StandardPaths 2026-02-21 19:27:35 +01:00
Ben Wiederhake
36063f6881 LibCore: Remove unused header in MappedFile 2026-02-21 19:27:35 +01:00
Ben Wiederhake
e6e0bf0136 LibCore: Remove unused header in Environment 2026-02-21 19:27:35 +01:00
Andreas Kling
e87f889e31 Everywhere: Abandon Swift adoption
After making no progress on this for a very long time, let's acknowledge
it's not going anywhere and remove it from the codebase.
2026-02-17 10:48:09 -05:00
Shannon Booth
32c51774ee LibCore: Remove unusued Core::System::mkdtemp
This suffers from TOCTOU issues, and alternatives should probably
be used. Since it is unused, let's just remove it.
2026-02-14 10:25:33 -05:00
Timothy Flynn
4ad9543a65 LibCore: Add helpers to share arbitrary versions between processes
This will allow sharing e.g. document cookie versions between the UI and
WebContent processes, and safely accessing those versions.

Core::AnonymousBuffer internally creates a minimum buffer of PAGE_SIZE
bytes. This is much more than the size of a single version, but this
affords us the opportunity to share multiple versions in a single buffer
between processes. With a PAGE_SIZE of 4096, we can share up to 512
versions in a single buffer.
2026-02-05 07:28:07 -05:00
Andrew Kaster
643605099e LibCore: Move Core::MappedFile to LibCoreMinimal 2026-02-03 10:29:51 +01:00
R-Goc
3a86e779bd LibCore/LibIPC/Meta: Stop using deprecated Winsock functions
This commit stops using deprecated WSA functions. While the ANSI
versions are most likely not going anywhere, Windows is natively UTF-16
so it has to convert to ANSI internally. All the ANSI functions in
Winsock are marked as deprecated. The macro suppressing the warnings is
no longer defined.
2026-02-02 10:35:11 +01:00
R-Goc
1ac35d19f9 LibCore: Handle long paths in ProcessWindows
This commit handles the case where the process executable has a long
path.
2026-02-02 10:35:11 +01:00
Andreas Kling
5968ff90af LibCore: Add AnonymousBuffer::bytes() getter 2026-02-01 22:46:09 +01:00
Andreas Kling
9ad9c65368 Revert "LibCore: Add thread-safe weak deferred_invoke()"
This reverts commit 96ce468b60.

Appears to have regressed WPT.
2026-01-25 12:20:39 +01:00
Andreas Kling
96ce468b60 LibCore: Add thread-safe weak deferred_invoke()
Add a thread-safe deferred_invoke() API on WeakEventLoopReference that
queues work onto the owning thread's event queue and wakes that thread
via EventLoopManager hooks. This avoids calling wake() from foreign
threads during teardown.

Implement current_thread_handle()/wake_thread() in each backend and
track per-thread data so handles are validated before waking:

- Unix: wake via per-thread wake pipe
- Windows: wake via thread wake event
- macOS: wake via stored CFRunLoopRef
- Qt: wake via event target or QEventLoop::wakeUp()
- Android: wake via stored ALooper
2026-01-25 09:32:51 +01:00
Andreas Kling
2734f72835 LibCore: Fix data race in WeakEventLoopReference::revoke()
This was taking a read lock while modifying m_event_loop, which is a
data race with concurrent calls to take() that also hold read locks.
2026-01-25 09:32:51 +01:00
Andreas Kling
2a6045833c LibCore: Make ProxyData::port a u16
TCP ports are always u16 and this prevents invalid values from getting
into this field somehow.
2026-01-22 17:38:15 +01:00
Zaggy1024
4a5350a2ee LibCore: Use sendfile instead of mmap+write on macOS 2026-01-19 06:53:29 -05:00
Zaggy1024
84c0eb3dbf LibCore+LibHTTP+RequestServer: Send data via sockets instead of pipes
This brings the implementation on Unix in line with Windows, so we can
drop a few ifdefs.
2026-01-19 06:53:29 -05:00
Zaggy1024
a3f0b513b6 LibCore: Remove an unnecessary ifdef from ioctl
Passing argp to ioctl as void* instead of FlatPtr works on Linux, but
Haiku needs a void*, so let's just do that unconditionally.
2026-01-19 06:53:29 -05:00
Zaggy1024
8eda26c5cf LibCore+Everywhere: Make Windows's System::ioctl consistent with POSIX
Passing the option by value on Windows where it's a pointer on all
other platforms seems like it may cause some unnecessary ifdef soup.
2026-01-19 06:53:29 -05:00
Undefine
822d8463c2 LibCore: Use the Linux implementation of TimeZoneWatcher on BSDs
The same implementation works just fine on any BSD system provided it
has a working FileWatcher implementation.
2026-01-16 10:59:50 -07:00
Undefine
941797c807 LibCore: Implement FileWatcher for any systems with inotify
FreeBSD 15 added support for inotify so let's just allow this file to
be used there too as it's needed for watching the time zone file.
2026-01-16 10:59:50 -07:00
Jelle Raaijmakers
771a9c9266 LibCore: Simplify anon_create()
After 07630f3b0c, this simplification
became obvious. No functional changes.
2026-01-16 07:26:46 -05:00
Andreas Kling
07630f3b0c LibCore: Fix memory leak in anon_create() on BSD/macOS
The mmap() call here served no purpose - anon_create() is only meant to
create and return a file descriptor. The actual mapping is done later
by AnonymousBufferImpl::create().

This leaked an mmap of `size` bytes for every AnonymousBuffer created,
which includes backing stores, shareable bitmaps, and more.
2026-01-16 08:04:22 +01:00
Andreas Kling
0e6f2cb734 LibCore: Add pipe2() implementation for Windows
This is needed by LibWebView's process output capture feature.
2026-01-13 21:05:58 +01:00
Andreas Kling
568758e55a LibCore: Fix Windows build for STDOUT_FILENO/STDERR_FILENO macros
Wrap the _get_osfhandle() return value with to_fd() to convert from
intptr_t to int, fixing a narrowing conversion error on Windows.
2026-01-13 21:05:58 +01:00
Tim Ledbetter
2a58b5b608 Revert "LibCore: Use weak ownership in EventReceiver::deferred_invoke"
This reverts commit 1ed94388e9.
2026-01-11 13:54:53 -05:00
ayeteadoe
1ed94388e9 LibCore: Use weak ownership in EventReceiver::deferred_invoke
When test-web has completed running all tests there is a pending
DeferredInvoke in the main threads event queue. For Unix pthread, the
main threads event queue is leaked as the destructor callback in
pthread_key_create is not invoked. For Windows pthreads4w, the
destructor callback is invoked when the main thread is exiting. When
the main threads event queue is destroyed, the pending DeferredInvoke
event is destroyed which causes a leftover WebContentClient reference
to also get destroyed; however, the static WebContentClient::s_clients
HashTable has already been destroyed at this point, so we get a UAF in
the WebContentClient destructor and ASAN reports that error.

The reason why cleaning up the pending deferred invoke results in a
WebContentClient instance also being cleaned up is that class inherits
from IPC::ConnectionBase which is a Core::EventReceiver. The
deferred_invoke() method exposed on event receivers takes a strong
reference to itself to ensure it is still alive by the time the event
loop is ready to execute the function. There are a couple places in
IPC::ConnectionBase::drain_messages_from_peer() that utilized deferred
invocation which is why we have a leftover WebContentClient that has
past its useful lifetime at the end of TestWeb::run_tests().

Instead of holding onto a strong reference when the event has not yet
been processed, we take a weak reference and only grab a strong ref if
the receiver is alive when the event loop is about to execute our
function.
2026-01-10 23:35:51 +01:00
Andreas Kling
3a0e2c3d0e LibCore: Notify write-only notifiers on POLLHUP
This fixes an issue where RequestServer would churn as poll() returned
immediately due to a file descriptor yielding POLLHUP.

In that case, we should just wake the notifier and let it figure out
what to do.
2026-01-10 14:58:21 -05:00
Zaggy1024
fb2d9e3c85 LibCore: Only wake the event loop in deferred_invoke from other threads
For some reason, writing to the wake fd from the same thread in
deferred_invoke was causing a deadlock. However, we don't actually need
to wake from the same thread, since the event loop is not waiting and
will therefore process the deferred_invoke on the next iteration.

This issue was introduced in 3742138cc3.
The deadlock could be reproduced consistently by increasing
LOCAL_STORAGE_QUOTA in StorageJar.cpp to a large value like 50 MiB.
2025-12-31 10:41:51 +01:00
Zaggy1024
87c3053370 LibCore: Allow checking for a ThreadEventQueue without creating one 2025-12-31 10:41:51 +01:00
Arran Ireland
bd82dfa048 AK+LibURL: Use AK::IPv4/6 in Host
This resolves two FIXME comments.
2025-12-31 10:24:56 +01:00
Zaggy1024
685535dc85 LibCore: Rename the forward declaration of WeakEventLoopReference
This was missed by the rename tool when changing EventLoopWeak to
WeakEventLoopReference.
2025-12-09 17:16:25 -06:00
Zaggy1024
3742138cc3 LibCore+LibThreading: Always wake the event loop when deferred invoking 2025-12-09 16:12:40 -06:00
Zaggy1024
2a5a9d2103 LibCore: Add a thread-safe weak link for EventLoop
Since the event loop has a very specifically scoped lifetime, we can't
ensure that it outlives threads that hold a reference to it without
blocking the thread that owns it. In order to make threads use the
event loop safely, we now have an atomically ref-counted
WeakEventLoopReference class that can be passed off to threads to
safely post events/callbacks to it.

Another possibility was to use an RWLock per event loop that each
thread holds a read lock on, while ~EventLoop() uses a write lock to
block and prevent it being destroyed until all its threads exit.
However, media data providers don't receive a signal to exit due to the
GC heap being intentionally leaked, so the process never actually
exits. It would be possible to specifically drop the reference to
PlaybackManager in HTMLMediaElement in order to make those data
providers die on their own, but that doesn't help prevent this problem
in other cases where it may arise.
2025-12-09 16:12:40 -06:00
Andreas Kling
05e449d32a LibCore: Simplify how we calculate processed event count 2025-12-03 13:26:27 +01:00