Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty column positions produce segfault in read_fwf() #511

Closed
jamesdunham opened this issue Aug 25, 2016 · 1 comment
Closed

empty column positions produce segfault in read_fwf() #511

jamesdunham opened this issue Aug 25, 2016 · 1 comment
Labels
bug an unexpected problem or unintended behavior read 📖

Comments

@jamesdunham
Copy link

I've found that read_fwf() will accept bad input in the form of numeric(0) column positions. This produces a segfault.

Are you able to replicate this?

library(readr)
sessionInfo()
# R version 3.3.0 (2016-05-03)
# Platform: x86_64-apple-darwin13.4.0 (64-bit)
# Running under: OS X 10.11.6 (El Capitan)
#
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
#
# other attached packages:
# [1] readr_1.0.0.9000
#
# loaded via a namespace (and not attached):
# [1] assertthat_0.1 tools_3.3.0    tibble_1.1     Rcpp_0.12.6   

txt = "foo\n"
pos = fwf_positions(start = numeric(0), end = numeric(0))
read_fwf(txt, pos)

#  *** caught segfault ***
# address 0xfffffffffffffffc, cause 'memory not mapped'
# 
# Traceback:
#  1: .Call("readr_guess_types_", PACKAGE = "readr", sourceSpec, tokenizerSpec,     locale_, n)
#  2: guess_types_(datasource, tokenizer, locale, n = n)
#  3: guess_types(ds, tokenizer, locale, n = n)
#  4: col_spec_standardise(file, skip = skip, n = guess_max, tokenizer = tokenizer,     locale = locale, col_names = col_positions$col_names, col_types = col_types,     drop_skipped_names = TRUE)
#  5: read_fwf(txt, pos)
# An irrecoverable exception occurred. R is aborting now ...

Thanks.

@hadley hadley added bug an unexpected problem or unintended behavior read 📖 labels Dec 22, 2016
@hadley
Copy link
Member

hadley commented Dec 22, 2016

Related to #534 - need better input validation

jimhester added a commit that referenced this issue Jan 23, 2017
@lock lock bot locked and limited conversation to collaborators Sep 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior read 📖
Projects
None yet
Development

No branches or pull requests

2 participants