Commit Graph

17161 Commits

Author SHA1 Message Date
thankyouverycool
42717b5b79 Base: Add new icons for fonts and File Manager 2021-02-25 08:08:26 +01:00
Andreas Kling
bb9cf083c4 LibC: Avoid double memory clearing in calloc()
calloc() was internally calling malloc_impl() which would scrub out
all the allocated memory with the scrub byte (0xdc). We would then
immediately zero-fill the memory.

This was obviously a waste of time, and our hash tables were doing
it all the time. :^)
2021-02-24 23:03:38 +01:00
Angus Gibson
0c44deeee2 LibGUI: Let cursor start a wrapped line
In line wrapping mode, the same column refers both to the end of a
visual line and the beginning of the subsequent visual line. This
meant that the cursor couldn't move to the beginning of a visual
line. Now, we only let the cursor go to the end of a physical line,
not the visual line.

Closes #4786
2021-02-24 22:30:08 +01:00
Angus Gibson
ae51dea524 LibGUI: Remove redundant cursor update 2021-02-24 22:30:08 +01:00
Andreas Kling
42133a196a AK: Don't compare past '\0' in StringView::operator==(const char*)
We kept scanning the needle string even after hitting a null terminator
and that's clearly not right.

Found by oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31338
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31351
2021-02-24 22:13:04 +01:00
Brendan Coles
9bc3c3c962 Calculator: Add support for copy+paste using system clipboard 2021-02-24 22:01:37 +01:00
Andreas Kling
1ba1ca76d8 Base: Add jcs.org to Browser bookmarks
This page is great for testing and it exposes a bunch of issues we
should look into in LibWeb. :^)
2021-02-24 21:55:04 +01:00
AnotherTest
ecc8e99a6b LibGUI: Account for the row and column headers when painting a TableView
Otherwise we'd be drawing all the rows, instead of the ones in view.
Fixes #5483.
2021-02-24 21:02:02 +01:00
AnotherTest
6a6f19a72f Spreadsheet: Store the column index in a Position instead of its name
This will make constructing (and destructing) Positions a lot cheaper
(as it no longer needs to ref() and unref() a String).
Resulted from #5483, but doesn't fix it.
2021-02-24 21:02:02 +01:00
Andreas Kling
98f08a8bad Kernel: Panic early if the kernel gets too big for its memory slot
Let's help our future selves find this problem sooner next time it
happens. Hopefully we'll come up with a nicer loader before then,
but who knows. :^)
2021-02-24 20:57:47 +01:00
Andreas Kling
c7cf56421a Kernel: Build with -fsanitize=undefined for all compilers
Now that we don't specify individual -fsanitize=foo options, the Clang
inside CLion can handle it just fine, so no need for this workaround.
2021-02-24 20:47:56 +01:00
Brendan Coles
0ffc06b795 Profiler: Add help documentation 2021-02-24 20:40:00 +01:00
Hendiadyoin1
8f867df31a KUBSAN: Condense all options down to "undefined"
Now that there is enough memory and all fsanitize flags are working
we can condense all options back to one
2021-02-24 16:00:51 +01:00
Brian Gianforcaro
303620ea85 Kernel: Fix pointer overflow in create_thread
KUBSAN found this overflow from syscall fuzzing.

Fixes #5498
2021-02-24 15:14:13 +01:00
Andreas Kling
7db8ccc0e4 LibC+DynamicLoader: Move "transactional memory" GCC stubs to LibC
Instead of having a special case in the dynamic loader where we ignore
TM-related GCC symbols, just stub them out in LibC like we already do
for various other things we don't support.
2021-02-24 14:54:26 +01:00
Brian Gianforcaro
069fd58381 LibELF: Convert more string literals to StringView literals.
Most of these won't have perf impact, but the optimization is
practically free, so no harm in fixing these up.
2021-02-24 14:45:34 +01:00
Andreas Kling
ce1775d81d Kernel: Oops, fix broken sys$uname() function definition 2021-02-24 14:42:38 +01:00
Brian Gianforcaro
141e6724d1 LibELF: Use StringView literal syntax to build section names. 2021-02-24 14:38:31 +01:00
Brian Gianforcaro
31e1b08e15 AK: Add support for AK::StringView literals with operator""sv
A new operator, operator""sv was added as of C++17 to support
string_view literals. This allows string_views to be constructed
from string literals and with no runtime cost to find the string
length.

See: https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv

