Skip to content
Prev 11825 / 15075 Next

R segfault at startup, causing R crash

After playing around with R.app for a bit, I was able to get myself
into a state where R.app was either dying or hanging on startup. I did
the following:

   1. Open R.app,
   2. Open a new R document (using the icon in the top menu bar --
'Create a new, empty document in the editor' ),
   3. Write and execute some code -- in my case, 'x <- 1; print(x)',
executed with Cmd + Enter,
   4. (optionally) Repeat steps 2 and 3, creating new documents and
executing more code,
   5. Focus a different application,
   6. Attempt to open an R document (using the menu bar again --
'Source script or load data in R',
   7. Observe that R.app is now hanging.

Note that if you run these repro steps, you may see R segfault / die
on startup (although in some cases all was fine). Note that step 5 is
necessary (IIUC) to force R.app to attempt to save the application
state.

It looks like R.app stores session state in the folder

    ~/Library/Saved Application State/org.R-project.R.savedState

My hypothesis at this point is that this saved state is somehow
getting corrupted. Removing that folder seems to resolve any startup
crashes I see.

As for the 'Open File' dialog hang, here's what I believe are the
relevant bits of an lldb stack trace I see:

 * frame #0: 0x00007fffce2a7cba libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fffce390f6a
libsystem_pthread.dylib`_pthread_mutex_lock_wait + 100
    frame #2: 0x00007fffc573faee
FinderKit`+[FI_TFloatingInputWindowController singleton] + 34
    frame #3: 0x00007fffc57edd5b FinderKit`-[FI_TBrowserTableView
inputContext] + 29
    frame #4: 0x00007fffb6d397dc AppKit`+[NSTextInputContext
currentInputContext] + 145
    frame #5: 0x00007fffb6e7a272 AppKit`+[_NSAutomaticFocusRing
setActiveFirstResponderChanged] + 37
    frame #6: 0x00007fffb6e7a1d9
AppKit`___NSPostActiveFirstResponderChanged_block_invoke + 29
    frame #7: 0x00007fffb90cdec7
CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
+ 23
    frame #8: 0x00007fffb90cde37 CoreFoundation`__CFRunLoopDoObservers + 391
    frame #9: 0x00007fffb90aead9 CoreFoundation`__CFRunLoopRun + 873
    frame #10: 0x00007fffb90ae514 CoreFoundation`CFRunLoopRunSpecific + 420
    frame #11: 0x00007fffbaaabcb2 Foundation`-[NSRunLoop(NSRunLoop)
runMode:beforeDate:] + 277
    frame #12: 0x000000010b21f43e R`-[RDocumentWinCtrl
setStatusLineText:](self=0x00006180001e7c00,
_cmd="setStatusLineText:", text=@"print(x, ...)") + 910 at
RDocumentWinCtrl.m:465
    frame #13: 0x000000010b21f03d R`-[RDocumentWinCtrl
RDocumentDidResize:](self=0x00006180001e7c00,_cmd="RDocumentDidResize:",
notification=@"NSWindowDidResizeNotification") + 77 at
RDocumentWinCtrl.m:431

with context from frame 12:

frame #12: 0x000000010b21f43e R`-[RDocumentWinCtrl
setStatusLineText:](self=0x00006180001e7c00,
_cmd="setStatusLineText:", text=@"print(x, ...)") + 910 at
RDocumentWinCtrl.m:465
   462          [statusLine setStringValue:text];
   463          [statusLine setNeedsDisplay:YES];
   464          // Run NSDefaultRunLoopMode to allow to update status line
-> 465          [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
   466
beforeDate:[NSDate distantPast]];
   467
   468  }

Hopefully this helps...

Best,
Kevin

---

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
macOS Sierra -- Version 10.12.1
On Sat, Nov 5, 2016 at 5:08 PM, Kevin Ushey <kevinushey at gmail.com> wrote: