Commit graph

20242 commits

Author SHA1 Message Date
Brian Gianforcaro
879eec6aa8 Kernel: Remove dead TCPSocket::from_endpoints method 2021-05-14 11:32:50 +02:00
Andreas Kling
6387f65f87 LibGUI: Resize GUI::HeaderView section vector to final size immediately
When computing row & column sizes in AbstractTableView, it iterates
across both axes starting from 0.

This caused us to grow the corresponding HeaderView's internal section
vector by 1 entry for each step, leading to Vector::resize() thrashing.

Since we already know the final size, just resize to that immediately,
and the thrashing goes away.

This gives a huge speedup when loading large files into Profiler. :^)
2021-05-14 10:32:44 +02:00
Brian Gianforcaro
c63761a341
Profiler: Avoid copies / String construction when parsing profile (#7096)
Use sv literal suffix to construct StringViews at compile time,
and make sure to reference array items by const reference.
2021-05-14 10:21:25 +02:00
Ali Mohammad Pur
5a7db74c52 LibTLS: Actually verify the certificats
This was likely commented out at some point to debug something.
2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
df515e1d85 LibCrypto+LibTLS: Avoid unaligned reads and writes
This adds an `AK::ByteReader` to help with that so we don't duplicate
the logic all over the place.
No more `*(const u16*)` and `*(const u32*)` for anyone.
This should help a little with #7060.
2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
bfd4c7a16c AK: Avoid passing nullptr to __buitin_memcpy() in ByteBuffer::grow() 2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
a4e20a87d5 LibCrypto: Do not assume that the passed in IV is as long as a block
Just take ReadonlyBytes instead of a raw pointer.
Fixes #7072 (tested with the ASAN build fixed by #7060).
2021-05-14 08:39:29 +01:00
Andrew Kaster
e96451edc9 Tests: Don't use TestRunners after their scope ends in test-js
The TestRunner objects at the end of test-js are destroyed after the
if/else that chooses whether to run the 262 parser tests or the standard
tests. Accessing TestRunner::the() after the lifetime of the TestRunners
ends is UB, so return the Test::Counts from run() instead. Also, fix the
destructor of TestRunner to set s_the to nullptr so that if anyone tries
this type of shenanigains again, they'll get a crash :^).
2021-05-14 08:34:00 +01:00
Andrew Kaster
f90a19ba4c LibJS: Make sure all allocators are 8-byte aligned
Absolutely massive allocations > 1024 bytes would go into the size
class which was 3172 bytes. 3172 happens to not be 8 byte aligned, and
so made UBSAN very sad on x86_64. Change the largest allocator to be
3072 bytes, which is in fact a multiple of 8 :^)
2021-05-14 08:34:00 +01:00
Andrew Kaster
e1b8a2e517 Tests: Mark use-after-scope NeverDestroyed test NO_SANITIZE_ADDRESS
The should_not_destroy test case intentionally performs an invalid stack
access on a NeverDestroyed to confirm that the destructor for the held
type was not called.
2021-05-14 08:34:00 +01:00
Andrew Kaster
55d338b66f Tests: Free all memory allocated with regcomp in RegexLibC tests
The C interface (posix interface?) for regexes has no "initialize"
function, only a free function. The comment in regcomp in
LibRegex/C/Regex.cpp notes that calling regcomp without a regfree is an
error, and will leak memory. Every single time regcomp is called on a
regex_t*, it will allocate new memory.

Make sure that all the regcomp calls are paired with a regfree in the
tests program
2021-05-14 08:34:00 +01:00
Andrew Kaster
09fe9f4542 Tests: Fix use-after-free in TestRefPtr.self_observers
We can't unref an object to destruction while there's still a live
RefPtr to the object, otherwise the RefPtr destructor will try to
destroy it again, accessing the refcount of a destroyed object (before
realizing that oops! the object is already dead)
2021-05-14 08:34:00 +01:00
Andrew Kaster
28987d1b56 AK: Add #define for [[gnu::no_sanitize_address]]
This lines up with other attribute global #defines
2021-05-14 08:34:00 +01:00
Andrew Kaster
d81f52e529 Lagom: Enable sanitizer builds with gcc
Previously the CMake options for -fsanitize=address, thread and
undefined were gated behind clang, which was unecessary. Only
-fsanitize=fuzzer is clang-only.
2021-05-14 08:34:00 +01:00
Linus Groh
a92dc4e30d LibJS: Ensure function declarations don't leak outside function scopes
When using VM::set_variable() to put the created ScriptFunction onto a
ScopeObject, we would previously unexpectedly reach the global object as
set_variable() checks each traversed scope for an existing Variable with
the given name - which would cause a leak of the inner function past the
outer function (we even had a test expecting that behaviour!). Now we
first declare functions (as DeclarationKind::Var) before setting them.
This will need some more work to make hoisting across non-lexical scopes
work, but it fixes this specific issue for now.

