Commit graph

349 commits

Author SHA1 Message Date
Linus Groh 52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh 4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Ben Wiederhake 50ad294527 AK: Implement a way to resolve relative paths lexically 2021-10-10 15:18:55 -07:00
Nico Weber 96666f3209 Tests: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Andreas Kling fc36f830ae Tests: Disable LibThreading detach tests for now
These tests don't pass (at least not without KVM) at the moment,
so let's not run them on CI.
2021-10-06 19:21:35 +02:00
Junior Rantila 1552873275 Tests: Add LibThreading to CMakeLists.txt 2021-10-06 19:05:39 +02:00
Rodrigo Tobar 4b091a7cc2 LibELF: Fix dynamic linking of dlopen()-ed libs
Consider the situation where two shared libraries libA and libB, both
depending (as in having a NEEDED dtag) on libC. libA is first
dlopen()-ed, which produces libC to be mapped and linked. When libB is
dlopen()-ed the DynamicLinker would re-map and re-link libC though,
causing any previous references to its old location to be invalid. And
if libA's PLT has been patched to point to libC's symbols, then any
further invocations to libA will cause the code to jump to a virtual
address that isn't mapped anymore, therefore causing a crash. This
situation was reported in #10014, although the setup was more convolved
in the ticket.

This commit fixes the issue by distinguishing between a main program
loading being performed by Loader.so, and a dlopen() call. The main
difference between these two cases is that in the former the
s_globals_objects maps is always empty, while in the latter it might
already contain dependencies for the library being dlopen()-ed. Hence,
when collecting dependencies to map and link, dlopen() should skip those
that are present in the global map to avoid the issue described above.

With this patch the original issue seen in #10014 is gone, with all
python3 modules (so far) loading correctly.

A unit test reproducing a simplified issue is also included in this
commit. The unit test includes the building of two dynamic libraries A
and B with both depending on libline.so (and B also depending on A); the
test then dlopen()s libA, invokes one its function, then does the same
with libB.
2021-10-06 12:33:21 +02:00
Mahmoud Mandour 0e5b2c923d LibSQL: Add an INSERT without column names test
This adds a passing test of an insert statement that contains no column
names and assumes full tuple input
2021-10-04 15:51:48 +02:00
Mahmoud Mandour 235573f7ba LibSQL: Test INSERT statement with wrong number of values 2021-10-04 15:51:48 +02:00
Mahmoud Mandour 4df85840c3 LibSQL: Test INSERT statement with wrong data types 2021-10-04 15:51:48 +02:00
Mahmoud Mandour 6065383e05 LibSQL: Check NoError individually in execution tests
This enables tests to check that a statement is erroneous, we could not
do so by only calling `execute()` since it asserted that no errors
occurred.
2021-10-04 15:51:48 +02:00
Tim Schumacher 7af7fc8c16 Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
Ali Mohammad Pur 8f722302d9 LibRegex: Use a match table for character classes
Generate a sorted, compressed series of ranges in a match table for
character classes, and use a binary search to find the matches.
This is about a 3-4x speedup for character class match performance. :^)
2021-10-03 19:16:36 +02:00
davidot ac2c3a73b1 LibJS: Add a specific test for invalid unicode characters in the lexer
Also fixes that it tried to make substrings past the end of the source
if we overran the source length.
2021-10-03 17:42:05 +02:00
Tim Schumacher 4302e7ac26 Tests: Add tests for mbrtowc 2021-10-03 11:13:50 +00:00
Tim Schumacher 67a579aab0 AK: Add a basic formatter for wchar_t 2021-10-03 11:13:50 +00:00
Tim Schumacher e7f99edefa Tests: Add a test for mbsinit 2021-10-03 11:13:50 +00:00
Tim Schumacher 05b283f552 LibC: Implement wmemmove 2021-10-03 05:28:51 +00:00
Tim Schumacher fa1208edfd LibC: Implement wmemset 2021-10-03 05:28:51 +00:00
Tim Schumacher 485c0ef691 LibC: Implement wmemcpy 2021-10-03 05:28:51 +00:00
Tim Schumacher 0ca1df4dc6 LibC: Implement wmemchr 2021-10-03 05:28:51 +00:00
Tim Schumacher 5ac2e84264 LibC: Implement wcsstr 2021-10-03 05:28:51 +00:00
Tim Schumacher 1b078f87b7 LibC: Implement wcspbrk 2021-10-03 05:28:51 +00:00
Liav A 4974727dbb Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
Nico Weber 841a5fe81b Tests: Fix typos 2021-10-01 01:33:43 +01:00
davidot ce3f29a135 LibJS + test-js: Get results from the global object directly
This is as the spec would require you to do it and necessary for changes
to come in the following commits.
2021-09-30 08:16:32 +01:00
Rodrigo Tobar a8fae3d2c8 LibPthread: Add first test cases for RWlock 2021-09-28 18:36:20 +03:30
Andreas Kling f67648f872 LibWeb: Rename HTMLDocumentParser => HTMLParser 2021-09-25 23:36:43 +02:00
Ben Wiederhake 743470c8f2 AK: Introduce ability to default-initialize a Variant
I noticed that Variant<Empty, …> is a somewhat common pattern while
working on #10080, and this will simplify a few use-cases. :^)
2021-09-21 04:22:52 +04:30
Ali Mohammad Pur 436693c0c9 LibTLS: Use a setter for on_tls_ready_to_write with some more smarts
The callback should be called as soon as the connection is established,
and if we actually set the callback when it already is, we expect it to
be called immediately.
2021-09-19 21:10:23 +04:30
thankyouverycool 41ce6d0cd0 Tests: Conform font tests to new font format 2021-09-19 00:58:59 +02:00
Andreas Kling 1be4cbd639 AK: Make Utf8View constructors inline and remove C string constructor
Using StringView instead of C strings is basically always preferable.
The only reason to use a C string is because you are calling a C API.
2021-09-18 19:54:24 +02:00
Tim Schumacher b8c756a53a LibC: Primitively implement wcscoll
At the moment, sorting like LC_COLLATE=C would do is better than
nothing.
2021-09-18 02:57:56 +00:00
Tim Schumacher 42031f026a LibC: Implement towctrans 2021-09-17 22:59:51 +00:00
Tim Schumacher 8c7b566629 LibC: Implement iswctype 2021-09-17 22:59:51 +00:00
Tim Schumacher ff0ab8b9a9 LibC: Implement wctrans 2021-09-17 22:59:51 +00:00
Tim Schumacher 7b17230d7a LibC: Implement wctype 2021-09-17 22:59:51 +00:00
Ben Wiederhake 5f0f0ac413 crash: Don't test for qemu-unsupported feature
See #10042 for details. In short: qemu doesn't seem to implement that
feature, therefore the test correctly fails. However, that does not help
us, so we skip that test.
2021-09-16 20:51:24 +00:00
Ben Wiederhake c680ef0a09 crash: Run automatically during CI 2021-09-16 20:51:24 +00:00
Andrew Kaster 6e7cc40b18 Meta: Add Meta/CMake to the CMAKE_MODULE_PATH for Serenity and Lagom
This makes it so we don't need to specify the full path to all the
helper scripts we include() from different places in the codebase and
feels a lot cleaner.
2021-09-15 19:04:52 +04:30
Ali Mohammad Pur 741886a4c4 LibRegex: Make the optimizer understand references and capture groups
Otherwise the fork in patterns like `(1+)\1` would be (incorrectly)
optimized away.
2021-09-15 15:52:28 +04:30
Andreas Kling 0a09eaf3a1 LibJS+LibTest: Use JS::Script and JS::SourceTextModule in test-js
Instead of creating a Parser and Lexer manually in test-js, we now
use either JS::Script::parse() or JS::SourceTextModule::parse()
to load tests.
2021-09-14 21:41:51 +02:00
Ali Mohammad Pur ccb53c64e9 AK: Add an abstraction over multiple disjoint buffers
DisjointChunks<T> provides a nice interface over multiple sequential
Vector<T>'s, allowing the user to iterate over/index into/slice from
said buffers as if they were a single contiguous buffer.
To work with views on such objects, DisjointSpans<T> is provided, which
has the same behaviour but does not own the underlying objects.
2021-09-14 21:33:15 +04:30
Idan Horowitz d6cfa34667 AK: Make URL::m_port an Optional<u16>, Expose raw port getter
Our current way of signalling a missing port with m_port == 0 was
lacking, as 0 is a valid port number in URLs.
2021-09-14 00:14:45 +02:00
Ali Mohammad Pur 246ab432ff LibRegex: Add a basic optimization pass
This currently tries to convert forking loops to atomic groups, and
unify the left side of alternations.
2021-09-13 14:38:53 +04:30
Timothy Flynn 470262c8ab LibJS: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn c59b97043e LibWeb: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Idan Horowitz 6704961c82 AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.

As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
2021-09-11 20:36:43 +03:00
Ben Wiederhake 2e4ec891da Everywhere: Fix format-vulnerabilities
Command used:
grep -Pirn '(out|warn)ln\((?!["\)]|format,|stderr,|stdout,|output, ")' \
     AK Kernel/ Tests/ Userland/
(Plus some manual reviewing.)

Let's pick ArgsParser as an example:
    outln(file, m_general_help);
This will fail at runtime if the general help happens to contain braces.

Even if this transformation turns out to be unnecessary in a place or
two, this way the code is "more obviously" correct.
2021-09-11 15:16:26 +01:00
Brian Gianforcaro a4efaa7b47 Tests/Kernel: Fix test after off-by-one fix in Memory::is_user_range()
Commit 890c647e0f fixed an off-by-one bug, so the mapping of the page
at the very end of the user address space now works correctly.

This change adjusts the test so cover the corner cases the original
version was designed too.validate.
2021-09-11 04:15:16 +00:00