Note: I posted this on Nabble before, but it keeps telling me that it has not been accepted by the mailing list. So this might be a duplicate.<div><br></div><div><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Hi together, </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">I recently encountered severe problems with R (see my post on stackoverflow here: </span><a href="http://stackoverflow.com/questions/8616862/r-terminates-with-error-message-this-application-has-requested-the-runtime-to-t" target="_top" rel="nofollow" link="external" style="font-size:13px;color:rgb(85,26,139);font-family:&#39;Open Sans&#39;;background-color:rgb(255,255,255)">http://stackoverflow.com/questions/8616862/r-terminates-with-error-message-this-application-has-requested-the-runtime-to-t</a><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">). Spending the whole day digging further into the problem, I was able to produce rather minimal code that crashes my RStudio session. I confirmed this on two different machines (see details at the end).  If I run this code in my Linux Terminal, I get the following error:</span></div>

<div><br></div><div><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> *** caught segfault *** </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">address (nil), cause &#39;unknown&#39; </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Traceback: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> 1: as.data.frame.Date(x[[i]], optional = TRUE) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> 2: as.data.frame(x[[i]], optional = TRUE) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> 3: data.frame(ID = rep(1:100, each = n/100), intTime = rep(1:(n/100),     times = 100), FYE = lDate1 + 1:n) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">So it looks like a similar problem  to caneff&#39;s problem: </span><a href="http://r.789695.n4.nabble.com/Random-segfaults-td4195472i20.html" target="_top" rel="nofollow" link="external" style="font-size:13px;color:rgb(85,26,139);font-family:&#39;Open Sans&#39;;background-color:rgb(255,255,255)">http://r.789695.n4.nabble.com/Random-segfaults-td4195472i20.html</a><br>

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">So my two questions are: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">1. Can you confirm this? (Sometimes, I have to run the code a couple of times to get R to crash) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">2. What is the cause? (Interestingly, I need to add the line DT[, reportDate := NA] to get the code breaking, although this line seems completely irrelevant for the further computations. For me, R closes when the last line is run.) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Rather minimal code: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">get_diff_month &lt;- function(actualDate, baseDate) { </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">  </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">  #Because data.table also has a month function </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">  return(month(actualDate) - month(baseDate) + 12*(year(actualDate) - year(baseDate))) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">} </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">library(data.table) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">n &lt;- 100000 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">lDate1 &lt;- as.Date(&quot;1jan1900&quot;, &quot;%d%b%Y&quot;)#dmy(&quot;1Jan1900&quot;) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">lDate2 &lt;- as.Date(&quot;1jan1901&quot;, &quot;%d%b%Y&quot;)#dmy(&quot;1Jan1901&quot;) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">df &lt;- data.frame(ID = rep(1:100, each=n/100), </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">                 intTime = rep(1:(n/100), times=100), </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">                 FYE=lDate1 + 1:n) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT &lt;- as.data.table(df) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT[rbinom(n, size=1, prob=0.05)==1, FYE:=NA] </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT[, reportDate := NA] #Bad line: comment it out and nothing breaks! </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT[, intFYE      := get_diff_month(FYE, as.Date(&quot;1jan1900&quot;, &quot;%d%b%Y&quot;))] </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">intDT &lt;- DT[ , list(FYE, intTime, ID)] </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">newDates &lt;- intDT[, intTime] - 1 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">intDT[, intTime := newDates] </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">#Set keys </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">key(DT)    &lt;- c(&quot;ID&quot;, &quot;intTime&quot;) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">key(intDT) &lt;- c(&quot;ID&quot;, &quot;intTime&quot;) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT &lt;- merge(DT, intDT, all.x=TRUE) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">DT[, intFYE_Next := get_diff_month(FYE.y, as.Date(&quot;1jan1900&quot;, &quot;%d%b%Y&quot;))] </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">sessionInfo() 1: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">R version 2.13.2 (2011-09-30) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Platform: x86_64-pc-linux-gnu (64-bit) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">locale: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=C             </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"> [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">attached base packages: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] stats     graphics  grDevices utils     datasets  methods   base     </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">other attached packages: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] data.table_1.7.7 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">loaded via a namespace (and not attached): </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] tools_2.13.2 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">sessionInfo() 2: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">R version 2.14.0 (2011-10-31) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Platform: x86_64-pc-mingw32/x64 (64-bit) </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">locale: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] C </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">attached base packages: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] stats     graphics  grDevices utils     datasets  methods   base     </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">other attached packages: </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] data.table_1.7.7 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">loaded via a namespace (and not attached): </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">[1] tools_2.14.0 </span><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)"><br style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">

<span style="font-family:&#39;Open Sans&#39;;font-size:13px;background-color:rgb(255,255,255)">Thanks Christoph</span><br clear="all"><div><br></div>-- <br>--------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>

<br>Christoph Jäckel (Dipl.-Kfm.)<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>Research Assistant<br>

<br>Chair for Financial Management and Capital Markets | Lehrstuhl für Finanzmanagement und Kapitalmärkte<br><br>TUM School of Management | Technische Universität München<br><br>Arcisstr. 21 | D-80333 München | Germany<br>

<br>Mailto: <a href="mailto:christoph.jaeckel@wi.tum.de" target="_blank">christoph.jaeckel@wi.tum.de</a> | Web: <a href="http://www.fm.wi.tum.de" target="_blank">www.fm.wi.tum.de</a><br><br>Phone: +49 89 289 25487 | Fax: +49 89 289 25488<br>

<br> <br><br>Head of Chair:<br><br>Univ.-Prof. Dr. Christoph Kaserer<br><br>----------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>

<br>E-Mail Disclaimer<br><br>Der Inhalt dieser E-Mail ist vertraulich und ausschliesslich<br>fuer den bezeichneten Adressaten bestimmt. Wenn Sie nicht<br>der vorgesehene Adressat dieser E-Mail oder dessen Vertreter<br>sein sollten, so beachten Sie bitte, dass jede Form der<br>

Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder<br>Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir<br>bitten Sie, sich in diesem Fall mit dem Absender der E-Mail<br>in Verbindung zu setzen.<br><br>The information contained in this email is confidential. It is<br>

intended solely for the addressee. Access to this email by<br>anyone else is unauthorized if you are not the intended<br>recipient, any form of disclosure, reproduction, distribution<br>or any action taken or refrained from in reliance on it, is<br>

prohibited and may be unlawful. Please notify the sender<br>immediately.<br>----------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>


</div>