Fixes #6766.
2021-05-13 23:59:00 +01:00
Linus Groh
b221cad659 LibJS/Tests: Add details for toBeTrue() / toBeFalse() expectation error 2021-05-13 23:59:00 +01:00
Linus Groh
f28491dbe7 LibJS/Tests: Add details for toThrowWithMessage did-not-throw case 2021-05-13 23:59:00 +01:00
Linus Groh
5b18bce23c LibJS/Tests: Add prefix to toThrowWithMessage expectation error details
This way we get some more information about where things went wrong.
2021-05-13 23:59:00 +01:00
Gunnar Beutner
53664787fb Kernel: Correctly set the lost_samples field for the first sample
This ensures that the lost_samples field is set to zero for the
first sample. We didn't lose any samples before the first sample
so this is the correct value. Without this Profiler gets confused
and draws the graph for the process which contains the first CPU
sample incorrectly (all zeroes usually).
2021-05-14 00:46:10 +02:00
Gunnar Beutner
c41f13f10b Kernel+Profiler: Track lost time between profiler timer ticks
We can lose profiling timer events for a few reasons, for example
disabled interrupts or system slowness. This accounts for lost
time between CPU samples by adding a field lost_samples to each
profiling event which tracks how many samples were lost immediately
preceding the event.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
8614d18956 Kernel: Use a separate timer for profiling the system
This updates the profiling subsystem to use a separate timer to
trigger CPU sampling. This timer has a higher resolution (1000Hz)
and is independent from the scheduler. At a later time the
resolution could even be made configurable with an argument for
sys$profiling_enable() - but not today.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
d6b3513aab Profiler: Let the user ignore context switches
Now that the profiling timer is independent from the scheduler the
user will get quite a few CPU samples from "within" the scheduler.
These events are less useful when just profiling a user-mode process
rather than the whole system. This patch adds an option to Profiler to
hide these events.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
c534f176bc Profiler: Add histogram for sample counts
Previously Profiler would use the stack depth to draw the timeline
graphs. This is not an accurate representation of whether a thread
is "busy" or not. Instead this updates the timelines to use the
sample count.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
a11a1cd4d6 AK: Vector::resize() should initialize new slots for primitive types
We call placement new for the newly added slots. However, we should
also specify an initializer so primitive data types like u64 are
initialized appropriately.
2021-05-14 00:35:57 +02:00
Andreas Kling
339b368308 InspectorServer: Add another missing <AK/JsonObject.h> include 2021-05-13 23:56:25 +02:00
Brian Gianforcaro
57385a1c29 CMake: Make missing medium icon a FATAL_ERROR
Now that all of the medium icons pass this check, we can make it
FATAL_ERROR to stop any new violations from being checked in.
2021-05-13 23:45:50 +02:00
Andreas Kling
9b765b42e4 InspectorServer: Add missing <AK/JsonObject.h> include 2021-05-13 23:44:48 +02:00
Andreas Kling
90e31b4f39 Inspector: Don't check that target has pledged "accept"
This check only existed to prevent crashing the target process back
when programs were listening for incoming Inspector connections.

Now that we talk to InspectorServer instead, and it already has a
communication channel with the target, this is no longer an issue.
2021-05-13 23:28:40 +02:00
Andreas Kling
31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Andreas Kling
04d78adaf7 Userland: Remove no-longer-needed unveil()'s of /tmp/rpc 2021-05-13 23:28:40 +02:00
Andreas Kling
a03879f8dd SystemServer: Stop creating the /tmp/rpc directory
This is no longer needed.
2021-05-13 23:28:40 +02:00
Andreas Kling
dc25a4e249 LibCore+Inspector: Reverse the direction of Inspector connections
Core::EventLoop now makes an outbound connection to InspectorServer
instead of listening for incoming connections on a /tmp/rpc/PID socket.

This has many benefits, for example:
- We no longer keep an open listening socket in most applications
- We stop leaking socket files in /tmp/rpc
- We can tighten the pledges in many programs (patch coming)
2021-05-13 23:28:40 +02:00
Andreas Kling
3d3a5b431f Services: Add InspectorServer to reverse the direction of Inspector
This service daemon will act as an intermediary between the Inspector
program and the inspectable programs it wants to inspect.

Programs can make themselves available for inspection by connecting
to /tmp/portal/inspectables using the Core::EventLoop RPC protocol.
2021-05-13 23:28:40 +02:00
Andreas Kling
3c3b384c80 SystemMonitor: Boost main thread priority to maximum on startup
It's frustrating when the system is under heavy load and you want to
investigate using SystemMonitor, but SystemMonitor chokes on the lag.

Let's at give it a fighting chance by maxing out the main thread prio.
2021-05-13 23:28:40 +02:00
Andreas Kling
c784413cd9 SymbolServer: Remove two unnecessary #include statements 2021-05-13 23:28:40 +02:00
Andreas Kling
0a75ee29da IPCCompiler: Add "u64" and "i64" to the list of primitive types 2021-05-13 23:28:40 +02:00
Andreas Kling
e46343bf9a Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr<size_t>
This makes error propagation less cumbersome (and also exposed some
places where we were not doing it.)
2021-05-13 23:28:40 +02:00
Valtteri Koskivuori
25a45e639a Magnifier: Add a 32x32 icon
This is stolen from the app-file-manager icon. I'm still 'borrowing' the
find icons for Magnifier, didn't see a reason to duplicate them.
2021-05-13 22:17:46 +01:00
Stephan Unverwerth
c2d84efaae LibGfx+Demos: Make Matrix4x4 a true alias for Matrix<4,T>
Matrix4x4 was defined as a derived class of Matrix<N,T> before.
Furthermore, some code was duplicated and it was overall just messy.
This commit turns Matrix4x4 into a simple alias for Matrix<4,T>.
2021-05-13 22:24:42 +02:00
Stephan Unverwerth
0833db0874 LibGfx: Make Matrix class consistently row-major
Matrix elements were interpreted in different ways.
This makes it definitely row-major, allowing initialization via
initializer list in a standard scientific order. Also matrix
multiplication now happens in the correct order and accessing
elements happens as m_elements[row][column].
2021-05-13 22:24:42 +02:00
Ali Mohammad Pur
a5194274af LibWasm: Stub out/implement parsing of all ElementSection segments
Previously, this was parsing only one kind because I mistakenly assumed
that they all had the same shape, now it can parse two kinds, and will
return NotImplemented for the rest.
2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
4d9246ac9d LibWasm: Add basic support for module instantiation and execution stubs
This adds very basic support for module instantiation/allocation, as
well as a stub for an interpreter (and executions APIs).
The 'wasm' utility is further expanded to instantiate, and attempt
executing the first non-imported function in the module.
Note that as the execution is a stub, the expected result is a zero.
Regardless, this will allow future commits to implement the JS
WebAssembly API. :^)
2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
2b755f1fbf LibWasm: Make the Module ctor generate a list of module functions
This list is supposed to be accessed rather frequently, so there's no
reason to make things slower by generating it many times on the spot.
2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
6e891822c5 LibWasm: Implement parsing of the DataCount section
With this, the parser should technically be able to parse all wasm
modules. Any parse failure on correct modules should henceforth be
labelled a bug :^)
2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
bd8dac111c LibWasm: Add a module pretty printer 2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
7a12f23c28 LibWasm: Un-nest the structured instructions 2021-05-13 19:44:32 +01:00
Ali Mohammad Pur
06a1c27e4d AK: Fix Variant's copy constructor trying to delegate to the wrong base
This was forgotten in 4fdbac2.
2021-05-13 19:44:32 +01:00
sin-ack
f248145e64 Shell: Fix incorrect fcntl usage
FD_CLOEXEC is a file descriptor flag, so one must use F_{G,S}ETFD
instead.
2021-05-13 19:18:22 +01:00
DexesTTP
fd80e7a339 LibCrypto: Reduce the UnsignedBigInteger inline size to 32 words
We never really needed the 512 words in the first place, and this does
reduce the stack allocations in montgomery modular power from 32Kb to
a more manageable 2Kb :^)

Note that the 32 words size doesn't provide any performance benefits or
drawbacks compared to other values. All values seem to have equivalent
performances (the tested values were 1, 2, 4, ..., 512). But since the
previous value of 512 was definitely too big, let's reduce it for now!
2021-05-13 19:18:07 +01:00
DexesTTP
ac6bd3a7a4 test-crypto: Add more tests for the modular power operator
Also addresses a fixup in the test suite by moving the NumberTheory
tests out of the RSA suite and into the BigInteger suite.
2021-05-13 19:18:07 +01:00