Skip to content

Segfault with ddply (plyr 1.8.1) #214

lionel- opened this Issue May 10, 2014 · 5 comments

2 participants

lionel- commented May 10, 2014

I was trying to modify position_dodge in ggplot2 when I got R crashing with a segfault.
I tracked it down to a ddply call. It occurs when you fail to correctly pass the arguments of the "strategy" function.

Steps to reproduce:

strategy <- function(df, height) {
  n <- length(unique(df$group))
  if (n == 1) return(df)

  if (!all(c("ymin", "ymax") %in% names(df))) {
      df$ymin <- df$y
      df$ymax <- df$y

  d_width <- max(df$ymax - df$ymin)
  diff <- height - d_width

  # Have a new group index from 1 to number of groups.
  # This might be needed if the group numbers in this set don't include all of 1:n
  groupidx <- match(df$group, sort(unique(df$group)))

  # Find the center for each group, then use that to calculate xmin and xmax
  df$y <- df$y + height * ((groupidx - 0.5)/n - 0.5)
  df$ymin <- df$y - d_width / n / 2
  df$ymax <- df$y + d_width / n / 2


test <- data.frame(x = letters[1:4], y = 1:4)
ddply(test, "x", strategy)
lionel- commented May 11, 2014

Is it reproducible by someone else?

I got another ddply-related segfault, using ggplot2 interactively (simple histogram but data input was messy). Maybe something is broken in my R installation (R 3.1.0, Snow Leopard build, which I run on Mavericks because rjags does not work with the Mavericks build).

lionel- commented May 11, 2014

I had another segfault with dplyr::summarize fed into ddply. When I specified plyr::summarize explicitely, no segfaut occurred.

With plyr::summarize, I obtained

Error: Results must have the same dimensions.

With dplyr::summarize, it segfaulted.
The same segfault message occurs everytime (including the previous errors I reported):

 *** caught segfault ***
address 0xfffffffffffffff8, cause 'memory not mapped'
lionel- commented May 13, 2014

I reinstalled plyr from github and I have no problem anymore. I think it's the same version as plyr in CRAN so I don't know what was the problem.

Anyway, I'm closing this.

@lionel- lionel- closed this May 13, 2014
mohitr commented Aug 24, 2015

getting same error again and again and reproducible also.

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

1: row.names(x)
2: write.table(y, file = "y.csv", col.names = NA, sep = ",", dec = ".", qmethod = "double")
3: eval(expr, envir, enclos)
4: eval(expr, p)
5: eval.parent(Call)
6: write.csv(y, file = "y.csv")

@lionel- by any chance you were able to figure out reason for this ?

lionel- commented Aug 24, 2015

@mohitr sorry, I don't remember. I guess you tried upgrading R and reinstalling packages?

your traceback is weird, I don't see any plyr command in it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.