[v2] gdb: Fixed type in value.c

Message ID 20200805105136.81345-1-ldurfina@tachyum.com
State New
Headers show
Series
  • [v2] gdb: Fixed type in value.c
Related show

Commit Message

Lukas Durfina Aug. 5, 2020, 10:51 a.m.
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.
---
 gdb/ChangeLog |  4 ++++
 gdb/value.c   | 10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.17.1

Comments

Andrew Burgess Aug. 5, 2020, 11:25 a.m. | #1
* 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

>

Patch

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));
     }
 }