[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU poke 2.0.92 with ubsan
From: |
Jose E. Marchesi |
Subject: |
Re: GNU poke 2.0.92 with ubsan |
Date: |
Mon, 07 Feb 2022 12:53:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Bruno.
Thanks for the analysis and solution.
The patch is OK for both master and maint/poke-2.
>>From 2149d470a32bcb79f5eadba8dfdaa5e1b676096e Mon Sep 17 00:00:00 2001
> From: Bruno Haible <bruno@clisp.org>
> Date: Mon, 7 Feb 2022 02:42:34 +0100
> Subject: [PATCH] Avoid undefined behaviour on signed integer.
>
> * libpoke/pvm-val.h (PVM_MAKE_INT): Cast to unsigned integer before
> shifting.
> ---
> ChangeLog | 6 ++++++
> libpoke/pvm-val.h | 6 +++---
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 57ac491b..b934f6ac 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2022-02-06 Bruno Haible <bruno@clisp.org>
> +
> + Avoid undefined behaviour on signed integer.
> + * libpoke/pvm-val.h (PVM_MAKE_INT): Cast to unsigned integer before
> + shifting.
> +
> 2022-02-06 Jose E. Marchesi <jemarch@gnu.org>
>
> * configure.ac: Bump version to 2.0.92.
> diff --git a/libpoke/pvm-val.h b/libpoke/pvm-val.h
> index 9489bf4a..6dc5e884 100644
> --- a/libpoke/pvm-val.h
> +++ b/libpoke/pvm-val.h
> @@ -63,9 +63,9 @@
> #define PVM_VAL_INT(V) (((int32_t) ((V) >> 32)) \
> << (32 - PVM_VAL_INT_SIZE ((V))) \
> >> (32 - PVM_VAL_INT_SIZE ((V))))
> -#define PVM_MAKE_INT(V,S) \
> - (((((int64_t) (V)) & 0xffffffff) << 32) \
> - | ((((S) - 1) & 0x1f) << 3) \
> +#define PVM_MAKE_INT(V,S) \
> + (((((uint64_t) (int64_t) (V)) & 0xffffffff) << 32) \
> + | ((((S) - 1) & 0x1f) << 3) \
> | PVM_VAL_TAG_INT)
>
> #define PVM_VAL_UINT_SIZE(V) (((int) (((V) >> 3) & 0x1f)) + 1)
- Re: GNU poke 2.0.92 on sparc, (continued)
- Re: GNU poke 2.0.92 on sparc, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 invokes undefined behaviour on signed integers, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 on arm, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 on mips, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 on x86_64-{32,x32}, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 on alpha, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 with ubsan, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 with ubsan, Mohammad-Reza Nabipoor, 2022/02/06
- Re: GNU poke 2.0.92 with ubsan, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 with ubsan, Bruno Haible, 2022/02/06
- Re: GNU poke 2.0.92 with ubsan,
Jose E. Marchesi <=
- Signed overflow Was: Re: GNU poke 2.0.92 with ubsan, Jose E. Marchesi, 2022/02/07
- Re: Signed overflow Was: Re: GNU poke 2.0.92 with ubsan, Bruno Haible, 2022/02/07
- Re: Signed overflow Was: Re: GNU poke 2.0.92 with ubsan, Jose E. Marchesi, 2022/02/07
Re: GNU poke 2.0.92 on s390x, Bruno Haible, 2022/02/06
Re: GNU poke 2.0.92 on riscv64, Bruno Haible, 2022/02/06