Project

General

Profile

Bug #12261

WireGeo has no default constructor

Added by Lynn Garren over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
04/12/2016
Due date:
% Done:

100%

Estimated time:
Spent time:
Occurs In:
Experiment:
-
Co-Assignees:
Duration:

Description

While using valgrind to help identify a segfault, we found the following:

==21893==  Uninitialised value was created by a stack allocation
==21893==    at 0x2069D546: geo::WireGeo::WireGeo(std::vector<TGeoNode const*, std::allocator<TGeoNode const*> >&, int) (WireGeo.cxx:42)

Checking the code confirms that larcore/Geometry/WireGeo.h has no defaultconstructor. Please fix this problem.


Related issues

Related to art - Bug #12247: segfault on missing wrapper of Assns partner typeClosed04/11/2016

History

#1 Updated by Gianluca Petrillo over 4 years ago

We need more information to properly solve the issue. Which geometry are you running on? is it SLF or OSX?

I am puzzled.
I can't find any instance of a standard container to geo::WireGeo in either LArSoft, MicroBooNE or DUNE code.
memcheck reports about "stack allocation", that I expect the compiler to prevent because of the lack of constructor. And I can't find any C-style array of WireGeo either.

geo::WireGeo exposes a completely constant interface and it is designed to be fully initialized on construction.
A "default" constructor would produce a permanently invalid object and it is deliberatly not implemented (we should = delete it to be more explicit).

On top of that, at least std::vector does not require default constructability (although that is required when using resize()). But then, the compiler chimes in.

#2 Updated by Lynn Garren over 4 years ago

We found this on SLF6. Please see larcore/Geometry/PlaneGeo.h and larcore/Geometry/GeoObjectSorterStandard.*

#3 Updated by Lynn Garren over 4 years ago

  • Related to Bug #12247: segfault on missing wrapper of Assns partner type added

#4 Updated by Lynn Garren about 4 years ago

  • Status changed from New to Resolved
  • Assignee set to Lynn Garren

The following change is committed to develop and causes no problems with either the build or the unit tests.

diff --git a/larcore/Geometry/WireGeo.h b/larcore/Geometry/WireGeo.h
index 5b15d6f..1e1e0c5 100644
--- a/larcore/Geometry/WireGeo.h
+++ b/larcore/Geometry/WireGeo.h
@@ -35,6 +35,7 @@ namespace geo {
   class WireGeo {
   public:
     WireGeo(std::vector<const TGeoNode*>& path, int depth);
+    WireGeo() = delete;   // disallow default constructor

     void   GetCenter(double* xyz, double localz=0.0) const;
     void   GetStart(double* xyz) const { GetCenter(xyz, -fHalfL); }

#5 Updated by Lynn Garren about 4 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100


Also available in: Atom PDF