TEOS-10 / GSW-R

R implementation of the Thermodynamic Equation Of Seawater - 2010 (TEOS-10)
http://teos-10.github.io/GSW-R/
Other
8 stars 5 forks source link

gsw_SA_from_SP() segfaults on NA for longitude or latitude #22

Closed dankelley closed 7 years ago

dankelley commented 7 years ago

Sample code

library(gsw)
print(gsw_SA_from_SP(SP=c(35, 35), p=c(100,100), longitude=c(-30,NA), latitude=c(45,30)))
print(gsw_CT_from_pt(c(35, NA), pt=c(10,11)))

yields

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

Traceback:
 1: .C("wrap_gsw_SA_from_SP", SP = as.double(l$SP), p = as.double(l$p),     longitude = as.double(l$longitude), latitude = as.double(l$latitude),     n = n, rval = double(n), NAOK = TRUE, package = "gsw")
 2: gsw_SA_from_SP(SP = c(35, 35), p = c(100, 100), longitude = c(-30,     NA), latitude = c(45, 30))
 3: print(gsw_SA_from_SP(SP = c(35, 35), p = c(100, 100), longitude = c(-30,     NA), latitude = c(45, 30)))
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault: 11
dankelley commented 7 years ago

I know where to fix this (src/wrappers.c near line 130, plus fixes for the other W macros nearby) and will likely fix it on the upcoming weekend.

dankelley commented 7 years ago

Fixed in the develop branch, commit bd900b3d5e7a1eccaaeec815a96faaad318e50ca