https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119597
Bug ID: 119597
Summary: SEGV on Cobol "hello world" on Power
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: bergner at gcc dot gnu.org
Target Milestone: ---
After fixing the bug in PR119308, we still end up SEGVing when we execute the
Cobol hello world program if it's compiled with -O0.
bergner@kubota:COBOL$ cat hello.cob
IDENTIFICATION DIVISION.
PROGRAM-ID. hello-world.
PROCEDURE DIVISION.
DISPLAY "Hello, world!"
.
bergner@kubota:COBOL$ gcobol -O0 hello.cob
bergner@kubota:COBOL$ ./a.out
Hello, world!
Segmentation fault (core dumped)
As described in PR119308, the problem is we do not allocate enough stack space
for our stack frame and spills end up overwriting the callers stack frame. In
this example, we end up clobbering the caller's saved backchain so when it
returns to its caller, it ends up in the weeds and crashes.