S , 2012-06-09 11:45 +0300, My Th rakstīja:
> S , 2012-06-09 00:30 +0300, My Th rakstīja:
> > Hi!
> > 
> > I have a GAMESS output file which kills Avogadro when loading MOs:
> > ...
> > push back 0.013014 
> > add MOs: 50 1052 
> > *** glibc detected *** /usr/bin/avogadro: malloc(): memory corruption:
> > 0x0000000002bec940 ***
> > When calling new in OpenQube::GAMESSUSOutput::load at
> > libavogadro/src/extensions/surfaces/openqube/gamessus.cpp:257
> > 
...
> The real issue is that GAMESSUSOutput::processLine() is ignoring
> elements when processing "ATOMIC BASIS SET" and relies on having a basis
> printed for each atom in molecule and in the right order. Now with the
> output of FMO (Fragment Molecular Orbital method) calculation these
> assumptions don't hold. In this case we have only one basis printed for
> each atom type, and MOs are printed for fragments, not the whole
> molecule.
> 
> I have a molecule consisting of 4 elements, that gives total of 50 AOs,
> but the first fragment has 14 atoms and 205 AOs (for which 192 MOs are
> written). And that confuses gaussianset.cpp::GaussianSet::addMOs(), it
> tries to fit 205x192=39360 elements into 50x50=2500 matrix. It looks
> like Eigen::MatrixXd doesn't check indexes for coeffRef(i, j) and it
> ends up with glibc panicking.
> 
> I guess it would be relatively easy to add a check and bail out if
> inconsistency is detected, but adding proper FMO output support would be
> more tricky. One way would be by adding multilevel mode support for
> gamessus.cpp::GAMESSUSOutput::processLine() so that m_currentMode works
> as now, by reading eigenvectors, but additionally would direct them to
> the right fragment. Any ideas comments?

Attached is a patch which stops loading and displaying MOs if there are
more eigenvectors than expected from basis (if there is not given basis
for each atom in the system). With this it aborts MO loading and
displays just the structures from optimization run. I'm not sure if the
checks are put in quite the right places, someone more familiar with the
code could comment on that.


Reinis
>From f9188933e5c584247c989ab663b1f3fba0362e7f Mon Sep 17 00:00:00 2001
From: Reinis Danne <[email protected]>
Date: Sat, 9 Jun 2012 15:06:00 +0300
Subject: [PATCH] orbitalextension: Don't read eigenvectors if them are more
 than MOs

This prevents loading of MOs and consequent memory corruption in case
where GTOs are not given for each atom of the system, like in the case
of FMO calculation in Gamess-US output where there is only one GTO for
each atom type in molecule.
---
 .../extensions/surfaces/openqube/gaussianset.cpp   |    7 +++++++
 .../src/extensions/surfaces/orbitalextension.cpp   |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/libavogadro/src/extensions/surfaces/openqube/gaussianset.cpp b/libavogadro/src/extensions/surfaces/openqube/gaussianset.cpp
index d913ddf..ad64707 100644
--- a/libavogadro/src/extensions/surfaces/openqube/gaussianset.cpp
+++ b/libavogadro/src/extensions/surfaces/openqube/gaussianset.cpp
@@ -145,6 +145,13 @@ void GaussianSet::addMOs(const vector<double>& MOs)
   unsigned int columns = MOs.size() / m_numMOs;
   qDebug() << " add MOs: " << m_numMOs << columns;
 
+  if (MOs.size() > m_numMOs*m_numMOs) {
+    qDebug() << " Can not fit " << MOs.size() << " eigenvectors in "
+             << m_numMOs << "x" << m_numMOs << " matrix!";
+    MOs.clear();
+    return;
+  }
+
   m_moMatrix.resize(m_numMOs, m_numMOs);
 
   for (unsigned int j = 0; j < columns; ++j)
diff --git a/libavogadro/src/extensions/surfaces/orbitalextension.cpp b/libavogadro/src/extensions/surfaces/orbitalextension.cpp
index d92dac6..11e2a1c 100644
--- a/libavogadro/src/extensions/surfaces/orbitalextension.cpp
+++ b/libavogadro/src/extensions/surfaces/orbitalextension.cpp
@@ -808,6 +808,11 @@ namespace Avogadro
         }
         GaussianSet *gaussian = new GaussianSet;
         GAMESSUSOutput gamout(m_molecule->fileName(), gaussian);
+        if (gaussian->numMOs() < 1) {
+          qDebug() << " No MOs loaded.";
+          delete gaussian;
+          return false;
+        }
         m_basis = gaussian;
         return true;
       }
-- 
1.7.8.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Avogadro-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

Reply via email to