fwrite crashes when a long line is encountered out of sample

Open
#3,289 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by running the provided R MRE and observe the verbose fwrite failure with lines exceeding the default 8MB buffer. Trace the fwrite implementation's handling of long or out-of-sample lines, then add a regression test covering the reproduced input. Done means fwrite writes the data without crashing.

Written by the indexing model from the issue text.

Description

fwrite segfault

MRE:

require(data.table)
DT = data.table(A=rep('foo', 10000))
DT[1111, A:=paste(rep('b',1e7), collapse='')]
DT[1112, A:=paste(rep('b',1e7), collapse='')]
fwrite(DT, 'temp.csv', verbose=TRUE)

For this error to occur, a single line has to be over 8MB (the default buffer's size). Or multiple lines (out of sample) have to have their total length over 8MB. Overall, the likelihood is quite rare

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.