From 96141272a7f5eea964da3f76120a9d29fe2064dd Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 5 Oct 2021 11:59:46 -0400
Subject: [PATCH] GeoModelXml: Enable thread-safety checking.

Enable thread-safety checking and fix warning:

 - Use std::abort() instead of exit().
 - Don't use DataHandle.
 - const cleanup.  A few const_casts were unavoidable due to problems
   with the design of the GeoModel and zlib interfaces.
---
 .../GeoModelXml/CMakeLists.txt                |  2 +-
 .../GeoModelXml/ATLAS_CHECK_THREAD_SAFETY     |  1 +
 .../GeoModelXml/GeoModelXml/Element2GeoItem.h |  8 +++----
 .../GeoModelXml/GeoModelXml/GeoNodeList.h     |  1 +
 .../GeoModelXml/GeoModelXml/MakeElement.h     |  4 ++--
 .../GeoModelXml/GeoModelXml/MakeMaterial.h    |  4 ++--
 .../GeoModelXml/MakeTransformation.h          |  4 ++--
 .../GeoModelXml/MakeTransformationref.h       |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeBox.h   |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeCons.h  |  4 ++--
 .../GeoModelXml/shape/MakeGenericTrap.h       |  4 ++--
 .../GeoModelXml/shape/MakeIntersection.h      |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakePara.h  |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakePcon.h  |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakePgon.h  |  4 ++--
 .../GeoModelXml/shape/MakeShaperef.h          |  2 +-
 .../GeoModelXml/shape/MakeSimplePolygonBrep.h |  4 ++--
 .../GeoModelXml/shape/MakeSubtraction.h       |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeTrap.h  |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeTrd.h   |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeTube.h  |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeTubs.h  |  4 ++--
 .../GeoModelXml/GeoModelXml/shape/MakeUnion.h |  4 ++--
 .../GeoModelXml/src/AssemblyrefProcessor.cxx  |  2 +-
 .../GeoModelXml/src/Element2GeoItem.cxx       | 12 +++++-----
 .../GeoModelXml/src/Gmx2Geo.cxx               |  4 ++--
 .../GeoModelXml/src/GmxInterface.cxx          |  5 ++--
 .../GeoModelXml/src/GmxUtil.cxx               |  6 ++---
 .../GeoModelXml/src/LogvolProcessor.cxx       |  8 +++----
 .../GeoModelXml/src/LogvolrefProcessor.cxx    |  4 ++--
 .../GeoModelXml/src/MakeBox.cxx               |  4 ++--
 .../GeoModelXml/src/MakeCons.cxx              |  4 ++--
 .../GeoModelXml/src/MakeElement.cxx           |  6 ++---
 .../GeoModelXml/src/MakeGenericTrap.cxx       |  4 ++--
 .../GeoModelXml/src/MakeIntersection.cxx      | 24 +++++++++++--------
 .../GeoModelXml/src/MakeMaterial.cxx          | 22 ++++++++---------
 .../GeoModelXml/src/MakePara.cxx              |  4 ++--
 .../GeoModelXml/src/MakePcon.cxx              |  4 ++--
 .../GeoModelXml/src/MakePgon.cxx              |  4 ++--
 .../GeoModelXml/src/MakeShaperef.cxx          |  4 ++--
 .../GeoModelXml/src/MakeSimplePolygonBrep.cxx |  4 ++--
 .../GeoModelXml/src/MakeSubtraction.cxx       | 24 +++++++++++--------
 .../GeoModelXml/src/MakeTransformation.cxx    |  6 ++---
 .../GeoModelXml/src/MakeTransformationref.cxx |  4 ++--
 .../GeoModelXml/src/MakeTrap.cxx              |  4 ++--
 .../GeoModelXml/src/MakeTrd.cxx               |  4 ++--
 .../GeoModelXml/src/MakeTube.cxx              |  4 ++--
 .../GeoModelXml/src/MakeTubs.cxx              |  4 ++--
 .../GeoModelXml/src/MakeUnion.cxx             | 24 +++++++++++--------
 .../GeoModelXml/src/MulticopyProcessor.cxx    | 14 +++++------
 .../GeoModelXml/src/PositionIndex.cxx         |  4 ++--
 .../GeoModelXml/src/TransformProcessor.cxx    |  4 ++--
 .../GeoModelXml/src/TransformrefProcessor.cxx |  4 ++--
 .../GeoModelXml/src/decompress.cxx            |  6 +++--
 54 files changed, 167 insertions(+), 150 deletions(-)
 create mode 100644 DetectorDescription/GeoModelXml/GeoModelXml/ATLAS_CHECK_THREAD_SAFETY

diff --git a/DetectorDescription/GeoModelXml/CMakeLists.txt b/DetectorDescription/GeoModelXml/CMakeLists.txt
index 3b3442c57f7..99d617549f7 100644
--- a/DetectorDescription/GeoModelXml/CMakeLists.txt
+++ b/DetectorDescription/GeoModelXml/CMakeLists.txt
@@ -18,6 +18,6 @@ atlas_add_library( GeoModelXml
    PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}
    LINK_LIBRARIES ${XERCESC_LIBRARIES} ${EIGEN_LIBRARIES} ${GEOMODEL_LIBRARIES}
    PRIVATE_LINK_LIBRARIES ${ZLIB_LIBRARIES} GaudiKernel GeoModelInterfaces
-                          StoreGateLib )
+                          StoreGateLib CxxUtils )
 
 atlas_install_runtime( data/*.dtd )
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/ATLAS_CHECK_THREAD_SAFETY b/DetectorDescription/GeoModelXml/GeoModelXml/ATLAS_CHECK_THREAD_SAFETY
new file mode 100644
index 00000000000..59435562d71
--- /dev/null
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/ATLAS_CHECK_THREAD_SAFETY
@@ -0,0 +1 @@
+DetectorDescription/GeoModelXml
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/Element2GeoItem.h b/DetectorDescription/GeoModelXml/GeoModelXml/Element2GeoItem.h
index aa892ce4379..c22a6cbcbc8 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/Element2GeoItem.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/Element2GeoItem.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -28,9 +28,9 @@ class Element2GeoItem {
 public:
     Element2GeoItem();
     virtual ~Element2GeoItem();
-    const RCBase * process(const xercesc::DOMElement *element, GmxUtil &gmxUtil);
-    virtual const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    RCBase * process(const xercesc::DOMElement *element, GmxUtil &gmxUtil);
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
 protected:
-    std::map<std::string, const RCBase *> m_map;  
+    std::map<std::string, RCBase *> m_map;  
 };
 #endif // ELEMENT2GEO_ITEM_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/GeoNodeList.h b/DetectorDescription/GeoModelXml/GeoModelXml/GeoNodeList.h
index eac3c942d3b..2b4fb074d80 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/GeoNodeList.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/GeoNodeList.h
@@ -6,3 +6,4 @@
 #include "GeoModelKernel/GeoGraphNode.h"
 
 typedef std::vector<GeoGraphNode *> GeoNodeList;
+typedef std::vector<const GeoGraphNode *> GeoConstNodeList;
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/MakeElement.h b/DetectorDescription/GeoModelXml/GeoModelXml/MakeElement.h
index f1494499f1a..ac31a7bb064 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/MakeElement.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/MakeElement.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -14,7 +14,7 @@
 class MakeElement: public Element2GeoItem {
 public:
     MakeElement();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // MAKE_ELEMENT_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/MakeMaterial.h b/DetectorDescription/GeoModelXml/GeoModelXml/MakeMaterial.h
index 8d95e862226..e2219f27fd6 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/MakeMaterial.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/MakeMaterial.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -14,7 +14,7 @@
 class MakeMaterial: public Element2GeoItem {
 public:
     MakeMaterial();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // MAKE_MATERIAL_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformation.h b/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformation.h
index c80e05c88c8..0cf6b79f001 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformation.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformation.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -14,7 +14,7 @@
 class MakeTransformation: public Element2GeoItem {
 public:
     MakeTransformation();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // MAKE_TRANSFORMATION_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformationref.h b/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformationref.h
index 5c345f73663..caca40cb2cb 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformationref.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/MakeTransformationref.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -13,7 +13,7 @@
 
 class MakeTransformationref: public Element2GeoItem {
 public:
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // MAKE_TRANSFORMATIONREF_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeBox.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeBox.h
index 599abebcec3..968bc48068b 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeBox.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeBox.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeBox: public Element2GeoItem {
 public:
     MakeBox();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_BOX_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeCons.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeCons.h
index 9283cfc20a0..7de87d2d0a0 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeCons.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeCons.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeCons: public Element2GeoItem {
 public:
     MakeCons();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_CONS_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeGenericTrap.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeGenericTrap.h
index 0eed6fe1193..83b011534ea 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeGenericTrap.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeGenericTrap.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeGenericTrap: public Element2GeoItem {
 public:
     MakeGenericTrap();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_GENERICTRAP_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeIntersection.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeIntersection.h
index 483a11e51fe..c8d7b71d9ac 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeIntersection.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeIntersection.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeIntersection: public Element2GeoItem {
 public:
     MakeIntersection();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_INTERSECTION_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePara.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePara.h
index b354c986541..c340ca70593 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePara.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePara.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakePara: public Element2GeoItem {
 public:
     MakePara();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_PARA_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePcon.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePcon.h
index aab86ab5336..190badf08e3 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePcon.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePcon.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakePcon: public Element2GeoItem {
 public:
     MakePcon();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_PCON_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePgon.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePgon.h
index df9fded68e5..cc48599aa88 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePgon.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakePgon.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakePgon: public Element2GeoItem {
 public:
     MakePgon();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_PGON_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeShaperef.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeShaperef.h
index 905e5fe2c13..5c218c35c8c 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeShaperef.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeShaperef.h
@@ -15,7 +15,7 @@
 class MakeShaperef: public Element2GeoItem {
 public:
 //    MakeShaperef() {};
-    const RCBase * process(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    RCBase * process(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
 };
 
 #endif // GEO_MODEL_XML_MAKE_SHAPEREF_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSimplePolygonBrep.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSimplePolygonBrep.h
index 5ec995fb3fb..92382bef948 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSimplePolygonBrep.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSimplePolygonBrep.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 #include <xercesc/util/XercesDefs.hpp>
 //
@@ -14,7 +14,7 @@
 class MakeSimplePolygonBrep: public Element2GeoItem {
 public:
     MakeSimplePolygonBrep();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_SIMPLEPOLYGONBREP_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSubtraction.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSubtraction.h
index 5dcd328651f..359b43037de 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSubtraction.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeSubtraction.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeSubtraction: public Element2GeoItem {
 public:
     MakeSubtraction();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_SUBTRACTION_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrap.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrap.h
index 3e8794c8c2e..2832814597c 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrap.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrap.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeTrap: public Element2GeoItem {
 public:
     MakeTrap();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_TRAP_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrd.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrd.h
index 85ec542afa1..ae05777cdd8 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrd.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTrd.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeTrd: public Element2GeoItem {
 public:
     MakeTrd();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_TRD_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTube.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTube.h
index 8c6f45debeb..bdf81d3c207 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTube.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTube.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeTube: public Element2GeoItem {
 public:
     MakeTube();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_TUBE_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTubs.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTubs.h
index c414908e5ba..a75b172635a 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTubs.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeTubs.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeTubs: public Element2GeoItem {
 public:
     MakeTubs();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_TUBS_H
diff --git a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeUnion.h b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeUnion.h
index e1a762fda56..cb5f32fc1ea 100644
--- a/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeUnion.h
+++ b/DetectorDescription/GeoModelXml/GeoModelXml/shape/MakeUnion.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -15,7 +15,7 @@
 class MakeUnion: public Element2GeoItem {
 public:
     MakeUnion();
-    const RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const;
+    virtual RCBase * make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const override;
 };
 
 #endif // GEO_MODEL_XML_MAKE_UNION_H
diff --git a/DetectorDescription/GeoModelXml/src/AssemblyrefProcessor.cxx b/DetectorDescription/GeoModelXml/src/AssemblyrefProcessor.cxx
index 185a6b2e7ad..58f2b40b1c0 100644
--- a/DetectorDescription/GeoModelXml/src/AssemblyrefProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/AssemblyrefProcessor.cxx
@@ -39,7 +39,7 @@ char *toRelease;
         OUTPUT_STREAM;
         msglog << MSG::FATAL << "Error in xml/gmx file: assemblyref " << XMLString::transcode(idref) << " referenced a " << 
                               nodeName << " instead of an assembly.\n";
-        exit(999); // Should do better...
+        std::abort();
     }
 //
 //    Process it
diff --git a/DetectorDescription/GeoModelXml/src/Element2GeoItem.cxx b/DetectorDescription/GeoModelXml/src/Element2GeoItem.cxx
index a780a0d7432..9634eb1e345 100644
--- a/DetectorDescription/GeoModelXml/src/Element2GeoItem.cxx
+++ b/DetectorDescription/GeoModelXml/src/Element2GeoItem.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 #include <string>
 
@@ -20,7 +20,7 @@ Element2GeoItem::Element2GeoItem() {}
 
 Element2GeoItem::~Element2GeoItem() {}
 
-const RCBase * Element2GeoItem::process(const xercesc::DOMElement *element, GmxUtil &gmxUtil) {
+RCBase * Element2GeoItem::process(const xercesc::DOMElement *element, GmxUtil &gmxUtil) {
 
     char *name2release;
     XMLCh * name_tmp = XMLString::transcode("name");
@@ -30,8 +30,8 @@ const RCBase * Element2GeoItem::process(const xercesc::DOMElement *element, GmxU
     XMLString::release(&name2release);
     XMLString::release(&name_tmp);
 
-    const RCBase *item;
-    map<string, const RCBase *>::iterator entry;
+    RCBase *item;
+    map<string, RCBase *>::iterator entry;
     if (name == "") { // Unnamed item; cannot store in the map; make a new one 
         item = make(element, gmxUtil);
     }
@@ -46,11 +46,11 @@ const RCBase * Element2GeoItem::process(const xercesc::DOMElement *element, GmxU
     return item;
 }
 
-const RCBase * Element2GeoItem::make(const xercesc::DOMElement *element, GmxUtil & /* gmxUtil */) const {
+RCBase * Element2GeoItem::make(const xercesc::DOMElement *element, GmxUtil & /* gmxUtil */) const {
     char *name2release = XMLString::transcode(element->getNodeName());
     OUTPUT_STREAM;
     msglog << MSG::FATAL << "Oh oh: called base class make() method of Element2GeoType object; tag " << name2release << endmsg;
     XMLString::release(&name2release);
 
-    exit(999); // Should improve on this 
+    std::abort();
 }
diff --git a/DetectorDescription/GeoModelXml/src/Gmx2Geo.cxx b/DetectorDescription/GeoModelXml/src/Gmx2Geo.cxx
index 51f9a015d8b..310ceb92148 100644
--- a/DetectorDescription/GeoModelXml/src/Gmx2Geo.cxx
+++ b/DetectorDescription/GeoModelXml/src/Gmx2Geo.cxx
@@ -43,7 +43,7 @@ Gmx2Geo::Gmx2Geo(const string xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInt
     if (!doc) {// Parsed badly
         XMLPlatformUtils::Terminate();
         msglog << MSG::FATAL << "Error in xml file " << xmlFile << ". Exiting athena." << endmsg;
-        exit(0);
+        std::abort();
     }
 //
 //    Set up the CLHEP evaluator and the xml-tag processors, and store the GmxInterface:
@@ -208,7 +208,7 @@ const DOMElement *element;
                 msglog << val << endl;
                 msglog << string(eval.error_position(), '-') << '^' << '\n';
                 msglog << "Exiting program." << endmsg;
-                exit(999); // Should do better...
+                std::abort();
             }
             eval.setVariable(name, evaluated);
             msglog << name << "\t\t" << val << " = " << setprecision(10) << evaluated << endl;
diff --git a/DetectorDescription/GeoModelXml/src/GmxInterface.cxx b/DetectorDescription/GeoModelXml/src/GmxInterface.cxx
index bd3d222c999..464e59d8fd2 100644
--- a/DetectorDescription/GeoModelXml/src/GmxInterface.cxx
+++ b/DetectorDescription/GeoModelXml/src/GmxInterface.cxx
@@ -13,15 +13,16 @@
 #include "GeoModelKernel/Query.h"
 #include "GeoModelKernel/GeoPhysVol.h"
 #include "GeoModelKernel/GeoVFullPhysVol.h"
+#include <atomic>
 using namespace std;
 
 int GmxInterface::sensorId(map<string, int> &/*index*/) const {
-    static int sequentialId;
+    static std::atomic<int> sequentialId;
     return sequentialId++;
 }
 
 int GmxInterface::splitSensorId(map<string, int> &/*index*/, std::pair<std::string, int> &/*extraIndex*/, map<string, int> &/*updatedIndex*/) const {
-    static int sequentialId;
+    static std::atomic<int> sequentialId;
     return sequentialId++;
 }
 
diff --git a/DetectorDescription/GeoModelXml/src/GmxUtil.cxx b/DetectorDescription/GeoModelXml/src/GmxUtil.cxx
index b1722a4b60a..1c1a34644a5 100644
--- a/DetectorDescription/GeoModelXml/src/GmxUtil.cxx
+++ b/DetectorDescription/GeoModelXml/src/GmxUtil.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "GeoModelXml/GmxUtil.h"
@@ -78,7 +78,7 @@ GmxInterface * GmxUtil::gmxInterface() {
 }
 
 double GmxUtil::evaluate(char const *expression) {
-    static string lastGoodExpression("none"); // It is helpful for debugging to get some idea of where we had got to...
+    static thread_local string lastGoodExpression("none"); // It is helpful for debugging to get some idea of where we had got to...
     string strExpression(expression);
 
     bool isWhiteSpace = true;
@@ -161,7 +161,7 @@ GeoLogVol * GmxUtil::makeAssemblyLV() {
             msglog << MSG::ERROR << "GmxUtil::makeAssemblyLV: Unable to access Detector Store" << endmsg;
     }
     else {
-        DataHandle<StoredMaterialManager> theMaterialManager;
+        StoredMaterialManager* theMaterialManager = nullptr;
         sc = pDetStore->retrieve(theMaterialManager, "MATERIALS");
         if(sc.isFailure()) {
                 msglog << MSG::ERROR << "GmxUtil::makeAssemblyLV: Unable to access Material Manager" << endmsg;
diff --git a/DetectorDescription/GeoModelXml/src/LogvolProcessor.cxx b/DetectorDescription/GeoModelXml/src/LogvolProcessor.cxx
index 237771bb710..051d3fa5608 100644
--- a/DetectorDescription/GeoModelXml/src/LogvolProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/LogvolProcessor.cxx
@@ -73,7 +73,7 @@ GeoNameTag *physVolName;
                     ". Error in gmx file. An IDREF for a logvol shape did not refer to a shape.\n" <<
               "Shape ref was " << shape_s << "; exiting" << endmsg;
             XMLString::release (&shape_s);
-            exit (1); // Need to improve...
+            std::abort();
         }
 //
 //    What sort of shape?
@@ -83,7 +83,7 @@ GeoNameTag *physVolName;
         XMLString::release(&name2release);
 	XMLString::release(&shape_tmp);
 
-        GeoShape *s = (GeoShape *) gmxUtil.geoItemRegistry.find(shapeType)->process(refShape, gmxUtil);
+        const GeoShape *s = static_cast<const GeoShape *> (gmxUtil.geoItemRegistry.find(shapeType)->process(refShape, gmxUtil));
 //
 //    Get the material
 //
@@ -99,10 +99,10 @@ GeoNameTag *physVolName;
                     ". Error in gmx file. An IDREF for a logvol material did not refer to a material.\n" <<
                     "Material ref was " << material_s << "; exiting" << endmsg;
            XMLString::release (&material_s);
-           exit (1); // Need to improve...
+           std::abort();
         }
 
-        GeoMaterial *m = (GeoMaterial *) gmxUtil.tagHandler.material.process(refMaterial, gmxUtil);
+        const GeoMaterial *m = static_cast<const GeoMaterial *> (gmxUtil.tagHandler.material.process(refMaterial, gmxUtil));
 
 //
 //    Make the LogVol and add it to the map ready for next time
diff --git a/DetectorDescription/GeoModelXml/src/LogvolrefProcessor.cxx b/DetectorDescription/GeoModelXml/src/LogvolrefProcessor.cxx
index 7269b7ebc91..444bda510d5 100644
--- a/DetectorDescription/GeoModelXml/src/LogvolrefProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/LogvolrefProcessor.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -36,7 +36,7 @@ char *toRelease;
 	OUTPUT_STREAM;
         msglog << MSG::FATAL << "Error in xml/gmx file: logvolref " << XMLString::transcode(idref) << " referenced a " << nodeName << 
                 " instead of a logvol." << endmsg;
-        exit(999); // Should do better...
+        std::abort();
     }
 //
 //    Process it
diff --git a/DetectorDescription/GeoModelXml/src/MakeBox.cxx b/DetectorDescription/GeoModelXml/src/MakeBox.cxx
index 75a1e43c1c2..bd8cf3e8bf4 100644
--- a/DetectorDescription/GeoModelXml/src/MakeBox.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeBox.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeBox::MakeBox() {}
 
-const RCBase * MakeBox::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeBox::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 3; 
 char const *parName[nParams] = {"xhalflength", "yhalflength", "zhalflength"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeCons.cxx b/DetectorDescription/GeoModelXml/src/MakeCons.cxx
index 7acac8dc128..092261f6db5 100644
--- a/DetectorDescription/GeoModelXml/src/MakeCons.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeCons.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeCons::MakeCons() {}
 
-const RCBase * MakeCons::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeCons::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 7; 
 char const *parName[nParams] = {"rmin1", "rmin2", "rmax1", "rmax2", "dz", "sphi", "dphi"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeElement.cxx b/DetectorDescription/GeoModelXml/src/MakeElement.cxx
index f6b6742c876..8de1a7e0201 100644
--- a/DetectorDescription/GeoModelXml/src/MakeElement.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeElement.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "GeoModelXml/MakeElement.h"
@@ -15,7 +15,7 @@ using namespace GeoModelKernelUnits;
 
 MakeElement::MakeElement() {}
 
-const RCBase * MakeElement::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeElement::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
   char *name, *shortname, *z,*a;
   XMLCh *name_tmp,*shortname_tmp,*z_tmp,*a_tmp;
   double zVal, aVal;
@@ -52,5 +52,5 @@ const RCBase * MakeElement::make(const xercesc::DOMElement *element, GmxUtil &gm
   XMLString::release(&name_tmp);
   XMLString::release(&shortname_tmp);
   
-  return (const RCBase *) el;
+  return (RCBase *) el;
 }
diff --git a/DetectorDescription/GeoModelXml/src/MakeGenericTrap.cxx b/DetectorDescription/GeoModelXml/src/MakeGenericTrap.cxx
index df1a86fc8aa..4bf1df75246 100644
--- a/DetectorDescription/GeoModelXml/src/MakeGenericTrap.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeGenericTrap.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // *NOT*!!! Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -18,7 +18,7 @@ using namespace xercesc;
 
 MakeGenericTrap::MakeGenericTrap() {}
 
-const RCBase * MakeGenericTrap::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeGenericTrap::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 17; 
 char const *parName[nParams] = {"x0", "y0", "x1", "y1", "x2", "y2", "x3", "y3", 
                                 "x4", "y4", "x5", "y5", "x6", "y6", "x7", "y7", "zhalflength"};
diff --git a/DetectorDescription/GeoModelXml/src/MakeIntersection.cxx b/DetectorDescription/GeoModelXml/src/MakeIntersection.cxx
index 49ab5599f6d..9c37da870e9 100644
--- a/DetectorDescription/GeoModelXml/src/MakeIntersection.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeIntersection.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -15,39 +15,40 @@
 
 #include "xercesc/util/XMLString.hpp"
 #include "GeoModelXml/GmxUtil.h"
+#include "CxxUtils/checker_macros.h"
 
 using namespace xercesc;
 using namespace std;
 
 MakeIntersection::MakeIntersection() {}
 
-const RCBase * MakeIntersection::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeIntersection::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 // 
 //    Process child elements; first is first shaperef; then transform; then second shaperef.
 //
-    GeoShape *first = 0;
-    GeoShape *second = 0;
+    const GeoShape *first = 0;
+    const GeoShape *second = 0;
     GeoTrf::Transform3D hepXf=GeoTrf::Transform3D::Identity(); 
     int elementIndex = 0;
     for (DOMNode *child = element->getFirstChild(); child != 0; child = child->getNextSibling()) {
         if (child->getNodeType() == DOMNode::ELEMENT_NODE) { // Skips text nodes
             switch (elementIndex) {
                 case 0: { // First element is first shaperef
-                    first = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    first = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 case 1: { // Second element is transformation or transformationref
                     char *toRelease = XMLString::transcode(child->getNodeName());
                     string nodeName(toRelease);
                     XMLString::release(&toRelease);
-                    GeoTransform *geoXf = nodeName == "transformation"? 
-(GeoTransform *) gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil):
-(GeoTransform *) gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil);
+                    const GeoTransform *geoXf = nodeName == "transformation"? 
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil)):
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil));
                     hepXf = geoXf->getTransform();
                     break;
                 }
                 case 2: { // Third element is second shaperef
-                    second = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    second = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 default: // More than 3 elements?
@@ -58,7 +59,10 @@ const RCBase * MakeIntersection::make(const xercesc::DOMElement *element, GmxUti
         }
     }
 
-    const GeoShapeIntersection *temp = &(first->intersect(*(GeoShape *) &(*(second) << hepXf)));
+    // FIXME: intersect() returns a new'd object --- should really be
+    // returning a `unique_ptr<GeoShapeIntersection>' not a
+    // `const GeoShapeIntersection'
+    GeoShapeIntersection *temp ATLAS_THREAD_SAFE = const_cast<GeoShapeIntersection*>(&(first->intersect(*(GeoShape *) &(*(second) << hepXf))));
 
     return (RCBase *) temp;
 }
