diff mbox series

[RFC] target/sh4/translate.c: fix TCG leak during gusa sequence

Message ID 20171206093050.25308-1-alex.bennee@linaro.org
State New
Headers show
Series [RFC] target/sh4/translate.c: fix TCG leak during gusa sequence | expand

Commit Message

Alex Bennée Dec. 6, 2017, 9:30 a.m. UTC
This fixes bug #1735384 while running java under qemu-sh4. When debug
was enabled it showed a problem with TCG temps. Once fixed I was able
to run java -version normally.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 target/sh4/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Paul Adrian Glaubitz Dec. 6, 2017, 9:45 a.m. UTC | #1
Hi Alex!

Wow, thanks! I wanted to run your suggested test today as I ran out of
time yesterday and now you already fixed it :-).

Thanks a lot!

Adrian

> On Dec 6, 2017, at 10:30 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
> 
> This fixes bug #1735384 while running java under qemu-sh4. When debug
> was enabled it showed a problem with TCG temps. Once fixed I was able
> to run java -version normally.
> 
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> target/sh4/translate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
> index 703020fe87..b4b5c822d0 100644
> --- a/target/sh4/translate.c
> +++ b/target/sh4/translate.c
> @@ -2189,7 +2189,7 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
>     }
> 
>     /* If op_src is not a valid register, then op_arg was a constant.  */
> -    if (op_src < 0) {
> +    if (op_src < 0 && !TCGV_IS_UNUSED(op_arg)) {
>         tcg_temp_free_i32(op_arg);
>     }
> 
> -- 
> 2.15.1
> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1735384
> 
> Title:
>  OpenJDK JVM segfaults on qemu-sh4 (regression)
> 
> Status in QEMU:
>  New
> 
> Bug description:
>  Some of the recent changes introduced a regression which makes the
>  OpenJDK JVM crash on qemu-sh4:
> 
>  (sid-sh4-sbuild)root@nofan:/# java -version
>  qemu: uncaught target signal 11 (Segmentation fault) - core dumped
>  Segmentation fault
>  (sid-sh4-sbuild)root@nofan:/#
> 
>  An older version works fine:
> 
>  (sid-sh4-sbuild)root@nofan:/# java -version
>  openjdk version "9.0.1"
>  OpenJDK Runtime Environment (build 9.0.1+11-Debian-1)
>  OpenJDK Zero VM (build 9.0.1+11-Debian-1, interpreted mode)
>  (sid-sh4-sbuild)root@nofan:/#
> 
>  Haven't had time for bisecting this yet.
> 
>  Adrian
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1735384/+subscriptions
John Paul Adrian Glaubitz Dec. 6, 2017, 10:22 a.m. UTC | #2
On 12/06/2017 10:30 AM, Alex Bennée wrote:
> This fixes bug #1735384 while running java under qemu-sh4. When debug
> was enabled it showed a problem with TCG temps. Once fixed I was able
> to run java -version normally.
> 
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

I can confirm that this fixes the issue for me, too.

So, just in case:

Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Alex Bennée Dec. 6, 2017, 10:52 a.m. UTC | #3
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> writes:

> Hi Alex!
>
> Wow, thanks! I wanted to run your suggested test today as I ran out of
> time yesterday and now you already fixed it :-).

Can you confirm you've tested it and your happy it works?

