lfe icon indicating copy to clipboard operation
lfe copied to clipboard

Segfault when using `demeanlist`

Open mattblackwell opened this issue 5 years ago • 1 comments

Thanks for writing lfe, it's really great! One issue that I've found is that the function demeanlist() appears to be fairly sensitive to the way that the factors are specified, which can lead to a segfault. Here is a MWE:

library(lfe)
mm <- matrix(1:10, nrow = 20, ncol = 3)
ff <- rep(1:4, each = 5)

## works
out <- demeanlist(mtx = mm, fl = list(factor(ff)))

## segfault
out <- demeanlist(mtx = mm, fl = list(ff))

## segfault
out <- demeanlist(mtx = mm, fl = factor(ff))

Either of the latter two calls leads to the follow:

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

Traceback:
 1: .Call(C_demeanlist, mtx = mm, fl = .fl, icpt = 0L, eps = getOption("lfe.eps"),     threads = getOption("lfe.threads"), progress = getOption("lfe.pint"),     accel = getOption("lfe.accel"), means = FALSE, weights = NULL,     scale = TRUE, attrs = NULL)
 2: eval(as.call(c(list(quote(.Call), quote(C_demeanlist)), ff)),     env)
 3: eval(as.call(c(list(quote(.Call), quote(C_demeanlist)), ff)),     env)
 4: demeanlist(mtx = mm, fl = list(ff))

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

It might be worthwhile to add checks for the fl argument so that demeanlist exits more gracefully under these conditions.

mattblackwell avatar Jun 21 '19 14:06 mattblackwell

Whoops,

thanks, I'll have a look at it.

On Fri, Jun 21, 2019 at 4:27 PM +0200, "Matthew Blackwell" [email protected] wrote:

Thanks for writing lfe, it's really great! One issue that I've found is that the function demeanlist() appears to be fairly sensitive to the way that the factors are specified, which can lead to a segfault. Here is a MWE: library(lfe) mm <- matrix(1:10, nrow = 20, ncol = 3) ff <- rep(1:4, each = 5)

works

out <- demeanlist(mtx = mm, fl = list(factor(ff)))

segfault

out <- demeanlist(mtx = mm, fl = list(ff))

segfault

out <- demeanlist(mtx = mm, fl = factor(ff))

Either of the latter two calls leads to the follow: *** caught segfault *** address 0x0, cause 'memory not mapped'

Traceback: 1: .Call(C_demeanlist, mtx = mm, fl = .fl, icpt = 0L, eps = getOption("lfe.eps"), threads = getOption("lfe.threads"), progress = getOption("lfe.pint"), accel = getOption("lfe.accel"), means = FALSE, weights = NULL, scale = TRUE, attrs = NULL) 2: eval(as.call(c(list(quote(.Call), quote(C_demeanlist)), ff)), env) 3: eval(as.call(c(list(quote(.Call), quote(C_demeanlist)), ff)), env) 4: demeanlist(mtx = mm, fl = list(ff))

Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace

It might be worthwhile to add checks for the fl argument so that demeanlist exits more gracefully under these conditions.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sgaure avatar Jun 21 '19 15:06 sgaure