From jwlong at llnl.gov  Fri Mar  6 23:17:47 2009
From: jwlong at llnl.gov (Jeff Long)
Date: Fri, 6 Mar 2009 14:17:47 -0800
Subject: [Rd] Fix for foreign package segfault on Solaris 10 Intel
Message-ID: <p06230977c5d7517b8dc8@[134.9.94.26]>

Like a couple of other posters in the past year, I was seeing R 2.8.1 
segfault in the foreign package on my Solaris 10 Intel system:

       > library(foreign)

       *** caught segfault ***
       address fe1d5c70, cause 'invalid permissions'

       Traceback:
            1: .C("spss_init", PACKAGE = "foreign")
            2: fun(...)

This happened whether I built with gcc3, gcc4, or SunStudio 12.

Using pstack I found that the code was crashing in avl_create(). 
Using truss I found that identically named functions in the Solaris 
/lib/libavl.so.1 library were being used instead of the AVL functions 
provided in avl.c in the foreign package. To verify, I replaced all 
of the "avl_" and "AVL_" patterns in foreign/src/*.[ch] with "ravl_" 
and "RAVL_" respectively. Once I made this change, loading the 
foreign package caused no further problems.

An alternative workaround was a hack involving symlinks and 
LD_LIBRARY_PATH, but that was not satisfactory. Since the foreign avl 
functions are incompatible with the ones provided by the standard Sun 
library, this approach has other potential gotchas.

FYI.

Jeff



[Rd] Fix for foreign package segfault on Solaris 10 Intel
Jeff Long