segfault with split_indices when n < number of groups #104

Closed
wch opened this Issue Oct 15, 2012 · 3 comments

Projects

None yet

2 participants

@wch
Collaborator
wch commented Oct 15, 2012

Examples:

# OK
plyr:::split_indices(as.integer(c(1,2)), 2)
# [[1]]
# [1] 1
#
# [[2]]
# [1] 2


plyr:::split_indices(as.integer(c(1,2)), 1)
#  *** caught segfault ***
# address 0x2000000d, cause 'memory not mapped'
#
# Traceback:
#  1: .Call("split_indices", group, as.integer(n))
#  2: plyr:::split_indices(as.integer(c(1, 2)), 1)
#
# Possible actions:
#1: abort (with core dump, if enabled)
#2: normal R exit
#3: exit R without saving workspace
#4: exit R saving workspace

Owner
hadley commented Oct 15, 2012

Yes - so don't call it with too few groups ;) Where's this a problem?

Collaborator
wch commented Oct 16, 2012

It's a problem when you're experimenting with split_indices to figure out what it does. :)

Owner
hadley commented Oct 16, 2012

Haha, ok. It shouldn't be too hard to throw an error at the c-level if an index is greater than the max.

@hadley hadley closed this in 73c8ed2 Oct 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment