Opened 8 years ago

Closed 7 years ago

#10947 closed Bugs (invalid)

serialization singleton & sanitizer : null reference

Reported by: vincent.dabir@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.56.0 Severity: Problem
Keywords: singleton sanitizer null reference Cc:

Description

Hi all,

I ran clang (3.5.1) sanitizer on my program and got the following error:

boost/1_56_0/gcc-4.8.2/include/boost/serialization/singleton.hpp:132:13: runtime error: reference binding to null pointer of type 'const Foo'

the program is :

#include<boost/serialization/singleton.hpp> 
#include <string> 
#include <iostream> 
class Foo{ 
private: 
  std::string bar = "Hello World"; 
public: 
  void print() const{ 
    std::cout << bar << std::endl; 
  } 
}; 

int main(){ 
  boost::serialization::singleton<Foo> test; 
  test.get_const_instance().print(); 
} 

http://stackoverflow.com/questions/28063066/boost-serialization-singleton-and-sanitizer-null-reference

Change History (1)

comment:1 by Robert Ramey, 7 years ago

Resolution: invalid
Status: newclosed

I wasn't able to get the (address?) sanitizer working in my Xcode 6 environment. But I did trace through the program with the debugger. line 132 of singleton.hpp contains the line

use(instance);

where the value of instance has the (initialized value of zero). This might be considered an error by the sanitizer, but use(...) is an empty function. It is only included to guarantee that the singleton is called before main. If this isn't included, compile for release may optimize away the pre-main invocation and the class may not function as intended. So I would call this an over zealous behavior of the sanitizer. Or maybe the sanitizer could be considered not smart enough to trace one more level deep. or... what ever.

Note: See TracTickets for help on using tickets.