2

This is probably a long shot, but is there any way of changing the C++ standard library used by R Shiny dynamically on OS X from libc++ to libstdc++ ?

The reason for this question is that I wanted to try out R Shiny but whenever I try any of the examples my R crashes:

> require(shiny)
Loading required package: shiny
> runExample("01_hello")
libc++abi.dylib: __cxa_guard_acquire detected deadlock
Abort trap: 6

Running from the R Gui I get more information (in the details) and I noticed an RcppExports.cpp call before crash. I have had issues with the libc++ (LLVM C++ standard library with C+11) versus the libstdc++ (GNU C++ standard library) before. Given that Rcpp requires the GNU library and the LLVM library is the default in Xcode 5, I suspect this to be the issue. Is there any way to change the default C++ library being loaded on Mac OS X (10.9.1) by R Shiny ?

Process:         R [23120]
Path:            /Applications/R.app/Contents/MacOS/R
Identifier:      org.R-project.R
Version:         R 3.0.2 GUI 1.62 Snow Leopard build (6558)
Code Type:       X86-64 (Native)
Parent Process:  launchd [250]
Responsible:     R [23120]
User ID:         501
Date/Time:       2014-02-06 14:55:39.785 +0000
OS Version:      Mac OS X 10.9.1 (13B42)
Report Version:  11
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called
__cxa_guard_acquire detected deadlock

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff9a5e4866 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff8e92135c pthread_kill + 92
2   libsystem_c.dylib               0x00007fff980bebba abort + 125
3   libc++abi.dylib                 0x00007fff925a1141 abort_message + 257
4   libc++abi.dylib                 0x00007fff925c428e __cxa_guard_acquire + 192
5   httpuv.so                       0x000000010860500b Rcpp::RNGScope::RNGScope() + 33 (routines.h:74)
6   httpuv.so                       0x00000001086040d6 httpuv_makeTcpServer + 54 (RcppExports.cpp:32)
7   libR.dylib                      0x00000001001831ce do_dotcall + 1230 (dotcode.c:634)
8   libR.dylib                      0x00000001001ab2ad Rf_eval + 1181 (eval.c:642)
9   libR.dylib                      0x00000001001b7a70 do_begin + 384 (eval.c:1573)
10  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
11  libR.dylib                      0x00000001001b535e Rf_applyClosure + 1422 (eval.c:1019)
12  libR.dylib                      0x00000001001ab34e Rf_eval + 1342 (eval.c:661)
13  libR.dylib                      0x00000001001b7717 do_set + 343 (eval.c:1902)
14  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
15  libR.dylib                      0x00000001001b7a70 do_begin + 384 (eval.c:1573)
16  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
17  libR.dylib                      0x00000001001b535e Rf_applyClosure + 1422 (eval.c:1019)
18  libR.dylib                      0x00000001001ab34e Rf_eval + 1342 (eval.c:661)
19  libR.dylib                      0x00000001001b4b03 forcePromise + 147 (eval.c:464)
20  libR.dylib                      0x00000001001b5624 getvar + 452 (eval.c:3525)
...
65  libR.dylib                      0x00000001001ab34e Rf_eval + 1342 (eval.c:661)
66  libR.dylib                      0x00000001001b7a70 do_begin + 384 (eval.c:1573)
67  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
68  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
69  libR.dylib                      0x00000001001b7a70 do_begin + 384 (eval.c:1573)
70  libR.dylib                      0x00000001001ab11f Rf_eval + 783 (eval.c:614)
71  libR.dylib                      0x00000001001b535e Rf_applyClosure + 1422 (eval.c:1019)
72  libR.dylib                      0x00000001001ab34e Rf_eval + 1342 (eval.c:661)
73  libR.dylib                      0x00000001001d8b9a R_ReplDLLdo1 + 458 (main.c:363)
74  org.R-project.R                 0x000000010001f38e run_REngineRmainloop + 302
75  org.R-project.R                 0x000000010001379c -[REngine runREPL] + 124
76  org.R-project.R                 0x0000000100001b7e main + 910
77  org.R-project.R                 0x00000001000017e4 start + 52

Thread 1:
...

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff7d09a310  rcx: 0x00007fff5fbf84d8  rdx: 0x0000000000000000
  rdi: 0x0000000000000707  rsi: 0x0000000000000006  rbp: 0x00007fff5fbf8500  rsp: 0x00007fff5fbf84d8
   r8: 0x00007fff925c7635   r9: 0x00007fff980e6900  r10: 0x0000000008000000  r11: 0x0000000000000206
  r12: 0x00007fff5fbf8660  r13: 0x0000000107d76548  r14: 0x0000000000000006  r15: 0x00007fff5fbf8540
  rip: 0x00007fff9a5e4866  rfl: 0x0000000000000206  cr2: 0x0000000100333fd4

Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133
Community
  • 1
  • 1
crogg01
  • 2,446
  • 15
  • 35
  • How did you install R and shiny? – hadley Feb 06 '14 at 16:17
  • I installed R from the `pkg` on [the r-project site](http://www.stats.bris.ac.uk/R/) and Shiny using `install.packages("shiny")`. I am thinking my best shot is probably to build Rcpp from source with `libstdc++`. – crogg01 Feb 06 '14 at 17:11
  • 1
    Have you recently upgraded to mavericks? If so, make sure you have the latest xcode, and re-install Rcpp from source. – hadley Feb 06 '14 at 18:09
  • However you install Rcpp, make sure httpuv is installed the same way (i.e. build both from source or both from CRAN). And restart your R session after installing. – Joe Cheng Feb 06 '14 at 18:29

1 Answers1

3

Seeing as I ran into the exact same problem - the comments from hadley and Joe worked for me with MacOSX Mavericks (apologies for stealing the answer, but I don't have enough reputation to add a comment...)

  1. Install latest xcode
  2. (Re)install Rcpp
  3. Restart R
JohnSG
  • 1,567
  • 14
  • 26