[sword-devel] osis2mod bug
DM Smith
dmsmith at crosswire.org
Mon Jan 4 09:52:45 MST 2010
I took a quick look at the problem. Seems that osis2mod chokes on
chapter numbers that are not in the book.
(It works just fine if the chapter is valid but the verse number is not.
And I still cannot reproduce the bug where it chokes on a book not in
the versification.)
Here is the smallest valid OSIS input that reproduces the problem:
<?xml version="1.0" encoding="UTF-8"?><osis
xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace
http://www.bibletechnologies.net/osisCore.2.1.1.xsd">
<osisText osisIDWork="KJV" osisRefWork="defaultReferenceScheme"
xml:lang="en">
<header>
<work osisWork="KJV">
<title>King James Version (1769)</title>
<identifier type="OSIS">Bible.KJV</identifier>
<scope>Gen-Rev</scope>
<refSystem>Bible.KJV</refSystem>
</work>
<work osisWork="defaultReferenceScheme">
<refSystem>Bible.KJV</refSystem>
</work>
</header>
<div type="book" osisID="Matt" canonical="true">
<chapter osisID="Matt.29">
<verse osisID="Matt.29.1">Matt.29.1 is not in the KJV versification</verse>
</chapter>
</div>
</osisText>
</osis>
Since osis2mod does not care about the header, the following will do the
same:
<div>
<verse osisID="Matt.29.1">Matt.29.1 is not in the KJV versification</verse>
</div>
A quick look shows the problem in this osis2mod code (lines 773-800):
// Get osisID for verse or annotateRef for commentary
SWBuf keyVal = token.getAttribute(tokenName == "verse" ? "osisID" :
"annotateRef");
// Massage the key into a form that ParseVerseList can accept
prepareSWVerseKey(keyVal);
// The osisID or annotateRef can be more than a single verse
// The first or only one is the currentVerse
// Use the last verse seen (i.e. the currentVerse) as the basis for
recovering from bad parsing.
// This should never happen if the references are valid OSIS references
ListKey verseKeys = currentVerse.ParseVerseList(keyVal, currentVerse, true);
int memberKeyCount = verseKeys.Count();
if (memberKeyCount) {
currentVerse = verseKeys.getElement(0);
// See if this osisID or annotateRef refers to more than one verse.
// If it does, save it until all verses have been seen.
// At that point we will output links.
// This can be done by incrementing, which will produce an error
// if there is only one verse.
verseKeys.setPosition(TOP);
verseKeys.increment(1);
if (!verseKeys.Error()) {
linkedVerses.push_back(verseKeys);
}
}
else {
cout << "ERROR(REF): Invalid osisID/annotateRef: " <<
token.getAttribute((tokenName == "verse") ? "osisID" :
}
In looking at the stack trace it gets into an infinite loop when calling:
verseKeys.increment(1);
This calls Index(pos) with a value of 0, and recursively calls it with a
value of -1. Once it does that, it spins until a segfault calling malloc.
Some help would be appreciated since I have very little extra time this
month.
In Him,
DM
More information about the sword-devel
mailing list