Skip to content

fread causing r to crash when assigning to variable in R 4.6.1 #7811

Description

@itendswells

Trying to save the output of fread() in a variable causes R to crash with exit code -1073741819. Using fread() on its own works fine, it's only when it is assigned to a variable that the issue occurs. This bug happens with R 4.6.1, but does not happen with R 4.5.3.

Minimal reproducible example

# works fine
data.table::fread("https://raw.githubusercontent.com/tidyverse/dplyr/refs/heads/main/data-raw/starwars.csv", verbose = T)

# crashes
dt <- data.table::fread("https://raw.githubusercontent.com/tidyverse/dplyr/refs/heads/main/data-raw/starwars.csv", verbose = T)

Output from line that causes the crash

  OpenMP version (_OPENMP)       201511
  omp_get_num_procs()            16
  R_DATATABLE_NUM_PROCS_PERCENT  unset (default 50)
  R_DATATABLE_NUM_THREADS        unset
  R_DATATABLE_THROTTLE           unset (default 1024)
  omp_get_thread_limit()         2147483647
  omp_get_max_threads()          16
  OMP_THREAD_LIMIT               unset
  OMP_NUM_THREADS                unset
  RestoreAfterFork               true
  data.table is using 8 threads with throttle==1024. See ?setDTthreads.
trying URL '[https://raw.githubusercontent.com/tidyverse/dplyr/refs/heads/main/data-raw/starwars.csv](vscode-file://vscode-app/c:/Program%20Files/Positron/resources/app/out/vs/code/electron-browser/workbench/workbench.html#)'
Content type 'text/plain; charset=utf-8' length 10579 bytes (10 KB)
downloaded 10 KB

freadR.c has been passed a filename: C:\Users\dwells\AppData\Local\Temp\Rtmpiasfpl\file2af855f84f3d.csv
[01] Check arguments
  Using 8 threads (omp_get_max_threads()=16, nth=8)
  NAstrings = [<<NA>>]
  None of the NAstrings look like numbers.
  show progress = 1
  0/1 column will be read as integer
  Y/N column will be read as character
[02] Opening the file
  Opening file C:\Users\dwells\AppData\Local\Temp\Rtmpiasfpl\file2af855f84f3d.csv
  File opened, size = 10.33KiB (10579 bytes).
  Memory mapped ok
[03] Detect and skip BOM
[04] Arrange mmap to be \0 terminated
  \n has been found in the input (counts: 0 \r by themselves vs 88 [\r]*\n) and different lines can end with different line endings (e.g. mixed \n and \r\n in one file). This is common and ideal.
[05] Skipping initial rows if needed
  Positioned on line 1 starting: <<name,height,mass,hair_color,sk>>
[06] Detect separator, quoting rule, and ncolumns
  Detecting sep automatically ...
  sep=','  with 88 lines of 14 fields using quote rule 0
  Detected 14 columns on line 1. This line is either column names or first data row. Line starts as: <<name,height,mass,hair_color,sk>>
  Quote rule picked = 0
  fill=false and the most number of columns found is 14
[07] Detect column types, dec, good nrow estimate and whether first row is column names
  sep=',' so dec set to '.'
  Number of sampling jump points = 1 because (10578 bytes from row 1 to eof) / (2 * 10578 jump0size) == 0
  Type codes (jump 000)    : E79EEE9EEEEEEE  Quote rule 0
  'header' determined to be true due to column 2 containing a string on row 1 and a lower type (int32) in the rest of the 87 sample rows
  All rows were sampled since file is small so we know nrow=87 exactly
[08] Assign column names
[09] Apply user overrides on column types
  After 0 type and 0 drop user overrides : E79EEE9EEEEEEE
[10] Allocate memory for the datatable
  Allocating 14 column slots (14 - 0 dropped) with 87 rows
[11] Read the data
  jumps=[0..1), chunk_size=1048576, total_size=10464
Read 87 rows x 14 columns from 10.33KiB (10579 bytes) file in 00:00.001 wall clock time
[12] Finalizing the datatable
  Type counts:
         1 : int32     '7'
         2 : float64   '9'
        11 : string    'E'
=============================
   0.001s ( 50%) Memory map 0.000GiB file
   0.000s ( 35%) sep=',' ncol=14 and header detection
   0.000s (  3%) Column type detection using 87 sample rows
   0.000s (  3%) Allocation of 87 rows x 14 cols (0.000GiB) of which 87 (100%) rows used
   0.000s (  9%) Reading 1 chunks (0 swept) of 1.000MiB (each chunk 87 rows) using 1 threads
   +    0.000s (  2%) Parse to row-major thread buffers (grown 0 times)
   +    0.000s (  5%) Transpose
   +    0.000s (  3%) Waiting
   0.000s (  0%) Rereading 0 columns due to out-of-sample type exceptions
   0.001s        Total
R 4.6.1 exited unexpectedly: exit code -1073741819

Output of sessionInfo()

R version 4.6.1 (2026-06-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default
  LAPACK version 3.12.1

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.6.1 tools_4.6.1  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions