Bug 46119

Summary: -fsplit-stack - code crashes when passing large struct via stack
Product: gcc Reporter: Zdenek Sojka <zsojka>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: iant
Priority: P3 Keywords: wrong-code
Version: 4.6.0   
Target Milestone: ---   
Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu
Build: Known to work: 4.8.0, 4.8.5
Known to fail: 4.6.0, 4.9.0 Last reconfirmed: 2024-03-12 00:00:00
Attachments: reduced testcase

Description Zdenek Sojka 2010-10-21 16:04:24 UTC
Created attachment 22108 [details]
reduced testcase

Output:
$ gcc -fsplit-stack -fstack-protector-all pr46119.c
$ ./a.out 
Segmentation fault

Tested revisions:
r165768 - fail
Comment 1 Andrew Pinski 2012-02-02 17:26:40 UTC
This works for me on the trunk
Comment 2 Andrew Pinski 2021-08-08 22:12:07 UTC
-fsplit-stack is enough.  It worked in GCC 4.7.x and 4.8.x but broke again in 4.9.0.

The one where it worked main had (clang also has this):
        leaq    -32776(%rsp), %r11
        cmpq    %fs:112, %r11
        jae     .L6

The one where it fails has:

        leaq    -16392(%rsp), %r11
        cmpq    %fs:112, %r11