diff --git a/spack/packages/dd4hep/package.py b/spack/packages/dd4hep/package.py
index 6e322c928d54d819b9587e136d225e217dd04e76..b1bfde0f556748e5050d3967aeb7af32a9b1f1e6 100644
--- a/spack/packages/dd4hep/package.py
+++ b/spack/packages/dd4hep/package.py
@@ -51,6 +51,9 @@ class Dd4hep(CMakePackage):
     # See https://github.com/spack/spack/issues/24232
     patch('cmake_language.patch', when='@:1.16.1')
 
+    # hack to fix refcount underflow
+    patch('refcount_underflow.patch', when='@1.17:')
+    
     # custom hash for the 2021-07-27 version, needed to include
     # https://github.com/AIDASoft/DD4hep/pull/849
     # https://github.com/AIDASoft/DD4hep/pull/851
diff --git a/spack/packages/dd4hep/refcount_underflow.patch b/spack/packages/dd4hep/refcount_underflow.patch
new file mode 100644
index 0000000000000000000000000000000000000000..37b1e12a827965b218e40de2416afc4fbba7ebb1
--- /dev/null
+++ b/spack/packages/dd4hep/refcount_underflow.patch
@@ -0,0 +1,14 @@
+diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp
+index 1db6105c..7f8d7482 100644
+--- a/DDG4/src/Geant4Particle.cpp
++++ b/DDG4/src/Geant4Particle.cpp
+@@ -57,7 +57,9 @@ Geant4Particle::~Geant4Particle()  {
+ void Geant4Particle::release()  {
+   //::printf("************ Release Geant4Particle[%p]: ID:%d pdgID %d ref:%d\n",(void*)this,id,pdgID,ref-1);
+   if ( --ref <= 0 )  {
++    if( (ref > -1) ) { 
+     delete this;
++    }
+   }
+ }
+