Bug 95456 - [11 Regression] gcc/gcc.c:6035:16: runtime error: null pointer passed as argument 2, which is declared to never be null
Summary: [11 Regression] gcc/gcc.c:6035:16: runtime error: null pointer passed as argu...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Alexandre Oliva
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: patch
Depends on:
Blocks: ubsan
  Show dependency treegraph
 
Reported: 2020-06-01 08:30 UTC by Martin Liška
Modified: 2020-06-06 01:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 10.1.0
Known to fail: 11.0
Last reconfirmed: 2020-06-01 00:00:00


Attachments
patch I'm testing (615 bytes, patch)
2020-06-04 07:40 UTC, Alexandre Oliva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2020-06-01 08:30:26 UTC
Since the Alexander's changes I see:

$ diff --git a/gcc/gcc.c b/gcc/gcc.c
index e2362175f40..44090a8e713 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -6032,8 +6032,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 		    if (dumpdir_length)
 		      memcpy (tmp, dumpdir, dumpdir_length);
 		    if (!outbase_length)
+		      {
+			gcc_assert (input_basename);
 		      memcpy (tmp + dumpdir_length, input_basename,
 			      basename_length);
+		      }
 		    else
 		      memcpy (tmp + dumpdir_length, outbase,
 			      outbase_length);

$ ./xgcc -B. /tmp/foo.c --save-temps
xgcc: internal compiler error: in do_spec_1, at gcc.c:6036
0x403cea do_spec_1
	/home/marxin/Programming/gcc/gcc/gcc.c:6036
0x4130a1 process_brace_body
	/home/marxin/Programming/gcc/gcc/gcc.c:7122
Comment 1 Alexandre Oliva 2020-06-04 07:40:19 UTC
Created attachment 48673 [details]
patch I'm testing

Here's the patch I'm testing
Comment 2 CVS Commits 2020-06-06 01:42:54 UTC
The master branch has been updated by Alexandre Oliva <aoliva@gcc.gnu.org>:

https://gcc.gnu.org/g:2e6a6644db0ef0f369df4e5b1b337122d84c1a39

commit r11-1014-g2e6a6644db0ef0f369df4e5b1b337122d84c1a39
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri Jun 5 22:31:19 2020 -0300

    [PR95456] avoid memcpy (_, NULL, 0) in gcc.c
    
    Some newly-added code in gcc.c might call memcpy with a NULL source
    pointer and zero-length inputs.  Avoid such calls by rearranging the
    code a little.
    
    
    for  gcc/ChangeLog
    
            PR driver/95456
            * gcc.c (do_spec_1): Don't call memcpy (_, NULL, 0).
Comment 3 Alexandre Oliva 2020-06-06 01:54:17 UTC
fixed