This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/87787] [9 Regression][UBSAN] runtime error: null pointer passed as argument 2, which is declared to never be null


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]