From f35bcb3dfafc7bd6123a303dc665f3573d8992ca Mon Sep 17 00:00:00 2001 From: Pasha Stetsenko Date: Fri, 7 Jul 2017 20:45:41 -0700 Subject: [PATCH] Fix race condition that caused fread to occasionally read the data only partially. Closes #2260 --- src/fread.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/fread.c b/src/fread.c index a9a3884923..ef5009591b 100644 --- a/src/fread.c +++ b/src/fread.c @@ -1446,12 +1446,12 @@ int freadMain(freadMainArgs _args) { nJumps = 1; } size_t initialBuffRows = allocnrow / (size_t)nJumps; - + // Catch initialBuffRows==0 when max_nrows is small, seg fault #2243 // Rather than 10, maybe 1 would work too but then 1.5 grow factor * 1 would still be 1. This clamp // should only engage when max_nrows is supplied, and supplied small too, so doesn't matter too much. if (initialBuffRows < 10) initialBuffRows = 10; - + if (initialBuffRows > INT32_MAX) STOP("Buffer size %lld is too large\n", initialBuffRows); nth = imin(nJumps, nth); @@ -1478,7 +1478,8 @@ int freadMain(freadMainArgs _args) { (rowSize1 && !myBuff1) || !myBuff0) stopTeam = true; #pragma omp for ordered schedule(dynamic) reduction(+:thNextGoodLine,thRead,thPush) - for (int jump=0; jump=nJumps || stopTeam) continue; // nothing left to do. This jump was the dummy extra one. const char *tch = pos + (size_t)jump*chunkBytes; const char *nextJump = jump