jeffwong / pdist

Distance functions on subsets of matrices
7 stars 3 forks source link

pdist crashes if Y is an empty list #5

Open backlin opened 9 years ago

backlin commented 9 years ago

Running the following command will cause a segmentation fault and crash the R session:

pdist(matrix(0, 3, 3), list())

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .C("Rpdist", X.vec, Y.vec, nx, ny, p, distances = distances,     NAOK = T)
 2: pdist(matrix(1, 3, 3), list())

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

My quite unexhaustive debugging suggests that this only happens when Y=list() but that c(), NULL, data.frame() or list(1:3) are fine. The following also works:

pdist(list(), matrix(0, 3, 3))