This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/87787] [9 Regression][UBSAN] runtime error: null pointer passed as argument 2, which is declared to never be null
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 09 Nov 2018 16:35:41 +0000
- Subject: [Bug libstdc++/87787] [9 Regression][UBSAN] runtime error: null pointer passed as argument 2, which is declared to never be null
- Auto-submitted: auto-generated
- References: <bug-87787-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87787
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
Summary|[9 Regression] runtime |[9 Regression][UBSAN]
|error: null pointer passed |runtime error: null pointer
|as argument 2, which is |passed as argument 2, which
|declared to never be null |is declared to never be
| |null
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #2)
> (In reply to Marc Glisse from comment #1)
> > That would be my recent commit. We will probably need to add if(size!=0) in
> > front of the call to memmove...
>
> That's what we already do in stl_algobase.h and fstream.tcc. I notice that
> we do not do it in char_traits.h for the generic version (we do for each
> specialization). I don't know if memcpy in locale_facets.h is safe either.
As that comment talks about char_traits.h, only, it is not clear whether the
following would be covered by the fix as well or not. In any case, the
following is a simple reproducer:
#include <vector>
int main() {
int *ip = NULL;
std::vector<int*> vec;
vec.push_back(ip);
return 1;
}
With gives with ubsan (-fsanitize=undefined) at run time:
stl_uninitialized.h:907:24: runtime error: null pointer passed as argument 2,
which is declared to never be null