title: R segfaults when starting R by opening a source file
body: <p>My R.app (R version 3.3.2, R.app GUI 1.68 (7288) x86_64-apple-darwin13.4.0) on macOS Sierra is odd.</p>
  
  <p>When I start <code>R.app</code> by clicking the app icon, I have no problems.</p>
  
  <p>But if I start <code>R.app</code> by double-clicking a source file (e.g., <code>test.R</code>) in Finder.app or if I type <code>open test.R</code> in Terminal.app, I get a segfault error ("memory not mapped").</p>
  
  <pre><code> *** caught segfault ***
  address 0x18, cause 'memory not mapped'
  
  Possible actions:
  1: abort (with core dump, if enabled)
  2: normal R exit
  3: exit R without saving workspace
  4: exit R saving workspace
  &gt; 
  Selection: 
  </code></pre>
  
  <p>It is OK if <code>R.app</code> is already running when <code>test.R</code> is opened.</p>
  
  <p>When <code>R.app</code> segfaults, I am sometimes lucky to have control and can close the app normally. But at other times, <code>R.app</code> halts with the spinning wheel appearing, and I have to Force-Quit the app. After I force-quit <code>R.app</code>, the next time I start <code>R.app</code>, I am permanently stuck (with <code>R.app</code> halting trying to open <code>test.R</code> as soon as I restart <code>R.app</code>), in which case I solve the problem by starting <code>R</code> from <code>Terminal</code> by typing <code>/Applications/R.app/Contents/MacOS/R</code>.</p>
  
  <p>What would be the problem?</p>