public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain
@ 2022-11-23 16:44 gabravier at gmail dot com
2022-11-23 16:59 ` [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: gabravier at gmail dot com @ 2022-11-23 16:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
Bug ID: 107840
Summary: ICE when compiling cursed setjmp/longjmp that uses
__builtin_call_with_static_chain
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
typedef __UINT16_TYPE__ uint16_t;
typedef __UINT32_TYPE__ uint32_t;
typedef __INTPTR_TYPE__ intptr_t;
#define unreachable __builtin_unreachable
typedef struct{
const uint16_t mov1;
const uint32_t addr;
const uint16_t mov2;
const void * const chain;
} __attribute__((packed)) thunk_struct;
#define NESTED_CHAIN(p) ({ \
thunk_struct *__t = (void*)p; \
__t->chain; \
})
#define NESTED_ADDR(p) ({ \
auto __p = (p); \
thunk_struct *__t = (void*)__p; \
(typeof(__p))(intptr_t)__t->addr; \
})
#define NESTED_UPGRADE(self, ptr, args) ({ \
if(self != ptr) \
__builtin_call_with_static_chain( \
NESTED_ADDR((typeof(self)*)ptr) args, \
NESTED_CHAIN(ptr) \
); \
})
typedef struct{
// can't apply standard [[noreturn]] to function pointers
[[gnu::noreturn]] void(*fun)(void*, int);
}xjmp_buf[1];
#define xsetjmp(env) ({ \
__label__ trgt; \
int __xsetjmp_ret = 0; \
[[noreturn]] void __jmp(void *self, int r){ \
NESTED_UPGRADE(__jmp, self, (self, r)); \
__xsetjmp_ret = r ?: 1; \
goto trgt; \
} \
env[0].fun = __jmp; \
trgt:; \
int tmp = __xsetjmp_ret; \
__xsetjmp_ret = 0; \
tmp; \
})
[[noreturn, gnu::always_inline]] inline void xlongjmp(xjmp_buf env, int r){
((void(*)(void*, int))NESTED_ADDR(env[0].fun))(env[0].fun, r);
unreachable();
}
int main(){
int a = 0;
xjmp_buf test;
void foo(xjmp_buf ctx){
if(!xsetjmp(ctx)){
(volatile void)0;
}
}
foo(test);
xlongjmp(test, ++a);
}
Compiling this code with `-std=c2x` results in the following error:
<source>: In function 'foo':
<source>:60:14: error: label '({anonymous})' has incorrect context in bb 4
60 | void foo(xjmp_buf ctx){
| ^~~
during GIMPLE pass: cfg
dump file: /app/output.c.015t.cfg
<source>:60:14: internal compiler error: verify_flow_info failed
0x2008dee internal_error(char const*, ...)
???:0
0xaf90d7 verify_flow_info()
???:0
0x10447c7 cleanup_tree_cfg(unsigned int)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
(PS: I cannot seem to get more of the necessary information from Godbolt,
although the bug seems simple enough to reproduce without it. Still, this link
to the setup I got the bug in might help: https://godbolt.org/z/cd7f4Mdzd)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
@ 2022-11-23 16:59 ` pinskia at gcc dot gnu.org
2022-11-23 17:08 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-23 16:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't think it is directly __builtin_call_with_static_chain but rather the
non-local jump causing issues.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
2022-11-23 16:59 ` [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps pinskia at gcc dot gnu.org
@ 2022-11-23 17:08 ` pinskia at gcc dot gnu.org
2022-11-23 17:09 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-23 17:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 53955
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53955&action=edit
testcase not using C23 features
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
2022-11-23 16:59 ` [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps pinskia at gcc dot gnu.org
2022-11-23 17:08 ` pinskia at gcc dot gnu.org
@ 2022-11-23 17:09 ` pinskia at gcc dot gnu.org
2022-11-24 14:31 ` marxin at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-23 17:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
With the testcase that does not use C23 features (which was only implemented in
GCC 13), we can get the ICE happening all the way back to at least GCC 6 with
-fchecking. GCC 5 didn't have -fchecking so I cannot check further back.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
` (2 preceding siblings ...)
2022-11-23 17:09 ` pinskia at gcc dot gnu.org
@ 2022-11-24 14:31 ` marxin at gcc dot gnu.org
2023-02-12 21:08 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-11-24 14:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2022-11-24
Status|UNCONFIRMED |NEW
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Also happens with 4.8.0+.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
` (3 preceding siblings ...)
2022-11-24 14:31 ` marxin at gcc dot gnu.org
@ 2023-02-12 21:08 ` pinskia at gcc dot gnu.org
2023-02-12 21:09 ` pinskia at gcc dot gnu.org
2024-01-09 3:27 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-12 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108765 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
` (4 preceding siblings ...)
2023-02-12 21:08 ` pinskia at gcc dot gnu.org
@ 2023-02-12 21:09 ` pinskia at gcc dot gnu.org
2024-01-09 3:27 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-12 21:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
int main()
{
void foo(void)
{
__label__ trgt;
void jmp(void) { goto trgt; }
trgt: ;
}
foo();
}
```
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
` (5 preceding siblings ...)
2023-02-12 21:09 ` pinskia at gcc dot gnu.org
@ 2024-01-09 3:27 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-09 3:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 40317.
*** This bug has been marked as a duplicate of bug 40317 ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-09 3:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 16:44 [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain gabravier at gmail dot com
2022-11-23 16:59 ` [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps pinskia at gcc dot gnu.org
2022-11-23 17:08 ` pinskia at gcc dot gnu.org
2022-11-23 17:09 ` pinskia at gcc dot gnu.org
2022-11-24 14:31 ` marxin at gcc dot gnu.org
2023-02-12 21:08 ` pinskia at gcc dot gnu.org
2023-02-12 21:09 ` pinskia at gcc dot gnu.org
2024-01-09 3:27 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).