This change implements that functionality in AK::StringView.
We do have to suppress some warnings about implementing reserved
operators as we are essentially implementing STL functions in AK
as we have no STL :).
2021-02-24 14:38:31 +01:00
Andreas Kling
a48d54dfc5 Kernel: Don't dereference untrusted userspace pointer in sys$uname()
Instead of writing to the userspace utsname struct one field at a time,
build up a utsname on the kernel stack and copy it out to userspace
once it's finished. This is both simpler and gets validity checking
built-in for free.

Found by KUBSAN! :^)

Fixes #5499.
2021-02-24 14:37:36 +01:00
Andreas Kling
99cd0d3ffb Kernel: Improve KUBSAN logging for "type mismatch" errors
Parse out some more information about the error from the data we get.
2021-02-24 14:27:06 +01:00
Linus Groh
6ad3454bfb AK: Rename {DBGLN_NO => ENABLE}_COMPILETIME_FORMAT_CHECK
This is no longer limited to dbgln(). Also invert it to match all the
other ENABLE_FOO options.
2021-02-24 13:07:57 +01:00
AnotherTest
857cdee0d0 AK: Make dbgln_if() avoid evaluating the arguments when disabled
Naturally, this makes the `enabled` flag on dbgln() obsolete.
2021-02-24 13:07:28 +01:00
AnotherTest
71de5433f8 LibLine: Note that the search() call modifies the buffer
Fixes #5465.
2021-02-24 12:19:20 +01:00
AnotherTest
dd87b14f52 LibLine: Update the drawn cursor value when updating lazily 2021-02-24 12:19:20 +01:00
AnotherTest
21cbcdd7da LibLine: Properly update the main editor when clearing the search editor
This broke after the lazy update change :P
2021-02-24 12:19:20 +01:00
Sahan Fernando
bf68939bcc Profiler: Make sure rendered timestamps don't overflow
If you drag-select a slice of the profile off of the side of the
Profiler window, the profiler will try to render a negative start time,
which will overflow. This commit fixes that bug by clamping timestamps
to the start/end of the profile before rendering.
2021-02-24 12:19:01 +01:00
Linus Groh
7dd233b2b6 LibJS: Use const references to avoid some copies in the parser 2021-02-24 11:43:05 +01:00
Andreas Kling
692bfc6ba2 Kernel: Fix some number typos in Arch/i386/boot.S 2021-02-24 11:40:31 +01:00
Andreas Kling
f27eb315fc Build: Build Userland with -O2, Kernel with -Os
For some reason I don't yet understand, building the kernel with -O2
produces a way-too-large kernel on some people's systems.

Since there are some really nice performance benefits from -O2 in
userspace, let's do a compromise and build Userland with -O2 but
put Kernel back into the -Os box for now.
2021-02-24 11:38:52 +01:00
Brian Gianforcaro
0817ea01c2 CMake: Fix build incrementality for boot.S
Due to the non-standard way the boot assembler code is linked into
the kernel (not and actual dependency, but linked via linker.ld script)
both make and ninja weren't re-linking the kernel when boot.S was
changed. This should theoretically work since we use the cmake
`add_dependencies(..)` directive to express a manual dependency
on boot from Kernel, but something is obviously broken in cmake.

We can work around that with a hack, which forces a dependency on
a file we know will always exist in the kernel (init.cpp). So if
boot.S is rebuilt, then init.cpp is forced to be rebuilt, and then
we re-link the kernel. init.cpp is also relatively small, so it
compiles fast.
2021-02-24 10:28:59 +01:00
Brian Gianforcaro
90adfcad3a Toolchain: Upgrade BuildQemu.sh to the latest 5.2.0 release 2021-02-24 10:28:15 +01:00
Linus Groh
e640fdd395 LibJS: Let RegExpPrototype inherit from Object directly
https://tc39.es/ecma262/#sec-properties-of-the-regexp-prototype-object

The RegExp prototype object:
- is an ordinary object.
- is not a RegExp instance and does not have a [[RegExpMatcher]]
  internal slot or any of the other internal slots of RegExp instance
  objects.

