Skip to content
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

badly formed tree input causes out of memory crash #3

Closed
chinchliff opened this issue Mar 12, 2013 · 7 comments
Closed

badly formed tree input causes out of memory crash #3

chinchliff opened this issue Mar 12, 2013 · 7 comments

Comments

@chinchliff
Copy link

If the last tree in the input treefile is not followed by a semicolon, the program will apparently keep reading until it completely fills the memory of the computer. I have crashed my 48GB RAM desktop several times doing this.

@josephwb
Copy link
Collaborator

Seems to occur in file tree_reader.cpp, line 65:

else if (nextChar == ';') {
keepGoing = false;
}

This is the only exit I can see. Should have a condition:

if (nextChar == null) {
Yell at user.
}

Better yet, as we discussed, perhaps deal with the length of the tree string.

int counter = 0;
int treeLength = tree.size();
bool semicolonEncountered = false;

while (counter < (treeLength - 1)) { // iterate through the characters in the tree string
Do stuff...
counter ++;
}
if (!semicolonEncountered) {
cout << "You messed up, yo." << endl;
exit(0);
}

@josephwb
Copy link
Collaborator

Noticed the exact same code is in treemachine, despite being in java. Java doesn't do the infinite loop thing when a semicolon is missing, but crashes with informative error.

@josephwb
Copy link
Collaborator

For what it is worth, I patched this in treemachine:

// pb is the newick tree string
if (pb.charAt(pb.length() - 1) != ';') {
    System.out.println("Tree is invalid: missing concluding semicolon. Exiting.");
    System.exit(1);
}

@blackrim
Copy link
Owner

look good. I will get this in treepl this weekend

On Wed, Mar 13, 2013 at 4:11 PM, Joseph W. Brown
notifications@github.comwrote:

I patched this in treemachinehttps://github.com/OpenTreeOfLife/treemachine/blob/master/src/main/java/jade/tree/TreeReader.java:

// pb is the newick tree string
if (pb.charAt(pb.length() - 1) != ';') {
System.out.println("Tree is invalid: missing concluding semicolon.
Exiting.");
System.exit(1);
}


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-14865561
.

@josephwb
Copy link
Collaborator

I've fixed this in a pull request I just sent.

@josephwb
Copy link
Collaborator

Okay, in pull request #9

@blackrim
Copy link
Owner

thanks

On Tue, Apr 15, 2014 at 8:07 AM, Joseph W. Brown
notifications@github.comwrote:

Okay, in pull request #9 #9


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-40473851
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants