public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949
@ 2021-05-29  6:02 Indu Bhagat
  2021-05-30  2:04 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Indu Bhagat @ 2021-05-29  6:02 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch fixes the failing pch testcases as observed in PR testsuite/100749.
Although the PR mentions powerpc64, the issue exists on other arches but
appears to be latent.

The issue causing the failure was that the underlying char[] df_set_names is a
static var. Multiple calls to 'debug_set_names' with different write_symbols
like the in c-family/c-pch.c must entail the use of xstrdup or such to retain a
reliable copy of the debug format str containing the names.

Bootstrapped, regression tested on x86_64, powepc64 (make check-gcc).

Thanks,
Indu

----
PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949

Fix failing pch testcases. Use xstrdup to retain a reliable copy of the debug
format str containing the names (df_set_names is a static string var).	    

2021-05-28  Indu Bhagat    <indu.bhagat@oracle.com>

gcc/c-family/ChangeLog:

	* c-pch.c (c_common_valid_pch): Use xstrdup for debug format set names.
---
 gcc/c-family/c-pch.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
index 8f0f760..5da6042 100644
--- a/gcc/c-family/c-pch.c
+++ b/gcc/c-family/c-pch.c
@@ -255,10 +255,13 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
   if (v.pch_write_symbols != write_symbols
       && write_symbols != NO_DEBUG)
     {
+      char *created_str = xstrdup (debug_set_names (v.pch_write_symbols));
+      char *used_str = xstrdup (debug_set_names (write_symbols));
       cpp_warning (pfile, CPP_W_INVALID_PCH,
 		   "%s: created with '%s' debug info, but used with '%s'", name,
-		   debug_set_names (v.pch_write_symbols),
-		   debug_set_names (write_symbols));
+		   created_str, used_str);
+      free (created_str);
+      free (used_str);
       return 2;
     }
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949
  2021-05-29  6:02 [PATCH] PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949 Indu Bhagat
@ 2021-05-30  2:04 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-05-30  2:04 UTC (permalink / raw)
  To: Indu Bhagat, gcc-patches



On 5/29/2021 12:02 AM, Indu Bhagat via Gcc-patches wrote:
> Hi,
>
> This patch fixes the failing pch testcases as observed in PR testsuite/100749.
> Although the PR mentions powerpc64, the issue exists on other arches but
> appears to be latent.
>
> The issue causing the failure was that the underlying char[] df_set_names is a
> static var. Multiple calls to 'debug_set_names' with different write_symbols
> like the in c-family/c-pch.c must entail the use of xstrdup or such to retain a
> reliable copy of the debug format str containing the names.
>
> Bootstrapped, regression tested on x86_64, powepc64 (make check-gcc).
>
> Thanks,
> Indu
>
> ----
> PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949
>
> Fix failing pch testcases. Use xstrdup to retain a reliable copy of the debug
> format str containing the names (df_set_names is a static string var).	
>
> 2021-05-28  Indu Bhagat    <indu.bhagat@oracle.com>
>
> gcc/c-family/ChangeLog:
>
> 	* c-pch.c (c_common_valid_pch): Use xstrdup for debug format set names.
OK for the trunk.  Thanks,
Jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-30  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-29  6:02 [PATCH] PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949 Indu Bhagat
2021-05-30  2:04 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).