Skip to content

[R][C++] segfault when writing to ParquetFileWriter after closing #37969

@amoeba

Description

@amoeba

Describe the bug, including details regarding any error messages, version, and platform.

Writing to a closed writer causes a segfault rather than an error. I ran into this while testing something unrelated, evaluating portions of a larger script in a REPL. Writing to a closed output errors as expected so the key here is writer$Close() and the subsequent writer$WriteTable call:

library(arrow)

outfile <- tempfile(fileext = ".parquet")
sink <- FileOutputStream$create(outfile)

my_schema <- schema(letters = string())
writer <- ParquetFileWriter$create(
  schema = my_schema,
  sink,
  properties = ParquetWriterProperties$create(
    column_names = names(my_schema),
    compression = arrow:::default_parquet_compression()
  )
)
tbl_arrow <- as_arrow_table(data.frame(letters=LETTERS), schema = my_schema)
writer$WriteTable(tbl_arrow, chunk_size = 1)

writer$Close()
sink$close()

tbl_arrow <- as_arrow_table(data.frame(letters=LETTERS), schema = my_schema)
writer$WriteTable(tbl_arrow, chunk_size = 1)

Result:

 *** caught segfault ***
address 0x0, cause 'invalid permissions'

Traceback:
 1: parquet___arrow___FileWriter__WriteTable(self, table, chunk_size)
 2: writer$WriteTable(tbl_arrow, chunk_size = 1)
An irrecoverable exception occurred. R is aborting now ...
fish: Job 1, 'Rscript arrow_memorypool_crashe…' terminated by signal SIGSEGV (Address boundary error)
  • OS/arch: macOS 14.0 (Sonoma), aarch64 (M2)
  • R: 4.3.1
  • arrow version: 13.0.0.1

Component(s)

R

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions