Feoramund
fef5f526f3
Remove unneeded slicing in strings.clone
2025-03-05 13:54:31 -05:00
Feoramund
2ab1ca29e6
Fix data races in os2/env_linux.odin
...
Switched to a recursive mutex so that procedures which need to perform
lookups can do so while also maintaining the lock across their entire
body in order to guarantee atomicity for each environment operation.
2025-03-04 19:32:05 -05:00
Feoramund
179e5b9266
Fix typo
2025-03-04 19:12:45 -05:00
Feoramund
266f15b672
Fix indentation
2025-03-04 19:11:32 -05:00
Feoramund
2d0dc44636
Shorten buffers used for os2.random_string results
...
This is needed now that `os2.random_string` fills the whole slice.
2025-03-03 19:18:54 -05:00
Feoramund
d6002d68a2
Make os2.random_string use context.random_generator
...
This removes the data race caused by multiple threads using the
unprotected global `random_string_seed`, so long as no two threads share
the same random generator; this is the default case.
Additionally, `os2.random_string` now takes into account the full buffer
slice given to it.
2025-03-03 19:17:29 -05:00
Feoramund
675bffce88
Add missing allocator in os2.file_info_clone
2025-03-02 17:22:43 -05:00
Feoramund
7d1fcfa09b
Fix wrong path in os2.user_config_dir
2025-03-02 17:22:40 -05:00
Feoramund
6054b921db
Add tests for new safe to_cstring
2025-02-27 18:54:38 -05:00
Feoramund
b2e3b34ce0
Fix #4890
...
`strings.to_cstring` previously would not check if the buffer could
handle the extra null byte and could lead to segmentation violations
when using the resulting string in an API expecting the terminator.
2025-02-27 18:54:38 -05:00
Feoramund
84700e09c9
Forbid parsing more fields if no separator was found
...
Fixes #4278
2024-09-20 19:02:00 -04:00
Feoramund
acbf5c8d97
Forbid labelled or-branch expressions within defer
2024-09-19 05:59:37 -04:00
Feoramund
9456c36684
Specify integer-like only for some atomic_* intrinsics
...
Fixes #4256
2024-09-18 17:18:48 -04:00
Feoramund
16ef59700b
Check for EINTR in sys/posix test
2024-09-15 23:58:03 -04:00
Feoramund
d38f5ffb49
Remove unneeded synchronizations in Chan
...
Everything was already guarded by `c.mutex`.
2024-09-15 22:59:30 -04:00
Feoramund
7f7cfebc91
Add tests for core:sync and core:sync/chan
2024-09-11 08:39:38 -04:00
Feoramund
16cd16b91e
Fix comments
2024-09-11 08:39:23 -04:00
Feoramund
2938655a3d
Fix CPU count detection in FreeBSD & NetBSD
2024-09-11 08:39:23 -04:00
Feoramund
b1db33b519
Add cpu_relax to sync.auto_reset_event_signal
2024-09-11 08:39:23 -04:00
Feoramund
a1435a6a90
Fix deadlock in Auto_Reset_Event
2024-09-11 08:39:23 -04:00
Feoramund
fec1ccd7a3
Fix data races in sync.Recursive_Benaphore
2024-09-11 08:39:23 -04:00
Feoramund
b2c2235e58
Fix recursive_benaphore_try_lock
...
Previously, if the owner called this, it would fail.
2024-09-10 14:52:20 -04:00
Feoramund
3a60109180
Fix signalling test child threads crashing test 0
...
A thread made inside a test does not share the test index of its parent,
so any time one of those threads failed an assert, it would tell the
runner to shutdown test index zero.
2024-09-10 14:52:20 -04:00
Feoramund
074314b887
Fix data race in test_core_flags
2024-09-10 14:52:20 -04:00
Feoramund
8a14a656fb
Fix chan.can_send for unbuffered channels
...
`w_waiting` is the signal that says a caller is waiting to be able to
send something. It is incremented upon send and - in the case of an
unbuffered channel - it can only hold one message.
Therefore, check that `w_waiting` is zero instead.
2024-09-10 14:52:20 -04:00
Feoramund
e9a6a34480
Forbid chan.try_send on closed buffered channels
2024-09-10 14:52:20 -04:00
Feoramund
026aef69e3
Fix deadlock on sending to full, buffered, closed Chan
...
This will also keep messages from being sent to closed, buffered
channels in general.
2024-09-10 14:52:20 -04:00
Feoramund
73f5ab473c
Keep chan.can_recv from deadlocking
2024-09-10 14:52:20 -04:00
Feoramund
0a594147af
Use contextless procs in core:sync instead
2024-09-10 14:52:20 -04:00
Feoramund
c3f363cfbc
Fix data race when pool_stop_task is called
2024-09-09 16:19:15 -04:00
Feoramund
dbb783fbf2
Fix atomic memory order for sync.ticket_mutex_unlock
2024-09-09 16:19:15 -04:00
Feoramund
45da009377
Use more atomic handling of thread flags
...
This can prevent a data race on Linux with `Self_Cleanup`.
2024-09-09 16:19:15 -04:00
Feoramund
4d14b4257e
Convert POSIX Thread to use semaphore instead
...
One less value to store, and it should be less of a hack too.
Semaphores will not wait around if they have the go-ahead; they depend
on an internal value being non-zero, instead of whatever was loaded when
they started waiting, which is the case with a `Cond`.
2024-09-09 16:19:14 -04:00
Feoramund
cbd4d5e765
Fix data race in atomic_sema_wait_with_timeout
2024-09-09 16:19:14 -04:00
Feoramund
74b28f1ff9
Fix rare double-join possibility in POSIX thread._join
...
This was occuring about 1/100 times with the test runner's thread pool.
2024-09-09 16:19:14 -04:00
Feoramund
9d6f71fd2e
Fix sync.Benaphore
...
The calls to `atomic_add*` return the value before adding, not after, so
the previous code was causing the occasional data race.
2024-09-09 16:19:14 -04:00
Feoramund
2f1228baa0
Add tests for Bit_Array
2024-09-03 17:23:42 -04:00
Feoramund
c3bd94a27e
Change Bit_Array.max_index to length
...
This will allow correct iteration of empty `bit_array`s.
2024-09-03 16:56:02 -04:00
Feoramund
d86e56089a
Fix iteration of biased Bit_Array
2024-09-03 15:34:38 -04:00
Feoramund
b8f8cb9582
Add bit_array.shrink
2024-09-03 13:33:15 -04:00
Feoramund
001b2b9d8f
Let bit_array.create make zero-length arrays
2024-09-03 13:33:11 -04:00
Feoramund
806c87d71d
Check for zero-length slices in slice.equal
2024-09-03 02:48:26 -04:00
Feoramund
309953e0f2
Return false if Small_Array can't append multiple elements
...
Fixes #4177
2024-09-03 01:14:17 -04:00
Feoramund
f6f2c67f37
Add time.time_to_datetime
2024-09-03 00:55:09 -04:00
Feoramund
9871ad5fc8
Remove extra format item at end of context error message
2024-09-01 17:50:50 -04:00
Feoramund and Laytan
7fa2e56cd9
Add io tests for bufio streams
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
24a53c246f
Make sure seek succeeds in io.Limited_Reader test setup
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
b11fa90ed2
Test empty slice usage in io procs
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
f453054aff
Return 0, nil in all io cases where an empty slice is provided
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
ef99373c31
Fix pread and pwrite on os2 Windows
...
The previous code was jumping ahead by the specified offset, instead of
getting the current offset.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
1cd5cbb0e4
Test io unexpected pointer movement
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
56f232e5fc
Report invalid whence & offset on os2 Windows
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
de1432b315
Fix Windows infinite recursion with os2._flush
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
e7d6e2d163
Add documentation to os2.close
...
Make it explicit that using a stream after closing is like a
use-after-free bug.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
8b40be50b9
Update core:io tests
...
- Relax return value requirements on errors. Only the error is checked,
as there are multiple conflicting return styles throughout the `os`
API.
Some return the error along with `0`, `-1`, or another value. This can
be smoothed out later.
- Test `os2` files now.
- No longer test streams after closing; this is considered similar to a
use-after-free in `os2`.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
6798d15ecb
Check int(abs) instead to avoid overflows
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
6aedb2695a
Report Invalid_Whence on some os platforms
...
- Move `Seek`-related checks into OS-specific files for granularity.
Platforms:
- Darwin
- FreeBSD
- Haiku
- Linux
- NetBSD
- OpenBSD
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
0243647e15
Add missing flush functionality to os platforms
...
Platforms:
- FreeBSD
- Haiku
- Linux
- NetBSD
- OpenBSD
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
3ec4db212b
Report Invalid_Whence in os2 Linux seek
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
7683c1f4bb
Report Invalid_Whence in os2 POSIX seek
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
ef2cd9d97f
Copy missing errors in os2._get_platform_error from posix to linux
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
5b9e9fb822
Add test suite for core:io
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
741ccd7ff5
Zero n on error in _file_stream_proc
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
eb92a2df71
Fix indentation
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
d60f404bb4
Fix OpenBSD implementations of read_at and write_at
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
6c4806835c
Fix indentation
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
e1555e04ad
Fix Haiku implementations of read_at and write_at
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
7061032db6
Fix NetBSD implementations of read_at and write_at
...
These procedures must not modify the underlying file pointer.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
861d892ffe
Make Windows pread and pwrite conform to POSIX
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
5c8c63ae04
Fix FreeBSD implementations of read_at and write_at
...
These procedures must not modify the underlying file pointer.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
1ced76cdd1
Fix broken cases of Seek usage in _file_stream_proc
...
Handles `EINVAL`, among other fixes.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
e83b982afe
Measure bytes.Buffer size by length instead of capacity
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
7c6cc81041
Add Seek behavior to bytes.Buffer
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
521e47ffee
Don't invalidate prev_rune if Reader seek failed
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
8251f4d7d0
Return .EOF in bytes.buffer_read_at instead
...
This is consistent with the other stream `read` procs
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
da49f7eb4e
Make bytes.reader_init return an io.Stream
...
Makes the API like the other stream `init` procs.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
d66486c17e
Make io.Section_Reader set base too
...
This should fix seeking from `.Start`, getting the `size`, and
`read_at`.
Also make the API consistent with the other `*_init` procs in
`util.odin` by returning the `io.Reader`.
2024-08-28 19:53:20 +02:00
Feoramund and Laytan
981a2e1a00
Add missing io.Stream_Mode responses
2024-08-28 19:53:19 +02:00
Feoramund
1f04f541cf
Fix -vet and -strict-style failures in tests
2024-08-26 16:20:08 -04:00
Feoramund
d43c6e39f6
Fix #4151
...
The `core:mem` procs were calling the wrong `runtime` procs for their
number of arguments.
2024-08-26 13:23:04 -04:00
Feoramund
9fac03b84c
Fix use-after-free in thread.Pool
2024-08-26 06:39:05 -04:00
Feoramund
49606ec3ea
Use thread_local_cleaner API in os2
2024-08-26 06:01:59 -04:00
Feoramund
d338642dc4
Add API for freeing thread_local state
2024-08-26 06:01:59 -04:00
Feoramund
95d1c29c2a
Free the arenas allocated in test_core_runtime
...
Found by using `-sanitize:address`.
2024-08-26 05:45:24 -04:00
Feoramund
c424c94030
Fix inline transmutation of [16]i8 to i128
...
Forbids LLVM from generating SSE aligned loads on unaligned data.
2024-08-26 04:48:31 -04:00
Feoramund
0fa24ac3c4
Remove deprecated log procs from core:testing
2024-08-18 21:30:32 -04:00
Feoramund
b49b80bdf9
Add test for count_digits_of_base
2024-08-18 20:14:14 -04:00
Feoramund
2906f2aa7e
Add core:math.count_digits_of_base
2024-08-18 20:14:14 -04:00
Feoramund
a07878be71
Check if file open-mode is O_CREATE on Darwin before forcing chmod
...
Fixes #4087
2024-08-16 14:08:55 -04:00
Feoramund
3a32250b80
Add .gitignore for tests directory
2024-08-12 15:16:52 -04:00
Feoramund
0af025d056
Add explicit copyright info to core:testing
2024-08-12 14:16:22 -04:00
Feoramund
f42a22369e
Fix wrong define name in test runner log messages
2024-08-11 23:01:28 -04:00
Feoramund
675add4d90
Optionally treat memory failures as errors in the test runner
...
Enable with `-define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true`.
2024-08-11 22:59:20 -04:00
Feoramund
cf8f6afeff
Use intrinsics.reverse_bits in core:compress/zlib
2024-08-10 15:29:44 -04:00
Feoramund
afbdc78f85
Fix .gitignore
...
- Remove all-encompassing `benchmark`
- Add exception for `core:simd/x86`
2024-08-10 15:16:12 -04:00
Feoramund
4f816aabb3
Use SIMD_SCAN_WIDTH constant in core:bytes test
2024-08-10 13:54:12 -04:00
Feoramund
9d2b4b2f03
Simplify core:bytes test
2024-08-10 08:13:22 -04:00
Feoramund
5d5addd48f
Set SIMD_SCAN_WIDTH based on size_of(uintptr)
2024-08-10 07:43:14 -04:00
Feoramund
c69fa87d53
Merge core:simd/util into core:bytes
2024-08-10 07:17:03 -04:00
Feoramund
e7e7fe766a
Add test for misaligned data to core:simd/util suite
2024-08-09 18:54:04 -04:00