Skip to content

buffer overflow detected when adding 10 million or more columns #199

@Wert5

Description

@Wert5

When adding the 10 millionth column to a CoinModel I get the following error message:
*** buffer overflow detected *** : ./solver terminated
A stack trace shows that the error occurs during CoinModel::addColumn(int, int const*, double const*, double, double, double, char const*, bool) () from /usr/lib/x86_64-linux-gnu/libCoinUtils.so.3
The next function on the stack trace was ___sprintf_chk which suggests that the problem is an overflow writing to a string.

Examining the code, I believe the issue is the format limitation of 7 characters for the number when creating a default name in addColumn. This makes sense because 10000000 is the first integer that requires 8 characters in a string.

CoinUtils/src/CoinModel.cpp

Lines 929 to 935 in ee7c023

if (name) {
columnName_.addHash(numberColumns_, name);
} else if (!noNames_) {
char name[9];
sprintf(name, "c%7.7d", numberColumns_);
columnName_.addHash(numberColumns_, name);
}

Increasing this limit from 7 characters to 10 characters would allow up to 9.999 * 10^9 = almost 10 billion variables, which is way more than anyone could practically solve.

Currently, I can work around this issue by setting noNames to true in the CoinModel constructor. I have confirmed that setting noNames to true prevents the error.

Although I understand that 10 million variables may be more variables than Coin was designed for, it solves in a reasonable time. My program, which uses Coin to solve 2 problems with over 10 million variables, finishes running in 12 minutes on my laptop.

Metadata

Metadata

Assignees

No one assigned

    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