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 sanitizer/60963] New: ubsan runtime error: load of null pointer of type '<unknown> *'


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60963

            Bug ID: 60963
           Summary: ubsan runtime error: load of null pointer of type
                    '<unknown> *'
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

I think this is valid:

#include <new>

class EmbeddedObject {
public:
  virtual int val() { return 2; }
};

class Container {
  alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)];
public:
  EmbeddedObject *obj() { return (EmbeddedObject*)buffer; }
  Container() { new (buffer) EmbeddedObject(); }
};

Container o;

int main()
{
  return o.obj()->val();
}

But compiled with trunk and -std=c++11 -O2 -fsanitize=undefined it errors:

sa3.cc:19:23: runtime error: load of null pointer of type '<unknown> *'
Segmentation fault (core dumped)

This might not be a ubsan issue, it might be just a side-effect of the
devirtualization problem described at
http://gcc.gnu.org/ml/gcc/2014-04/msg00236.html


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