* [PATCH] Fix jit crash on aarch64, mips
@ 2016-02-04 15:09 David Malcolm
2016-02-04 15:35 ` James Greenhalgh
0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2016-02-04 15:09 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
The jit testsuite was showing numerous segfaults and fatal
errors for trunk on aarch64; typically on the 2nd iteration of each
test, with errors like:
test-volatile.c.exe: fatal error: pass ârnregâ not found but is referenced by new pass âwhole-programâ
where the new pass' name varies, and can be bogus, e.g.:
test-nested-loops.c.exe: fatal error: pass 'rnreg' not found but is referenced by new pass '/tmp/libgccjit-FMb7g3/fake.c'
This is a regression relative to gcc 5.
The root cause is that aarch64_register_fma_steering builds and
registers an "fma_steering" pass after "rnreg", but the
struct register_pass_info
containing the arguments to register_pass is marked "static".
Hence after the 1st iteration, the pointer to the pass isn't touched,
and we have a use-after-free of the 1st iteration's pass_fma_steering.
The attached patch removes the "static" from the relevant local, so
that the pass pointer is updated before each call to register_pass.
With this patch, the jit testsuite runs successfully (8514 passes) on
gcc113 (aarch64-unknown-linux-gnu).
I used grep to see if there were any other
"static struct register_pass_info"
in the code, and there's one in the mips backend, so I did the same
change there (untested).
Bootstrap on aarch64 in progress; I don't have mips handy.
OK for trunk if it passes?
gcc/ChangeLog:
* config/aarch64/cortex-a57-fma-steering.c
(aarch64_register_fma_steering): Remove "static" from arguments
to register_pass.
* config/mips/frame-header-opt.c (mips_register_frame_header_opt):
Likewise.
---
gcc/config/aarch64/cortex-a57-fma-steering.c | 2 +-
| 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/config/aarch64/cortex-a57-fma-steering.c b/gcc/config/aarch64/cortex-a57-fma-steering.c
index 5d2ec87..21159fe 100644
--- a/gcc/config/aarch64/cortex-a57-fma-steering.c
+++ b/gcc/config/aarch64/cortex-a57-fma-steering.c
@@ -1082,7 +1082,7 @@ aarch64_register_fma_steering ()
{
opt_pass *pass_fma_steering = make_pass_fma_steering (g);
- static struct register_pass_info fma_steering_info
+ struct register_pass_info fma_steering_info
= { pass_fma_steering, "rnreg", 1, PASS_POS_INSERT_AFTER };
register_pass (&fma_steering_info);
--git a/gcc/config/mips/frame-header-opt.c b/gcc/config/mips/frame-header-opt.c
index cc51577..9c3674a 100644
--- a/gcc/config/mips/frame-header-opt.c
+++ b/gcc/config/mips/frame-header-opt.c
@@ -98,7 +98,7 @@ void
mips_register_frame_header_opt (void)
{
opt_pass *p = make_pass_ipa_frame_header_opt (g);
- static struct register_pass_info f =
+ struct register_pass_info f =
{p, "comdats", 1, PASS_POS_INSERT_AFTER };
register_pass (&f);
}
--
1.8.5.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix jit crash on aarch64, mips
2016-02-04 15:09 [PATCH] Fix jit crash on aarch64, mips David Malcolm
@ 2016-02-04 15:35 ` James Greenhalgh
0 siblings, 0 replies; 2+ messages in thread
From: James Greenhalgh @ 2016-02-04 15:35 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches
On Thu, Feb 04, 2016 at 10:31:27AM -0500, David Malcolm wrote:
> The jit testsuite was showing numerous segfaults and fatal
> errors for trunk on aarch64; typically on the 2nd iteration of each
> test, with errors like:
> test-volatile.c.exe: fatal error: pass ârnregâ not found but is referenced by new pass âwhole-programâ
> where the new pass' name varies, and can be bogus, e.g.:
> test-nested-loops.c.exe: fatal error: pass 'rnreg' not found but is referenced by new pass '/tmp/libgccjit-FMb7g3/fake.c'
>
> This is a regression relative to gcc 5.
>
> The root cause is that aarch64_register_fma_steering builds and
> registers an "fma_steering" pass after "rnreg", but the
> struct register_pass_info
> containing the arguments to register_pass is marked "static".
> Hence after the 1st iteration, the pointer to the pass isn't touched,
> and we have a use-after-free of the 1st iteration's pass_fma_steering.
>
> The attached patch removes the "static" from the relevant local, so
> that the pass pointer is updated before each call to register_pass.
>
> With this patch, the jit testsuite runs successfully (8514 passes) on
> gcc113 (aarch64-unknown-linux-gnu).
>
> I used grep to see if there were any other
> "static struct register_pass_info"
> in the code, and there's one in the mips backend, so I did the same
> change there (untested).
>
> Bootstrap on aarch64 in progress; I don't have mips handy.
>
> OK for trunk if it passes?
The AArch64 part is OK (assuming bootstrap and test succeed), thanks.
James
>
> gcc/ChangeLog:
> * config/aarch64/cortex-a57-fma-steering.c
> (aarch64_register_fma_steering): Remove "static" from arguments
> to register_pass.
> * config/mips/frame-header-opt.c (mips_register_frame_header_opt):
> Likewise.
> ---
> gcc/config/aarch64/cortex-a57-fma-steering.c | 2 +-
> gcc/config/mips/frame-header-opt.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-04 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 15:09 [PATCH] Fix jit crash on aarch64, mips David Malcolm
2016-02-04 15:35 ` James Greenhalgh
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).