traversc/qs

Uncaught exception in a worker thread crashes R

Closed this issue · 1 comments

thudec commented

When using qs in a single-threaded mode, any exception is caught and converted to an R error. However, if an exception is thrown in a multi-threaded mode, it is uncaught and causes R to crash.

# Create a corrupted qs file
qs::qsave(1:100000, "file.qs", preset="high")
data <- readBin("file.qs", "raw", 1000)
data <- head(data, -1)
writeBin(data, "corrupted.qs")

# Single-threaded call produces an error, as expected
try(qs::qread("corrupted.qs", nthreads = 1))
# Error in qs::qread("corrupted.qs", nthreads = 1) :
#   zstd decompression error

# Multi-threaded call crashes the R session instead of producing an error
try(qs::qread("corrupted.qs", nthreads = 2))
# terminate called after throwing an instance of 'std::runtime_error'
#   what():  zstd decompression error
# Aborted

Hi, you are right but its not simple to catch all possible errors. This is one thing I am trying to improve in https://github.com/traversc/qs2