diff --git a/DetectorDescription/GeoModelXml/src/MakeMaterial.cxx b/DetectorDescription/GeoModelXml/src/MakeMaterial.cxx
index 48235001275..861e18acb4a 100644
--- a/DetectorDescription/GeoModelXml/src/MakeMaterial.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeMaterial.cxx
@@ -18,7 +18,7 @@ using namespace GeoModelKernelUnits;
 
 MakeMaterial::MakeMaterial() {}
 
-const RCBase * MakeMaterial::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeMaterial::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 char *name;
 char *density;
 char *densitySF;
@@ -49,7 +49,7 @@ char *toRelease;
     if (XMLString::compareIString(parent->getNodeName(), materials_tmp) != 0) {
         msglog << MSG::FATAL << "Asked to make a material for non-material element. Parent element was " << 
                              XMLString::transcode(parent->getNodeName()) << "; error in gmx file; exiting" << endmsg;
-        exit(1);
+        std::abort();
     }
     double scaleFactor(1.0);
     DOMElement *el = dynamic_cast<DOMElement *> (parent);
@@ -88,10 +88,10 @@ char *toRelease;
         if (nodeName != string("element")) {
             msglog << MSG::FATAL << "Error in xml/gmx file: An elementref referenced a " << nodeName << " instead of an element." 
                               << endmsg;
-            exit(999); // Should do better...
+            std::abort();
         }
 
-        GeoElement *geoElem = (GeoElement *) gmxUtil.tagHandler.element.process(elem, gmxUtil);
+        const GeoElement *geoElem = static_cast<const GeoElement *> (gmxUtil.tagHandler.element.process(elem, gmxUtil));
 
         fracString = XMLString::transcode(elRef->getAttribute(fraction_tmp));
         fraction = gmxUtil.evaluate(fracString);
@@ -114,7 +114,7 @@ char *toRelease;
         if (nodeName != string("chemical")) {
             msglog << MSG::FATAL << "Error in xml/gmx file: A chemref referenced a " << nodeName << " instead of a chemical." << 
                                   endmsg;
-            exit(999); // Should do better...
+            std::abort();
         }
 
         fracString = XMLString::transcode(chemRef->getAttribute(fraction_tmp));
@@ -124,7 +124,7 @@ char *toRelease;
         // Loop over chemical contents, adding each element to this material
         DOMNodeList *chemEls = chem->getElementsByTagName(elemcontent_tmp);
         int nChemEls = chemEls->getLength();
-        vector<GeoElement *> geoElem;
+        vector<const GeoElement *> geoElem;
         vector<double> atomicWeight;
         double molWeight = 0.0;
         vector<double> formula;
@@ -139,10 +139,10 @@ char *toRelease;
             if (nodeName != string("element")) {
                 msglog << MSG::FATAL << 
                        "Error in xml/gmx file: An elementref referenced a " << nodeName << " instead of an element." << endmsg;
-                exit(999); // Should do better...
+                std::abort();
             }
 
-            geoElem.push_back((GeoElement *) gmxUtil.tagHandler.element.process(elem, gmxUtil));
+            geoElem.push_back(static_cast<const GeoElement *> (gmxUtil.tagHandler.element.process(elem, gmxUtil)));
             atomicWeight.push_back(geoElem.back()->getA());
 
             qString = XMLString::transcode(chemEl->getAttribute(quantity_tmp));
@@ -172,10 +172,10 @@ char *toRelease;
         if (nodeName != string("material")) {
             msglog << MSG::FATAL << 
                    "Error in xml/gmx file: A materialref referenced a " << nodeName << " instead of a material." << endmsg;
-            exit(999); // Should do better...
+            std::abort();
         }
 
-        GeoMaterial *geoMaterial = (GeoMaterial *) gmxUtil.tagHandler.material.process(elem, gmxUtil);
+        const GeoMaterial *geoMaterial = static_cast<const GeoMaterial *> (gmxUtil.tagHandler.material.process(elem, gmxUtil));
 
         fracString = XMLString::transcode(elRef->getAttribute(fraction_tmp));
         fraction = gmxUtil.evaluate(fracString);
@@ -198,5 +198,5 @@ char *toRelease;
   XMLString::release(&materialref_tmp);
 
 
-    return (const RCBase *) material;
+    return (RCBase *) material;
 }
diff --git a/DetectorDescription/GeoModelXml/src/MakePara.cxx b/DetectorDescription/GeoModelXml/src/MakePara.cxx
index e1aaef2b76e..c68e187611e 100644
--- a/DetectorDescription/GeoModelXml/src/MakePara.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakePara.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakePara::MakePara() {}
 