In other words: no need to have RegExpPrototype inherit from
RegExpObject (we weren't even calling its initialize()).
2021-02-24 10:22:17 +01:00
Linus Groh
a72276407b LibJS: Make ArrayPrototype an Array object
https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object

The Array prototype object: [...] is an Array exotic object and has the
internal methods specified for such objects.

NOTE: The Array prototype object is specified to be an Array exotic
object to ensure compatibility with ECMAScript code that was created
prior to the ECMAScript 2015 specification.
2021-02-24 10:22:17 +01:00
Andreas Kling
84996c6567 Everywhere: Okay let's try that -O2 build again :^)
Now that the issue with the kernel outgrowing its slot is patched,
we should be able to boot a slightly larger kernel without trouble.
2021-02-23 21:52:26 +01:00
Andreas Kling
8cd5477e54 Kernel: Expand the kernel memory slot from 8 MiB to 16 MiB
We were only 448 KiB away from filling up the old slot size we reserve
for the kernel above the 3 GiB mark. This expands the slot to 16 MiB,
which allows us to continue booting the kernel until somebody takes
the time to improve our loader.
2021-02-23 21:50:18 +01:00
Andreas Kling
4ba36c6a49 Build: Revert back to building with -Os
-O2 kernels are failing to boot on other people's machines for some
reason that we need to investigate. In the meantime, let's revert.
2021-02-23 21:22:20 +01:00
Andreas Kling
679cc154e6 Everywhere: Remove unused RELEASE_ASSERT macro 2021-02-23 21:11:53 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
b33a6a443e LibELF: Inline DynamicObject::hash_section()
This was high up in profiles and gets almost entirely optimized out
when inlined, so let's do that.
2021-02-23 20:33:32 +01:00
Andreas Kling
4ed85e9b9e LibELF: Don't build barely-used section lookup table in ELF::Image
The name-to-section lookup table was only used in a handful of places,
and none of them were calling it nearly enough to justify building
a cache for it in the first place. So let's get rid of it and reduce
startup time by a little bit. :^)
2021-02-23 19:45:29 +01:00
Andreas Kling
06919d189b Kernel: Enable three missing KUBSAN options :^)
With the kernel command line issue fixed, we can now enable these
KUBSAN options without getting triple faults on startup:

* alignment
* null
* pointer-overflow
2021-02-23 19:43:44 +01:00
Andreas Kling
bc029a6314 Everywhere: Build with -O2 :^)
Let's try going faster instead of smaller.
2021-02-23 19:43:44 +01:00
Andreas Kling
5100dabb96 Kernel: Copy the kernel command line to a good location at boot
When building the kernel with -O2, we somehow ended up with the kernel
command line outside of the lower 8MB of physical memory. Since we don't
map that area in our initial page table setup, we would triple fault
when trying to parse the command line.

This patch sidesteps the issue by copying the (first 4KB of) the kernel
command line to a buffer in a known safe location at boot.
2021-02-23 19:43:44 +01:00
Andreas Kling
4172a46fb5 LibDebug: Fix build with -O2
It turns out that LibDebug was the only thing that couldn't be built
with -O2. We were neglecting to deal with some stream read errors.
2021-02-23 19:43:44 +01:00
Andreas Kling
22b8110554 LibELF: Avoid doing strlen() on everything while iterating GNU hash
It's a lot faster to iterate the GNU hash tables if we don't have to
compute the length of every symbol name before rejecting it anyway while
comparing the first character. :^)
2021-02-23 19:43:44 +01:00
Andreas Kling
46a94a9a9e LibELF: Rename lookup_elf_symbol() => lookup_sysv_symbol()
We have two kinds of lookup, SYSV and GNU hash. Both are ELF lookups.
2021-02-23 19:43:44 +01:00
Andreas Kling
cc00df0f0f LibELF: Avoid calling strlen() in DynamicObject::hash_section()
The long-term fix here is to make StringView recognize compile-time
string literals and do the right thing automatically.
2021-02-23 19:43:44 +01:00
Andreas Kling
d6af3302e8 LibELF: Don't recompute the same ELF hashes over and over
When performing a global symbol lookup, we were recomputing the symbol
hashes once for every dynamic object searched. The hash function was
at the very top of a profile (15%) of program startup.

With this change, the hash function is no longer visible among the top
stacks in the profile. :^)
2021-02-23 19:43:44 +01:00
Andreas Kling
af6a633468 LibELF: Remove an ungodly amount of DYNAMIC_LOAD_DEBUG logging
This logging mode was unusable anyway since it spams way too much.
The dynamic loader is in a pretty good place now anyway, so I think
it's okay for us to drop some of the bring-up debug logging. :^)

Also, we have to be careful with dbgln_if(FOO_DEBUG, "{}", foo())
where foo() is something expensive, since it might get evaluated
even if !FOO_DEBUG.
2021-02-23 19:43:44 +01:00