[PATCH v2] gdb: Fixed type in value.c

Andrew Burgess andrew.burgess@embecosm.com
Wed Aug 5 11:25:03 GMT 2020


* Lukas Durfina <ldurfina@tachyum.com> [2020-08-05 12:51:36 +0200]:

> Type's length is ULONGEST. It fixes an issue with fortran arrays.
> Instead of crash with the message:
> internal-error: virtual memory exhausted: can't allocate 240518168752 bytes.
> There is correct error message in backtrace:
> str=<error reading variable: value requires 240518168752 bytes, which is more than max-value-size>
> 
> gdb/ChangeLog:
> 
>         * value.c (check_type_length_before_alloc): Fixed type.

LGTM.

Thanks for fixing this.

Andrew


> ---
>  gdb/ChangeLog |  4 ++++
>  gdb/value.c   | 10 +++++-----
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 2cd89b73b7d..0855255e536 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-08-05  Lukas Durfina  <ldurfina@tachyum.com>
> +
> +	* value.c (check_type_length_before_alloc): Fixed type.
> +
>  2020-08-04  Simon Marchi  <simon.marchi@efficios.com>
>  
>  	* frame.h (frame_id_p): Return bool.
> diff --git a/gdb/value.c b/gdb/value.c
> index aac9baaaf56..a6e21309f85 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -997,16 +997,16 @@ show_max_value_size (struct ui_file *file, int from_tty,
>  static void
>  check_type_length_before_alloc (const struct type *type)
>  {
> -  unsigned int length = TYPE_LENGTH (type);
> +  ULONGEST length = TYPE_LENGTH (type);
>  
>    if (max_value_size > -1 && length > max_value_size)
>      {
>        if (type->name () != NULL)
> -	error (_("value of type `%s' requires %u bytes, which is more "
> -		 "than max-value-size"), type->name (), length);
> +	error (_("value of type `%s' requires %s bytes, which is more "
> +		 "than max-value-size"), type->name (), pulongest (length));
>        else
> -	error (_("value requires %u bytes, which is more than "
> -		 "max-value-size"), length);
> +	error (_("value requires %s bytes, which is more than "
> +		 "max-value-size"), pulongest (length));
>      }
>  }
>  
> -- 
> 2.17.1
> 


More information about the Gdb-patches mailing list