Bug 67497 - data.c sanitizer runtime error: null pointer passed as argument 2, which is declared to never be null
Summary: data.c sanitizer runtime error: null pointer passed as argument 2, which is d...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.2.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 33056
  Show dependency treegraph
 
Reported: 2015-09-08 14:50 UTC by Vittorio Zecca
Modified: 2017-03-18 16:59 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2015-09-08 14:50:52 UTC
!gcc-5.2.0/gcc/fortran/data.c:181:32: runtime error: null pointer passed as argument 2, which is declared to never be null
! source line "memcpy (&dest[start], rvalue->value.character.string, len * sizeof (gfc_char_t));"
! double check with "gcc_assert(rvalue->value.character.string)" immediately before
! esay fix "if(len) memcpy (&dest[start], rvalue->value.character.string, len *
! sizeof (gfc_char_t));"
!Target: x86_64-unknown-linux-gnu
      CHARACTER, POINTER :: PTR
      DATA  PTR / NULL() /
      end
Comment 1 Dominique d'Humieres 2015-11-05 10:57:40 UTC
Can you please check that it has not been fixed by r229153 for pr67939 (trunk 6.0) and r229555 (5.2.1)?
Comment 2 Vittorio Zecca 2015-11-05 11:58:17 UTC
Traveling now, I cannot check it.
Comment 3 Vittorio Zecca 2016-04-28 09:02:52 UTC
Still in gfortran 5.3.0

/home/vitti/gcc-5.3.0/gcc/fortran/data.c:191:32: runtime error: null
pointer passed as argument 2, which is declared to never be null

data.c:191 "memcpy (&dest[start], rvalue->value.character.string,
            len * sizeof (gfc_char_t));"

Maybe len==0
Comment 4 Vittorio Zecca 2016-04-29 19:26:00 UTC
And in 6.1.0 

../../gcc-6.1.0/gcc/fortran/data.c:191:32: runtime error: null pointer passed as argument 2, which is declared to never be null
Comment 5 Vittorio Zecca 2016-05-12 17:20:44 UTC
Still in trunk:

../../gcc7/gcc/fortran/data.c:191:32: runtime error: null pointer passed as argument 2, which is declared to never be null

here:

memcpy (&dest[start], rvalue->value.character.string, len * sizeof (gfc_char_t));

Probably len==0 and preponing an if(len) should do the trick
Comment 6 Dominique d'Humieres 2017-02-23 14:09:02 UTC
I cannot reproduce this PR even with an instrumented compiler. How do you get the error?
Comment 7 Vittorio Zecca 2017-02-23 15:16:06 UTC
Traveling now, back home end of March.
Did you check the value of variable "len" maybe it's zero so it's not
really a bug.
Comment 8 Vittorio Zecca 2017-03-18 16:56:18 UTC
Just back from my travel.
The sanitizer error message disappeared on trunk level 246252.