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

Fread: possible segfault when reading a file with extra sep on out-of-sample row #2523

Closed
st-pasha opened this issue Dec 13, 2017 · 0 comments · Fixed by #2570
Closed

Fread: possible segfault when reading a file with extra sep on out-of-sample row #2523

st-pasha opened this issue Dec 13, 2017 · 0 comments · Fixed by #2570

Comments

@st-pasha
Copy link
Contributor

@st-pasha st-pasha commented Dec 13, 2017

Test file can be generated using the following python script:

nrows = 2100       # need >2000 in order to trigger nJumps==10
ncols = 1024 * 16  # "round" number increases probability that 
                   # `sizes` array will not be overallocated
row = ','.join(list('abcdefghijklmnop') * int(ncols / 16))
rows = [row] * nrows
rows[111] += ","
src = "\n".join(rows)
open("test.txt", "w").write(src)

Then

> for(b in 1:100){ fread("test.txt", header=F) -> DT }

 *** caught bus error ***
address 0x7fd839704e40, cause 'non-existent physical address'

The primary cause are the following lines in "TEPID" section of freadMain:

         else if (eol(&tch)) {
            int8_t thisSize = size[j];
            ((char **) targets)[thisSize] += thisSize;

Here j can be equal to ncol, which causes OOB access in array size, and even if that succeeds by accident, the retrieved value thisSize can be anything, causing OOB access on array targets.

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

Successfully merging a pull request may close this issue.

1 participant