New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with fatal error when max nodes limit reached #121

merged 1 commit into from Mar 9, 2018


None yet
2 participants

poire-z commented Mar 9, 2018

Crash with fatal error when max nodes limit reached instead of segfault (to ease discriminating bugs).

FATAL ERROR #1003: allocTinyNode: can't create any more text nodes (hard limit)

Copied from koreader/koreader#3459 (comment) :
Some book crashes with a segfault, when it reaches the point when there are 1024 * 1024 = 1048576 text nodes.
There is a hardcoded limit of the number of 1024-nodes slots, which is 1024:

#define TNC_PART_COUNT 1024
#define TNC_PART_SHIFT 10
/// storage of ldomNode
class tinyNodeCollection
friend class ldomNode;
friend class tinyElement;
friend class ldomDocument;
int _textCount;
lUInt32 _textNextFree;
ldomNode * _textList[TNC_PART_COUNT];

I thought we could just increase it to 2048, but it segfaults elsewhere.

There are some other design choices (good for limiting resources usage) that limits this to 1024:

struct ldomNodeHandle {
unsigned _docIndex:8; // index in ldomNode::_documentInstances[MAX_DOCUMENT_INSTANCE_COUNT];
unsigned _dataIndex:24; // index of node in document's storage and type

dataIndex, which is the incremented_id << 4, then fails to be stored in 24 bits slots when it reaches 1048576:

(1024*1024) << 4 = 16777216
2**24 = 16777216

Increasing this 24 bit slot, or any other trick, would probably be too much work and too risky for a change. I think this will stay a limitation.

Crash with fatal error when max nodes limit reached
Instead of segfault (to ease discriminating bugs).
There is a 1024*1024 limit for the number of text nodes, and the same for
the number of element nodes. These can't easily be increased.

Frenzie approved these changes Mar 9, 2018

More clarity is always good.

@poire-z poire-z merged commit a4ab441 into koreader:master Mar 9, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed

@poire-z poire-z deleted the poire-z:fatalerror_on_max_nodes branch Mar 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment