Bug 24864 - 'struct value *v' pointer not checked in cp-valprint.c (field_is_static)
Summary: 'struct value *v' pointer not checked in cp-valprint.c (field_is_static)
Status: RESOLVED DUPLICATE of bug 20020
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: 8.3.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-30 17:25 UTC by Adrian Harris
Modified: 2019-08-01 12:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Harris 2019-07-30 17:25:24 UTC
This is from the 8.3 source blob, not git.

Line 315 in cp-valprint.c has a try/catch block to catch problems with finding a static elf symbol. However, cp_print_static_field() is called regardless of the outcome and the following call chain never checks that 'v' is non-null.

The proximate fix is trivial: simply move the call into the try part of the block, e.g.:

	      else if (field_is_static (&TYPE_FIELD (type, i)))
		{
		  struct value *v = NULL;

		  TRY
		    {
		      v = value_static_field (type, i);
		      cp_print_static_field (TYPE_FIELD_TYPE (type, i),
					     v, stream, recurse + 1,
					     options);
		    }

		  CATCH (ex, RETURN_MASK_ERROR)
		    {
		      fprintf_filtered (stream,
					_("<error reading variable: %s>"),
					ex.message);
		    }
		  END_CATCH
		}

Now *why* the static symbol is not found is another question altogether, but this is clearly a bug.
Comment 1 Tom Tromey 2019-08-01 12:42:12 UTC
Thanks for the report.  This has already been fixed in git.

*** This bug has been marked as a duplicate of bug 20020 ***