Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » libsbml-development » LibSBML crashes non-deterministically
Show: Today's Posts  :: Message Navigator
| Subscribe to topic 
Return to the default flat view Create a new topic Submit Reply
AuthorTopic
Andreas Dräger


Posts: 273
Registered:
June 2006
LibSBML crashes non-deterministically 15 Jul '09 00:24 Go to previous message

Dear all,

It is interesting to observe the following crash of libSBML. I loaded two models into memory and tried the following (using libSBML 3.4 and Scientific Linux as OS):

// model 1: m1
// model 2: m2

for (i = 0; i < m1.getNumSpecies(); i++) {
Species s1 = m1.getSpecies(i);
Species s2 = findSpecies(m2, s1);
if (s2 == null) {
System.out.println("no mapping found for Species " + s1.getId());
} else {
System.out.println("mapping Species " + s1.getId() + " to " + s2.getId());
}
}

Please find the referenced methods below. Interestingly, this code snippet crashes if I change the if-clause as follows:

if (s2 != null) {
System.out.println("mapping Species " + s1.getId() + " to " + s2.getId());
} else {
System.out.println("no mapping found for Species " + s1.getId());
}

LibSBML then states an unexpected error occured and the program was terminated. It took a lot of time to identify the source of this error but I still do not know why this actually happens.

Cheers
Andreas

// The referenced methods:


public static Species findSpecies(Model m, Species s) {
for (int i = 0; i < m.getNumSpecies(); i++)
if (equals(m.getSpecies(i), s))
return m.getSpecies(i);
return null;
}

/**
* Returns true if both species have the identical id, the identical name,
* or if the MIRIAM annotation of both species is identical.
*
* @param r
* @param p
* @return
*/
public static boolean equals(Species r, Species p) {
if (r.getId().equals(p.getId())
|| (r.isSetName() && p.isSetName() && r.getName().equals(
p.getName())))
return true;
// annotation check
for (int i = 0; i < r.getNumCVTerms(); i++) {
CVTerm cvtR = r.getCVTerm(i);
boolean equal = false;
for (int j = 0; j < p.getNumCVTerms(); j++) {
CVTerm cvtP = p.getCVTerm(j);
// run over all
if (cvtR.getQualifierType() == cvtP.getQualifierType())
for (int k = 0; k < cvtR.getNumResources(); k++) {
for (int l = 0; l < cvtP.getNumResources(); l++)
if (cvtR.getResources().getValue(k).equals(
cvtP.getResources().getValue(l)))
equal = true;
}
}
if (equal)
return true;
}
return false;
}

      

SubjectPosterDate
Read Message   LibSBML crashes non-deterministically  Andreas Dräger15 Jul '09 00:24
Read Message   Re: LibSBML crashes non-deterministically Andreas Dräger15 Jul '09 00:42
Read Message   Re: LibSBML crashes non-deterministically Andreas Dräger15 Jul '09 00:46
Read Message   Re: LibSBML crashes non-deterministically Frank Bergmann15 Jul '09 09:48
Read Message   Re: LibSBML crashes non-deterministically Frank Bergmann15 Jul '09 08:53
Previous Topic:getFormula and InitialAssignment
Next Topic:64-bit libsbml
Go to forum:
-=] Back to Top [=-

Powered by FUDforum. (Copyright Advanced Internet Designs Inc.)

Please use our issue tracking system for any questions or suggestions about this website.