diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-19 19:54:12 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-19 19:54:12 -0400 |
| commit | 7022ad8378e307a70c436901c3d2870bf1e38a77 (patch) | |
| tree | 55f8894dec4f8de933c17eacc8268906ba679712 /tests | |
| parent | c2f3d074e34eecce2bb7dc2cf11ef2d5d65c019d (diff) | |
Add test for issue #3435
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/issues/run.bat | 1 | ||||
| -rwxr-xr-x | tests/issues/run.sh | 1 | ||||
| -rw-r--r-- | tests/issues/test_issue_3435.odin | 38 |
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 76d8f58b6..4a1072e12 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -17,6 +17,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style ..\..\..\odin test ..\test_issue_2637.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_2666.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_2694.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_3435.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4210.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4364.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4584.odin %COMMON% || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 305329e7d..03d84425a 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -18,6 +18,7 @@ $ODIN test ../test_issue_2615.odin $COMMON $ODIN test ../test_issue_2637.odin $COMMON $ODIN test ../test_issue_2666.odin $COMMON $ODIN test ../test_issue_2694.odin $COMMON +$ODIN test ../test_issue_3435.odin $COMMON $ODIN test ../test_issue_4210.odin $COMMON $ODIN test ../test_issue_4364.odin $COMMON $ODIN test ../test_issue_4584.odin $COMMON diff --git a/tests/issues/test_issue_3435.odin b/tests/issues/test_issue_3435.odin new file mode 100644 index 000000000..3830869ed --- /dev/null +++ b/tests/issues/test_issue_3435.odin @@ -0,0 +1,38 @@ +package main + +import "base:runtime" +import "core:mem" +import "core:testing" +import "core:time" + +@test +test_issue_3435 :: proc(t: ^testing.T) { + testing.set_fail_timeout(t, time.Second) + allocator: mem.Buddy_Allocator + data := runtime.make_aligned([]byte, 64, 32) + defer delete(data) + + // mem.buddy_allocator_init(&allocator, data, 32) + + // Bypass the assertion that would normally keep this from happening by + // manually putting the allocator together. + allocator.head = cast(^mem.Buddy_Block)raw_data(data) + allocator.head.size = len(data) + allocator.head.is_free = true + allocator.tail = mem.buddy_block_next(allocator.head) + allocator.alignment = 32 + + context.allocator = mem.buddy_allocator(&allocator) + + // Three allocations in the space above is all that's needed to reproduce + // the bug seen in #3435; this is the most minimal reproduction possible. + a := make([]u8, 1) + testing.expect(t, len(a) == 1) + b := make([]u8, 1) + testing.expect(t, len(b) == 0) + c := make([]u8, 1) + testing.expect(t, len(c) == 0) + + // With the bugfix in place, the allocator should be sensible enough to not + // fall into an infinite loop anymore, even if the assertion is disabled. +} |