-const RCBase * MakePara::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakePara::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 6; 
 char const *parName[nParams] = {"xhalflength", "yhalflength", "zhalflength", "alpha", "theta", "phi"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakePcon.cxx b/DetectorDescription/GeoModelXml/src/MakePcon.cxx
index f333f5fddbd..4b98472a34c 100644
--- a/DetectorDescription/GeoModelXml/src/MakePcon.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakePcon.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -15,7 +15,7 @@ using namespace xercesc;
 
 MakePcon::MakePcon() {}
 
-const RCBase * MakePcon::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakePcon::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 2; 
 char const *parName[nParams] = {"sphi", "dphi"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakePgon.cxx b/DetectorDescription/GeoModelXml/src/MakePgon.cxx
index a57daf51291..a73b002c762 100644
--- a/DetectorDescription/GeoModelXml/src/MakePgon.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakePgon.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -15,7 +15,7 @@ using namespace xercesc;
 
 MakePgon::MakePgon() {}
 
-const RCBase * MakePgon::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakePgon::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 3; 
 char const *parName[nParams] = {"sphi", "dphi", "nsides"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeShaperef.cxx b/DetectorDescription/GeoModelXml/src/MakeShaperef.cxx
index 7bcb5b2374e..a541727e210 100644
--- a/DetectorDescription/GeoModelXml/src/MakeShaperef.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeShaperef.cxx
@@ -15,7 +15,7 @@
 using namespace std;
 using namespace xercesc;
 
-const RCBase *MakeShaperef::process(const DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase *MakeShaperef::process(const DOMElement *element, GmxUtil &gmxUtil) const {
 //
 //    Get the referenced shape
 //
@@ -36,7 +36,7 @@ const RCBase *MakeShaperef::process(const DOMElement *element, GmxUtil &gmxUtil)
         msglog << MSG::FATAL << "Error processing <shaperef> tag: An IDREF for a shape did not refer to a shape.\nShape ref was " << 
                idref_s << "; exiting" << endmsg;
         XMLString::release (&idref_s);
-        exit (1); // Need to improve...
+        std::abort();
     }
 //
 //    Get what sort of shape
diff --git a/DetectorDescription/GeoModelXml/src/MakeSimplePolygonBrep.cxx b/DetectorDescription/GeoModelXml/src/MakeSimplePolygonBrep.cxx
index 3150a3dd0b9..8df003a75cb 100644
--- a/DetectorDescription/GeoModelXml/src/MakeSimplePolygonBrep.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeSimplePolygonBrep.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 #include <string>
 #include <vector>
@@ -18,7 +18,7 @@ using namespace xercesc;
 
 MakeSimplePolygonBrep::MakeSimplePolygonBrep() {}
 
-const RCBase * MakeSimplePolygonBrep::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeSimplePolygonBrep::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 3; 
 char const *parName[nParams] = {"xpoints", "ypoints", "zhalflength"};
 double z;
diff --git a/DetectorDescription/GeoModelXml/src/MakeSubtraction.cxx b/DetectorDescription/GeoModelXml/src/MakeSubtraction.cxx
index 699af4a9c7c..a6a99f66589 100644
--- a/DetectorDescription/GeoModelXml/src/MakeSubtraction.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeSubtraction.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -16,39 +16,40 @@
 
 #include "xercesc/util/XMLString.hpp"
 #include "GeoModelXml/GmxUtil.h"
+#include "CxxUtils/checker_macros.h"
 
 using namespace xercesc;
 using namespace std;
 
 MakeSubtraction::MakeSubtraction() {}
 
-const RCBase * MakeSubtraction::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeSubtraction::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 // 
 //    Process child elements; first is first shaperef; then transformation; then second shaperef.
 //
-    GeoShape *first = 0;
-    GeoShape *second = 0;
+    const GeoShape *first = 0;
+    const GeoShape *second = 0;
     GeoTrf::Transform3D hepXf=GeoTrf::Transform3D::Identity();
     int elementIndex = 0;
     for (DOMNode *child = element->getFirstChild(); child != 0; child = child->getNextSibling()) {
         if (child->getNodeType() == DOMNode::ELEMENT_NODE) { // Skips text nodes
             switch (elementIndex) {
                 case 0: { // First element is first shaperef
-                    first = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    first = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 case 1: { // Second element is transformation or transformationref
                     char *toRelease = XMLString::transcode(child->getNodeName());
                     string nodeName(toRelease);
                     XMLString::release(&toRelease);
-                    GeoTransform *geoXf = nodeName == "transformation"? 
-(GeoTransform *) gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil):
-(GeoTransform *) gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil);
+                    const GeoTransform *geoXf = nodeName == "transformation"? 
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil)):
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil));
                     hepXf = geoXf->getTransform();
                     break;
                 }
                 case 2: { // Third element is second shaperef
-                    second = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    second = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 default: // More than 3 elements?
@@ -59,7 +60,10 @@ const RCBase * MakeSubtraction::make(const xercesc::DOMElement *element, GmxUtil
         }
     }
 
-    const GeoShapeSubtraction *temp = &(first->subtract(*(GeoShape *) &(*(second) << hepXf)));
+    // FIXME: subtract() returns a new'd object --- should really be
+    // returning a `unique_ptr<GeoShapeSubtraction>' not a
+    // `const GeoShapeSubtraction'
+    GeoShapeSubtraction *temp ATLAS_THREAD_SAFE = const_cast<GeoShapeSubtraction*>(&(first->subtract(*(GeoShape *) &(*(second) << hepXf))));
 
     return (RCBase *) temp;
 }
diff --git a/DetectorDescription/GeoModelXml/src/MakeTransformation.cxx b/DetectorDescription/GeoModelXml/src/MakeTransformation.cxx
index 603b094b619..5c1e1cf30bb 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTransformation.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTransformation.cxx
@@ -18,7 +18,7 @@ using namespace std;
 
 MakeTransformation::MakeTransformation() {}
 
-const RCBase * MakeTransformation::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeTransformation::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 char *name2release;
  GeoTrf::Transform3D hepTransform=GeoTrf::Transform3D::Identity(); // Starts as Identity transform
 //
@@ -53,9 +53,9 @@ char *name2release;
     XMLString::release(&toRelease);
     XMLString::release(&alignable_tmp);
     if (alignable.compare(string("true")) == 0) {
-        return (const RCBase *) new GeoAlignableTransform(hepTransform);
+        return (RCBase *) new GeoAlignableTransform(hepTransform);
     }
     else {
-        return (const RCBase *) new GeoTransform(hepTransform);
+        return (RCBase *) new GeoTransform(hepTransform);
     }
 }
diff --git a/DetectorDescription/GeoModelXml/src/MakeTransformationref.cxx b/DetectorDescription/GeoModelXml/src/MakeTransformationref.cxx
index d3054df9eff..b33238b1f82 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTransformationref.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTransformationref.cxx
@@ -16,7 +16,7 @@
 using namespace std;
 using namespace xercesc;
 
