Skip to content

parse_date() segfaults on invalid format #1151

Description

@sonicdoe

If a percent sign (%) is misplaced in parse_date()’s format specification, a segmentation fault is raised.

library(readr)
# Note this percent sign  ↓
parse_date("2020-11-17", "%%Y-%m-%d")

With R v4.0.3 and readr v1.4.0:

 *** caught segfault ***
address 0x20, cause 'memory not mapped'

Traceback:
 1: parse_vector_(x, collector, na = na, locale_ = locale, trim_ws = trim_ws)
 2: withCallingHandlers(expr, warning = function(w) if (inherits(w,     classes)) tryInvokeRestart("muffleWarning"))
 3: suppressWarnings(x)
 4: probs(x)
 5: n_problems(x)
 6: warn_problems(parse_vector_(x, collector, na = na, locale_ = locale,     trim_ws = trim_ws))
 7: parse_vector(x, col_date(format), na = na, locale = locale, trim_ws = trim_ws)
 8: parse_date("2020-11-17", "%%Y-%m-%d")

Activity

  1. jimhester commented on Nov 17, 2020

    @jimhester
    Collaborator

    Thanks for opening the issue, a clear bug that happened in the recent conversion. Should now be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions