#At file:///home/svoj/devel/bzr-mysql/mysql-6.0-falcon-team-bug39456/
2922 Sergey Vojtovich 2008-12-03
BUG#39456 - Falcon: assertion (false) failed at line 258 in file
RecordLocatorPage.cpp
Falcon in-memory data page structures may get corrupt and
cause assertion failures in certain cases.
Fixed two integer overruns.
modified:
storage/falcon/DataPage.cpp
storage/falcon/RecordLocatorPage.cpp
per-file messages:
storage/falcon/DataPage.cpp
Fixed short integer overrun in DataPage::storeRecord() when
page size is 32k and page is [almost] full and there're no
unused slots for new lineIndex entry.
Fixed incorrect calculation of available space in
DataPage::deleteLine(). We must take absolute value
of lineIndex.length, as negative bit only informs us
that there is an overflow page for this record.
storage/falcon/RecordLocatorPage.cpp
Assert that availableSpace must be smaller than 0x8000, otherwise
it'll cause short integer overrun.
=== modified file 'storage/falcon/DataPage.cpp'
--- a/storage/falcon/DataPage.cpp 2008-06-17 17:41:54 +0000
+++ b/storage/falcon/DataPage.cpp 2008-12-03 14:30:51 +0000
@@ -225,7 +225,7 @@ int DataPage::storeRecord(Dbb *dbb, Bdb
short id = -1;
short highWater = dbb->pageSize;
- short used = OFFSET (DataPage*, lineIndex) + maxLine * sizeof (LineIndex);
+ int spaceRemaining = dbb->pageSize - OFFSET (DataPage*, lineIndex) - maxLine * sizeof (LineIndex) - length;
LineIndex *line, *end;
for (line = lineIndex, end = line + maxLine; line < end; ++line)
@@ -234,19 +234,17 @@ int DataPage::storeRecord(Dbb *dbb, Bdb
if (line->offset < highWater)
highWater = line->offset;
- used += ABS (line->length);
+ spaceRemaining -= ABS (line->length);
}
else if (id == -1)
id = (int) (line - lineIndex);
if (id == -1)
{
- used += sizeof (LineIndex);
+ spaceRemaining -= sizeof (LineIndex);
++end;
}
- int spaceRemaining = dbb->pageSize - used - length;
-
if (spaceRemaining < 0)
return 0;
@@ -318,7 +316,7 @@ int DataPage::deleteLine (Dbb *dbb, int
if (lineIndex [n].offset)
{
max = n + 1;
- available -= lineIndex[n].length;
+ available -= ABS(lineIndex[n].length);
}
maxLine = max;
=== modified file 'storage/falcon/RecordLocatorPage.cpp'
--- a/storage/falcon/RecordLocatorPage.cpp 2008-06-17 17:41:54 +0000
+++ b/storage/falcon/RecordLocatorPage.cpp 2008-12-03 14:30:51 +0000
@@ -269,7 +269,7 @@ void RecordLocatorPage::printPage(void)
void RecordLocatorPage::setIndexSlot(int slot, int32 pageNumber, int line, int availableSpace)
{
- ASSERT(availableSpace >= 0);
+ ASSERT(availableSpace >= 0 && availableSpace < 0x8000);
RecordIndex *element = elements + slot;
//validateSpaceSlots();