-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This program is currently accepted
struct X {
y: Y,
}
struct Y {
x: X,
}
fn g() -> Y {
let y: *Y = new Y{f()};
*y
}
fn f() -> X {
let x: *X = new X{g()};
*x
}
fn main() -> int { f(); 0 }
The program is invalid as X and Y are infinitely embedded within themselves, thus calculation of sizeof(X) or sizeof(Y) does not terminate.
It leads to a stack overflow in the activation record calculation
Details
~/src/c/structlang (master) % echo '
struct X {
y: Y,
}
struct Y {
x: X,
}
fn g() -> Y {
let y: *Y = new Y{f()};
*y
}
fn f() -> X {
let x: *X = new X{g()};
*x
}
fn main() -> int { f(); 0 }
' | ./build/debug/structlangc -
AddressSanitizer:DEADLYSIGNAL
=================================================================
==84056==ERROR: AddressSanitizer: stack-overflow on address 0x00016d05fff0 (pc 0x0001025afcf4 bp 0x00016d060020 sp 0x00016d05ffd0 T0)
#0 0x1025afcf4 in lookup_builtin activation.c:139
#1 0x1025af7a4 in alignment_of_type activation.c:167
#2 0x1025af968 in alignment_of_type activation.c:178
#3 0x1025af968 in alignment_of_type activation.c:178
#4 0x1025af968 in alignment_of_type activation.c:178
...
Metadata
Metadata
Assignees
Labels
No labels