-const RCBase *MakeTransformationref::make(const DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase *MakeTransformationref::make(const DOMElement *element, GmxUtil &gmxUtil) const {
 XMLCh *ref = XMLString::transcode("ref");
 const XMLCh *idref;
 DOMDocument *doc = element->getOwnerDocument();
@@ -36,7 +36,7 @@ char *toRelease;
         OUTPUT_STREAM;
         msglog << MSG::FATAL << "Error in xml/gmx file: transformationref " << XMLString::transcode(idref) << " referenced a " << nodeName << 
                 " instead of a transformation." << endmsg;
-        exit(999); // Should do better...
+        std::abort();
     }
 //
 //    Process it
diff --git a/DetectorDescription/GeoModelXml/src/MakeTrap.cxx b/DetectorDescription/GeoModelXml/src/MakeTrap.cxx
index c7c64b3eb58..6e881629f2d 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTrap.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTrap.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeTrap::MakeTrap() {}
 
-const RCBase * MakeTrap::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeTrap::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 11; 
 char const *parName[nParams] = {"zhalflength", "theta", "phi", "dydzn", "dxdyndzn", "dxdypdzn", "angleydzn", "dydzp", "dxdyndzp", "dxdypdzp", "angleydzp"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeTrd.cxx b/DetectorDescription/GeoModelXml/src/MakeTrd.cxx
index afe9dd86a33..7b326216dfe 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTrd.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTrd.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeTrd::MakeTrd() {}
 
-const RCBase * MakeTrd::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeTrd::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 5; 
 char const *parName[nParams] = {"xhalflength1", "xhalflength2", "yhalflength1", "yhalflength2", "zhalflength"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeTube.cxx b/DetectorDescription/GeoModelXml/src/MakeTube.cxx
index b8690d063d9..e916cd98af4 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTube.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTube.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeTube::MakeTube() {}
 
-const RCBase * MakeTube::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeTube::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 3; 
 char const *parName[nParams] = {"rmin", "rmax", "zhalflength"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeTubs.cxx b/DetectorDescription/GeoModelXml/src/MakeTubs.cxx
index b0d4d79bfca..f6c76a6a988 100644
--- a/DetectorDescription/GeoModelXml/src/MakeTubs.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeTubs.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Automatically generated code from /home/hessey/prog/gmx2geo/makeshape
@@ -14,7 +14,7 @@ using namespace xercesc;
 
 MakeTubs::MakeTubs() {}
 
-const RCBase * MakeTubs::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeTubs::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 const int nParams = 5; 
 char const *parName[nParams] = {"rmin", "rmax", "zhalflength", "sphi", "dphi"};
 double p[nParams];
diff --git a/DetectorDescription/GeoModelXml/src/MakeUnion.cxx b/DetectorDescription/GeoModelXml/src/MakeUnion.cxx
index d23afc4ffe6..920fcd1be1f 100644
--- a/DetectorDescription/GeoModelXml/src/MakeUnion.cxx
+++ b/DetectorDescription/GeoModelXml/src/MakeUnion.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "GeoModelXml/shape/MakeUnion.h"
@@ -14,39 +14,40 @@
 
 #include "xercesc/util/XMLString.hpp"
 #include "GeoModelXml/GmxUtil.h"
+#include "CxxUtils/checker_macros.h"
 
 using namespace xercesc;
 using namespace std;
 
 MakeUnion::MakeUnion() {}
 
-const RCBase * MakeUnion::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
+RCBase * MakeUnion::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) const {
 // 
 //    Process child elements; first is first shaperef; then transform; then second shaperef.
 //
-    GeoShape *first = 0;
-    GeoShape *second = 0;
+    const GeoShape *first = 0;
+    const GeoShape *second = 0;
     GeoTrf::Transform3D hepXf=GeoTrf::Transform3D::Identity();
     int elementIndex = 0;
     for (DOMNode *child = element->getFirstChild(); child != 0; child = child->getNextSibling()) {
         if (child->getNodeType() == DOMNode::ELEMENT_NODE) { // Skips text nodes
             switch (elementIndex) {
                 case 0: { // First element is first shaperef
-                    first = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    first = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 case 1: { // Second element is transformation or transformationref
                     char *toRelease = XMLString::transcode(child->getNodeName());
                     string nodeName(toRelease);
                     XMLString::release(&toRelease);
-                    GeoTransform *geoXf = nodeName == "transformation"? 
-(GeoTransform *) gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil):
-(GeoTransform *) gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil);
+                    const GeoTransform *geoXf = nodeName == "transformation"? 
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformation.process(dynamic_cast<DOMElement *>(child), gmxUtil)):
+static_cast<const GeoTransform *> (gmxUtil.tagHandler.transformationref.process(dynamic_cast<DOMElement *>(child), gmxUtil));
                     hepXf = geoXf->getTransform();
                     break;
                 }
                 case 2: { // Third element is second shaperef
-                    second = (GeoShape *) gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil);
+                    second = static_cast<const GeoShape *> (gmxUtil.tagHandler.shaperef.process(dynamic_cast<DOMElement *> (child), gmxUtil));
                     break;
                 }
                 default: // More than 3 elements?
@@ -57,7 +58,10 @@ const RCBase * MakeUnion::make(const xercesc::DOMElement *element, GmxUtil &gmxU
         }
     }
 
-    const GeoShapeUnion *temp = &(first->add(*(GeoShape *) &(*(second) << hepXf)));
+    // FIXME: add() returns a new'd object --- should really be
+    // returning a `unique_ptr<GeoShapeUnion>' not a
+    // `const GeoShapeUnion'
+    GeoShapeUnion *temp ATLAS_THREAD_SAFE = const_cast<GeoShapeUnion*>(&(first->add(*(GeoShape *) &(*(second) << hepXf))));
 
     return (RCBase *) temp;
 }
diff --git a/DetectorDescription/GeoModelXml/src/MulticopyProcessor.cxx b/DetectorDescription/GeoModelXml/src/MulticopyProcessor.cxx
index cbccfe6a23d..380ed5c7097 100644
--- a/DetectorDescription/GeoModelXml/src/MulticopyProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/MulticopyProcessor.cxx
@@ -92,7 +92,7 @@ DOMDocument *doc = element->getOwnerDocument();
             if (!gmxUtil.eval.findVariable(firstElement.c_str())) {
                 msglog << MSG::FATAL << "Error in .gmx file. Processing multicopy element with name " << name << 
                 ". Found loopvar set to " << varname << ", but no vector with that name has been defined." << endmsg;
-                exit(999); // Should do better
+                std::abort();
             }
         }
 //
@@ -110,7 +110,7 @@ DOMDocument *doc = element->getOwnerDocument();
             else { // Not OK
                 msglog << MSG::FATAL << "Error in .gmx file. Processing multicopy element with name " << name <<
                 ". \nIt gives loopvar therefore should have a <transformation> and not a <transformationref> (despite the DTD)\n";
-                exit(999); // Should do better
+                std::abort();
             }
         }
         else {
@@ -127,11 +127,11 @@ DOMDocument *doc = element->getOwnerDocument();
             for (int i = 0; i < nCopies; ++i) {
                 gmxUtil.eval.setVariable(varname.c_str(), (varname + "_" + to_string(i)).c_str());
                 if (alignable) {
-                    geoAXf = (GeoAlignableTransform *) xFormProcessor->make(elXf, gmxUtil);
+                    geoAXf = static_cast<GeoAlignableTransform *> (xFormProcessor->make(elXf, gmxUtil));
                     xfList->push_back((GeoGraphNode *) geoAXf);
                 }
                 else {
-                    geoXf = (GeoTransform *) xFormProcessor->make(elXf, gmxUtil);
+                    geoXf = static_cast<GeoTransform *> (xFormProcessor->make(elXf, gmxUtil));
                     xfList->push_back((GeoGraphNode *) geoXf);
                 }
                 gmxUtil.eval.removeVariable(varname.c_str()); // Avoids a warning status in evaluator
@@ -144,11 +144,11 @@ DOMDocument *doc = element->getOwnerDocument();
 //
 	  GeoTrf::Transform3D hepXf0=GeoTrf::Transform3D::Identity();
             if (alignable) {
-                geoAXf = (GeoAlignableTransform *) xFormProcessor->make(elXf, gmxUtil);
+                geoAXf = static_cast<GeoAlignableTransform *> (xFormProcessor->make(elXf, gmxUtil));
                 hepXf0 = geoAXf->getTransform();
             }
             else {
-                geoXf = (GeoTransform *) xFormProcessor->make(elXf, gmxUtil);
+                geoXf = static_cast<GeoTransform *> (xFormProcessor->make(elXf, gmxUtil));
                 hepXf0 = geoXf->getTransform();
             }
             GeoTrf::Transform3D hepXf=GeoTrf::Transform3D::Identity(); // Identity initially
@@ -206,7 +206,7 @@ DOMDocument *doc = element->getOwnerDocument();
 	  msglog << MSG::FATAL << 
 	    "multicopyprocessor: error in " << name << ". <transform> object was neither assemblyref nor logvolref\n"
                     << "Exiting Athena" << endmsg;
-	  exit(999); // Should do better
+          std::abort();
 	}
       }
     }
diff --git a/DetectorDescription/GeoModelXml/src/PositionIndex.cxx b/DetectorDescription/GeoModelXml/src/PositionIndex.cxx
index 162528e4d2c..20bbe16650e 100644
--- a/DetectorDescription/GeoModelXml/src/PositionIndex.cxx
+++ b/DetectorDescription/GeoModelXml/src/PositionIndex.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include <cstdlib>
@@ -105,7 +105,7 @@ void PositionIndex::indices(map<string, int> &index, Evaluator &eval) {
             eval.print_error();
             msglog << m_formula[name] << endl << string(eval.error_position(), '-') << '^' << '\n' << "Exiting program." << 
                    endmsg;
-            exit(999); // Should do better...
+            std::abort();
         }
 //
 //    And create a CLHEP variable with the same index-name in case the user needs it 
diff --git a/DetectorDescription/GeoModelXml/src/TransformProcessor.cxx b/DetectorDescription/GeoModelXml/src/TransformProcessor.cxx
index 55774d47102..71a593bd42d 100644
--- a/DetectorDescription/GeoModelXml/src/TransformProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/TransformProcessor.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -51,7 +51,7 @@ char *tagName;
  DOMElement *transformation = element->getFirstElementChild();
  tagName = XMLString::transcode(transformation->getTagName()); // transformation or transformationref
  //  ******* Should check here that an alignable transform is given an alignable transformation and object; to be done
- toAdd.push_back((GeoGraphNode *)gmxUtil.geoItemRegistry.find(string(tagName))->process(transformation, gmxUtil));
+ toAdd.push_back((GeoGraphNode *)(gmxUtil.geoItemRegistry.find(string(tagName))->process(transformation, gmxUtil)));
  XMLString::release(&tagName);
  //
  //    Add transformation to DetectorManager via GmxInterface, if it is alignable
diff --git a/DetectorDescription/GeoModelXml/src/TransformrefProcessor.cxx b/DetectorDescription/GeoModelXml/src/TransformrefProcessor.cxx
index a375911755a..55b2107a616 100644
--- a/DetectorDescription/GeoModelXml/src/TransformrefProcessor.cxx
+++ b/DetectorDescription/GeoModelXml/src/TransformrefProcessor.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -36,7 +36,7 @@ char *toRelease;
         OUTPUT_STREAM;
         msglog << MSG::FATAL<< "Error in xml/gmx file: transformref " << XMLString::transcode(idref) << " referenced a " << nodeName << 
                 " instead of a logvol." << endmsg;
-        exit(999); // Should do better...
+        std::abort();
     }
 //
 //    Process it
diff --git a/DetectorDescription/GeoModelXml/src/decompress.cxx b/DetectorDescription/GeoModelXml/src/decompress.cxx
index 6566366cb7c..5d72fcff650 100644
--- a/DetectorDescription/GeoModelXml/src/decompress.cxx
+++ b/DetectorDescription/GeoModelXml/src/decompress.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //
@@ -9,6 +9,7 @@
 #include <sstream>
 #include <algorithm>
 #include <stdexcept>
+#include "CxxUtils/checker_macros.h"
 
 extern "C" {
     #include <zlib.h>
@@ -24,7 +25,8 @@ string decompress(const string& str) {
     zs.zalloc   = NULL;
     zs.zfree    = NULL;
     zs.opaque   = NULL;
-    zs.next_in  = (Bytef *)str.c_str();
+    char* str_nc ATLAS_THREAD_SAFE = const_cast<char*> (str.c_str());
+    zs.next_in  = reinterpret_cast<Bytef *>(str_nc);
     zs.avail_in = str.size();
 
     // According to the official manual, 2nd param is windowsBits and is max. 15. But a web page somewhere 
-- 
GitLab