Merge pull request #6402 from bymehul/fix-6401-generic-cycle-deadlock

Fix generic cycle deadlock in struct layout
This commit is contained in:
gingerBill
2026-03-11 11:45:22 +00:00
committed by GitHub
4 changed files with 26 additions and 2 deletions

View File

@@ -4201,8 +4201,9 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
if (t->Struct.is_packed) {
return 1;
}
type_set_offsets(t);
// Avoid forcing offset computation here. The caller's type-path state must
// be able to detect recursive field cycles before any nested struct tries to
// re-enter this struct's offset mutex.
i64 max = 1;
for_array(i, t->Struct.fields) {

View File

@@ -31,6 +31,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
..\..\..\odin test ..\test_issue_6101.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_6165.odin %COMMON% || exit /b
..\..\..\odin build ..\test_issue_6240.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b
..\..\..\odin build ..\test_issue_6401.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b
@echo off

View File

@@ -43,6 +43,12 @@ else
echo "SUCCESSFUL 0/1"
exit 1
fi
if [[ $($ODIN build ../test_issue_6401.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]] ; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
set +x
popd

View File

@@ -0,0 +1,16 @@
// Tests issue #6401 https://github.com/odin-lang/Odin/issues/6401
package test_issues
Wrapper :: struct(T: typeid) {
value: T,
}
A :: struct {
value: Wrapper(B),
}
B :: struct {
value: A,
}
main :: proc() {}