Skip to content

Memory leak by TopLevelTable::GetTableSize() + assert crash #14

@rrrlasse

Description

@rrrlasse

The code at the end of this issue crashes during exit of main(), in:

SlabAlloc::~SlabAlloc() {

ifdef _DEBUG

if (!IsAllFree()) {
    m_slabs.Print();
    m_freeSpace.Print();
    assert(false);
}

because IsAllFree() returns false. Happens in VS and gcc/Linux for the commit https://github.com/rrrlasse/tightdb/commit/4d3ebb50760bcb7b36b39ac369aac0f47359ed0f

include "UnitTest++.h"

include

include <math.h>

include "Column.h"

include

include "tightdb.h"

include "Group.h"

int main() {
Group group;
TopLevelTable& table = group.GetTable("test");

Spec s = table.GetSpec();
s.AddColumn(COLUMN_TYPE_INT,    "i");
Spec sub = s.AddColumnTable(    "tab");
    sub.AddColumn(COLUMN_TYPE_BOOL,   "active");
    sub.AddColumn(COLUMN_TYPE_INT,    "count");
    sub.AddColumn(COLUMN_TYPE_STRING, "str");
table.UpdateFromSpec(s.GetRef());

// Add a row of data
table.InsertInt(0, 0, 6);
table.InsertTable(1, 0);
table.InsertDone();

Table subtable = table.GetTable(1,0);
subtable.InsertBool   (0, 0, true);
subtable.InsertInt    (1, 0, 6);
subtable.InsertString (2, 0, "Fido");
subtable.InsertDone();

std::cerr << table.GetTableSize(1,0) << std::endl;

// const int res = UnitTest::RunAllTests();

ifdef _MSC_VER

// getchar(); // wait for key

endif

//return res;
return 0;

}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions