title: .Internal(La_rs(x,FALSE)) crashes R after long (reproducible) script on windows only
body: <p>The <code>.Internal(La_rs(x,FALSE))</code> call inside of the <code>eigen</code> function used within <code>fields:::Krig.engine.default</code> causes my R console[1] to crash after it gets triggered during a huge script.</p>
  <p>I am sure that that's the line that's causing the detonation.  however, the same line does not crash on a fresh session using:</p>
  <pre><code>x &lt;- structure(c(0.00251355321405019, -0.000589785531216647, -0.000172411748626129, -0.000589785531217227, 0.000897505637785858, -0.000714600035538855, -0.000172411748626269, -0.000714600035538766, 0.00123946691634644), .Dim = c(3L, 3L))
  .Internal(La_rs(x,FALSE))
  </code></pre>
  <p>you can reproduce this console crash with the following three lines (takes about ten minutes):</p>
  <pre><code># install.packages( c(&quot;MonetDB.R&quot;, &quot;MonetDBLite&quot; , &quot;survey&quot; , &quot;SAScii&quot; , &quot;descr&quot; , &quot;downloader&quot; , &quot;digest&quot; , &quot;sas7bdat&quot; , &quot;R.utils&quot; ,&quot;survey&quot;,&quot;ggplot2&quot;,&quot;scales&quot;,&quot;mapproj&quot;,&quot;sqldf&quot;,&quot;maptools&quot;,&quot;raster&quot;,&quot;rgeos&quot;,&quot;stringr&quot;,&quot;plyr&quot;,&quot;mgcv&quot;,&quot;spatstat&quot;,&quot;rgeos&quot;) , repos=c(&quot;http://dev.monetdb.org/Assets/R/&quot;, &quot;http://cran.rstudio.com/&quot;))
  # path.to.7z &lt;- &quot;7za&quot;       # macintosh/unix users need to specify 7z
  #  setwd(&quot;C:/My Directory/&quot;)
  # warning: some large downloads
  downloader::source_url( &quot;https://raw.githubusercontent.com/davidbrae/swmap/8eecde1683efab65a7e27eb7c92e7967a98dc639/how%20to%20map%20the%20american%20community%20survey.R&quot; , prompt = FALSE )
  </code></pre>
  <p>sorry the example isn't more minimal, the crash disappeared when i removed different things..</p>
  <p><em>february 22nd 2016 edit:</em> even worse, when i try a script intended to trigger the crash on its own, it does not die!</p>
  <pre><code>downloader::source_url(&quot;https://gist.githubusercontent.com/ajdamico/0c256ed3a77d77eecfd6/raw/ce0570effd37c6384f2e27f1b38335078adcb49d/La_rs_bughunt.R&quot;,echo=T,prompt=F)
  </code></pre>
  <p>thanks!</p>
  <p>[1] R version 3.2.3 (2015-12-10) Platform: x86_64-w64-mingw32/x64 (64-bit)</p>
  <p>if i run the whole script at once, R crashes without any info in Rterm.exe.  but if i break the script up into two parts, R gives me this error:</p>
  <pre><code>&gt; x
                [,1]          [,2]          [,3]
  [1,]  0.0025135532 -0.0005897855 -0.0001724117
  [2,] -0.0005897855  0.0008975056 -0.0007146000
  [3,] -0.0001724117 -0.0007146000  0.0012394669
  &gt; .Internal(La_rs(x,TRUE))
  Error: 'a' must be a complex matrix
  </code></pre>
  <p>a bit more debugging info: it looks like the .Internal() function <code>La_rs</code> has been destroyed somehow?</p>
  <pre><code>&gt; debug::mtrace(.Internal(La_rs(x,TRUE)))
  Error in debug::mtrace(.Internal(La_rs(x, TRUE))) : 
    Dunno wot to do with .Internal(La_rs(x, TRUE))
  &gt; x
                [,1]          [,2]          [,3]
  [1,]  0.0025135532 -0.0005897855 -0.0001724117
  [2,] -0.0005897855  0.0008975056 -0.0007146000
  [3,] -0.0001724117 -0.0007146000  0.0012394669
  &gt; class(x)
  [1] &quot;matrix&quot;
  &gt; .Internal(La_rs(x,FALSE))
  Error: 'a' must be a complex matrix
  &gt; .Internal(La_rs(x,TRUE))
  Error: 'a' must be a complex matrix
  &gt; .Internal(La_rs(1,TRUE))
  Error: 'a' must be a complex matrix
  &gt; .Internal(La_rs(matrix(1,2,3,4),TRUE))
  Error: 'a' must be a complex matrix
  </code></pre>
  <hr />
  <p><em>february 21 2016 update:</em> i was able to reproduce this error (without R dying) on a second windows script.  here is the permanent link</p>
  <pre><code># install.packages( c( 'fields' , 'maps' , 'ggplot2' , 'raster' , 'sqldf' , 'rgeos' , 'rgdal' , 'sp' , 'digest' , 'ff' , 'descr' , 'SAScii' , 'stringr' , 'R.utils' , 'R.oo' , 'RCurl' , 'MonetDBLite' , 'MonetDB.R' , 'survey' , 'downloader' ) , repos=c(&quot;http://dev.monetdb.org/Assets/R/&quot;, &quot;http://cran.rstudio.com/&quot;))
  # setwd( &quot;S:/temp/PNAD&quot; )
  # warning: some large downloads
  downloader::source_url( &quot;https://raw.githubusercontent.com/davidbrae/swmap/4501e2c8927faaffa02c92d3e40d16beb44bca92/how%20to%20map%20the%20pesquisa%20nacional%20por%20amostra%20de%20domicilios.R&quot; , echo = TRUE , prompt = FALSE )
  </code></pre>
  <p>and here is what happens at the point of the error.  again <code>La_rs</code> appears corrupted.</p>
  <pre><code>&gt; for ( i in 1:4 ){
  + 
  +       this.krig.fit &lt;-
  +               Krig(
  +                       cbind( x$x , x$y ) ,
  +                       x[ , paste0( 'occcat' , i ) ] ,
  +                       weights = x[ , paste0( 'weigh .... [TRUNCATED] 
  Error in eigen(tempM, symmetric = TRUE) : 'a' must be a complex matrix
  In addition: There were 50 or more warnings (use warnings() to see the first 50)
  &gt; traceback()
  8: eigen(tempM, symmetric = TRUE)
  7: Krig.engine.default(out, verbose = verbose)
  6: Krig(cbind(x$x, x$y), x[, paste0(&quot;occcat&quot;, i)], weights = x[, 
         paste0(&quot;weight&quot;, i)]) at filee101515cee#676
  5: eval(expr, envir, enclos)
  4: eval(ei, envir)
  3: withVisible(eval(ei, envir))
  2: source(temp_file, ...)
  1: downloader::source_url(&quot;https://raw.githubusercontent.com/davidbrae/swmap/master/how%20to%20map%20the%20pesquisa%20nacional%20por%20amostra%20de%20domicilios.R&quot;, 
         echo = T, prompt = F)
  &gt; sessionInfo()
  R version 3.2.3 (2015-12-10)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1
  
  locale:
  [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  [5] LC_TIME=English_United States.1252    
  
  attached base packages:
  [1] tcltk     grid      stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
   [1] fields_8.3-6      maps_3.1.0        spam_1.3-0        ggplot2_2.0.0     raster_2.5-2     
   [6] sqldf_0.4-10      RSQLite_1.0.0     gsubfn_0.6-6      proto_0.3-10      rgeos_0.3-17     
  [11] rgdal_1.1-3       sp_1.2-2          digest_0.6.9      ff_2.2-13         bit_1.1-12       
  [16] descr_1.1.2       SAScii_1.0        stringr_1.0.0     R.utils_2.2.0     R.oo_1.19.0      
  [21] R.methodsS3_1.7.0 RCurl_1.95-4.6    bitops_1.0-6      MonetDBLite_0.2.0 MonetDB.R_1.0.1  
  [26] DBI_0.3.1         survey_3.30-3     downloader_0.4   
  
  loaded via a namespace (and not attached):
   [1] Rcpp_0.12.3      plyr_1.8.3       tools_3.2.3      gtable_0.1.2     lattice_0.20-33 
   [6] magrittr_1.5     scales_0.3.0     codetools_0.2-14 xtable_1.8-0     colorspace_1.2-6
  [11] stringi_1.0-1    munsell_0.4.2    chron_2.3-47    
  &gt; 
  </code></pre>
  <p><em>february 27th, 2016 edit: very similar bug, adding <code>gc()</code> in the middle of this script prevents the crash</em></p>
  <pre><code># account creation page
  # http://www.icpsr.umich.edu/rpxlogin?path=NACJD&amp;request_uri=https%3a%2f%2fwww.icpsr.umich.edu%2ficpsrweb%2fNACJD%2f
  your.username &lt;- 'email@address.com'
  your.password &lt;- 'some_password'
  
  setwd( &quot;C:/My Directory/NCVS_BUG/&quot; )
  library(downloader)
  source_url( &quot;https://gist.githubusercontent.com/ajdamico/4cd5f76aebbdaae5bc88/raw/1ae140e84aa82f1c12af297badad6d8c2c50f5a1/ncvs_bughunt.R&quot; , echo = TRUE , prompt = FALSE )
  </code></pre>