>
> Thanks a lot!
>
> Adrian
>
>> On Dec 6, 2017, at 10:30 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> This fixes bug #1735384 while running java under qemu-sh4. When debug
>> was enabled it showed a problem with TCG temps. Once fixed I was able
>> to run java -version normally.
>>
>> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
>> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>> target/sh4/translate.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
>> index 703020fe87..b4b5c822d0 100644
>> --- a/target/sh4/translate.c
>> +++ b/target/sh4/translate.c
>> @@ -2189,7 +2189,7 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
>>     }
>>
>>     /* If op_src is not a valid register, then op_arg was a constant.  */
>> -    if (op_src < 0) {
>> +    if (op_src < 0 && !TCGV_IS_UNUSED(op_arg)) {
>>         tcg_temp_free_i32(op_arg);
>>     }
>>
>> --
>> 2.15.1
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1735384
>>
>> Title:
>>  OpenJDK JVM segfaults on qemu-sh4 (regression)
>>
>> Status in QEMU:
>>  New
>>
>> Bug description:
>>  Some of the recent changes introduced a regression which makes the
>>  OpenJDK JVM crash on qemu-sh4:
>>
>>  (sid-sh4-sbuild)root@nofan:/# java -version
>>  qemu: uncaught target signal 11 (Segmentation fault) - core dumped
>>  Segmentation fault
>>  (sid-sh4-sbuild)root@nofan:/#
>>
>>  An older version works fine:
>>
>>  (sid-sh4-sbuild)root@nofan:/# java -version
>>  openjdk version "9.0.1"
>>  OpenJDK Runtime Environment (build 9.0.1+11-Debian-1)
>>  OpenJDK Zero VM (build 9.0.1+11-Debian-1, interpreted mode)
>>  (sid-sh4-sbuild)root@nofan:/#
>>
>>  Haven't had time for bisecting this yet.
>>
>>  Adrian
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/qemu/+bug/1735384/+subscriptions


--
Alex Bennée
John Paul Adrian Glaubitz Dec. 6, 2017, 11:37 a.m. UTC | #4
On 12/06/2017 11:52 AM, Alex Bennée wrote:
>> Wow, thanks! I wanted to run your suggested test today as I ran out of
>> time yesterday and now you already fixed it :-).
> 
> Can you confirm you've tested it and your happy it works?

I already confirmed it, but in case my previous mail got lost:

Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

And, yes, I'm happy it works :-). Can now switch back to using the latest
qemu snapshot for building packages for Debian sh4.

Adrian
Richard Henderson Dec. 6, 2017, 2:15 p.m. UTC | #5
On 12/06/2017 01:30 AM, Alex Bennée wrote:
> This fixes bug #1735384 while running java under qemu-sh4. When debug
> was enabled it showed a problem with TCG temps. Once fixed I was able
> to run java -version normally.
> 
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Cc: stable, as the bug is present in 2.10 too.

r~

>  target/sh4/translate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
> index 703020fe87..b4b5c822d0 100644
> --- a/target/sh4/translate.c
> +++ b/target/sh4/translate.c
> @@ -2189,7 +2189,7 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
>      }
>  
>      /* If op_src is not a valid register, then op_arg was a constant.  */
> -    if (op_src < 0) {
> +    if (op_src < 0 && !TCGV_IS_UNUSED(op_arg)) {
>          tcg_temp_free_i32(op_arg);
>      }
>  
>
Aurelien Jarno Dec. 6, 2017, 10:33 p.m. UTC | #6
On 2017-12-06 09:30, Alex Bennée wrote:
> This fixes bug #1735384 while running java under qemu-sh4. When debug
> was enabled it showed a problem with TCG temps. Once fixed I was able
> to run java -version normally.
> 
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  target/sh4/translate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
> index 703020fe87..b4b5c822d0 100644
> --- a/target/sh4/translate.c
> +++ b/target/sh4/translate.c
> @@ -2189,7 +2189,7 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
>      }
>  
>      /* If op_src is not a valid register, then op_arg was a constant.  */
> -    if (op_src < 0) {
> +    if (op_src < 0 && !TCGV_IS_UNUSED(op_arg)) {
>          tcg_temp_free_i32(op_arg);
>      }

I guess this happens when trying to match the exchange pattern, so this
looks correct to me.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox series

Patch

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 703020fe87..b4b5c822d0 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -2189,7 +2189,7 @@  static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
     }
 
     /* If op_src is not a valid register, then op_arg was a constant.  */
-    if (op_src < 0) {
+    if (op_src < 0 && !TCGV_IS_UNUSED(op_arg)) {
         tcg_temp_free_i32(op_arg);
     }