<div dir="ltr">Hi Tim,<div><br></div><div>Thanks for the idea. I removed all the RProgress calls from the C++ code underlying the package, and there are no more crashed on Windows with antivirus software. Mysterious as to the details, but a good enough solution for me for now. Thanks!</div><div><br></div><div>Ben</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 1, 2017 at 4:37 PM, Tim Keitt <span dir="ltr"><<a href="mailto:tkeitt@utexas.edu" target="_blank">tkeitt@utexas.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Ben,<div><br></div><div>I wonder if the RProgress could be triggering something. It does some thread manipulation if I recall. If the code does not evoke any warnings from valgrind, that is the place I would look next. You could also ask your reporters to run R in a debugger while triggering the fault.</div><div><br></div><div>THK</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_-654858193824412751gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div></div></div>
<br><div class="gmail_quote"><div><div class="h5">On Wed, Nov 1, 2017 at 10:47 AM, Benjamin Blonder <span dir="ltr"><<a href="mailto:benjamin.blonder@ouce.ox.ac.uk" target="_blank">benjamin.blonder@ouce.ox.ac.<wbr>uk</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div style="font-size:12.800000190734863px">I am writing with a very puzzling crash issue I have been unable to resolve myself. It concerns my hypervolume R package, which uses Rcpp to call some custom functions to build and evaluate a k-d tree data structure. Everything has been working fine for several versions of the package, and the package passes the CRAN tests.</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">The complication is on Windows. On a Windows 7/8/10 install, calling functions via Rstudio, the package runs just fine. When using Windows Rgui/Rscript, if antivirus software (e.g. Sophos or McAfee) is NOT installed, the package also runs just fine. However on Windows with antivirus and the Rgui/Rscript program, the package repeatably crashes the entire program. </div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">A minimally reproducible example is below:</div><div style="font-size:12.800000190734863px"><font face="monospace, monospace"><br></font></div><div style="font-size:12.800000190734863px"><font face="monospace, monospace" color="#ff0000">library(hypervolume)</font><div><font face="monospace, monospace" color="#ff0000">data(iris)</font></div><div><font face="monospace, monospace" color="#ff0000">hv = hypervolume_svm(iris[,1:2])</font></div><div><br></div><div>On a debug trace, the problem occurs when hypervolume_svm() eventually internally calls kdtree_ball_query_multip<wbr>le(), which is just a wrapper for an Rcpp call to a C++ function (in the package's src/convert.cpp):</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">SEXP kdtree_ball_query_multiple(SEX<wbr>P tr, SEXP ptlist, SEXP nr, SEXP nc, SEXP r, SEXP verb)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">{</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  XPtr<KDTree> tree = as<XPtr<KDTree> >(tr);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures"> nrow = as<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures">>(nr);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures"> ncol = as<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures">>(nc);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  NumericVector data(ptlist);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">double</span><span style="font-variant-ligatures:no-common-ligatures"> radius = as<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">double</span><span style="font-variant-ligatures:no-common-ligatures">>(r);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">bool</span><span style="font-variant-ligatures:no-common-ligatures"> verbose = as<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures">>(verb);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  vector<vector< </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">double</span><span style="font-variant-ligatures:no-common-ligatures"> > > dataMatrix</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    = convertMatrixToVector(data.beg<wbr>in(), nrow, ncol);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  vector<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures">> finalCounts;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">if</span><span style="font-variant-ligatures:no-common-ligatures"> (ncol != tree->ndims())</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">throw</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(length_error(</span><span style="font-variant-ligatures:no-common-ligatures">"Points not same dimensionality as data in kdtree"</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">));  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  }</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  RProgress::RProgress pb(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"[:bar]"</span><span style="font-variant-ligatures:no-common-ligatures">, nrow);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">if</span><span style="font-variant-ligatures:no-common-ligatures"> (verbose==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    Rcpp::Rcout << </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"Ball query... \n"</span><span style="font-variant-ligatures:no-common-ligatures">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    pb.tick(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span><span style="font-variant-ligatures:no-common-ligatures">);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  }</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">for</span><span style="font-variant-ligatures:no-common-ligatures"> (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures"> i=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span><span style="font-variant-ligatures:no-common-ligatures">; i<nrow; i++)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    vector<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">int</span><span style="font-variant-ligatures:no-common-ligatures">> thisIndices;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    vector<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">double</span><span style="font-variant-ligatures:no-common-ligatures">> thisDistances;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    vector<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">double</span><span style="font-variant-ligatures:no-common-ligatures">> thisPoint = dataMatrix[i];</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    tree->ball_query(thisPoint, radius, thisIndices, thisDistances);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures">// store the number of points within the ball for each point</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    finalCounts.push_back(thisIndi<wbr>ces.size());</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">if</span><span style="font-variant-ligatures:no-common-ligatures"> (i%</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">10</span><span style="font-variant-ligatures:no-common-ligatures">==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span><span style="font-variant-ligatures:no-common-ligatures"> && verbose==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">      pb.update(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1.0</span><span style="font-variant-ligatures:no-common-ligatures">*(i+</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures">)/nrow);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    }</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">    </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  }</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">if</span><span style="font-variant-ligatures:no-common-ligatures"> (verbose==</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    Rcpp::Rcout << </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"\ndone.\n"</span><span style="font-variant-ligatures:no-common-ligatures">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  }</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  pb.update(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures">);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">return</span><span style="font-variant-ligatures:no-common-ligatures">(wrap(finalCounts));</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></p></div><div><br></div><div>As noted above, that same code works just fine on other platforms and has worked well on Windows in other package versions too, with or without antivirus. </div><div><br></div><div>Does anyone have any ideas for what is going on, or how to fix it? Are there any other reports of antivirus programs causing this kind of crash, or of Rcpp issues between Rstudio and Rgui or Rscript?</div><div><br></div><div>The problem is hard for me to debug as I only get user error reports and have limited access to Windows machines with antivirus software - my test environment has been Windows 7, no antivirus, in VirtualBox. </div><div><br></div><div>Code for the package is up at <a href="https://github.com/bblonder/hypervolume" target="_blank">https://github.com/bblonder<wbr>/hypervolume</a>.</div><div><br></div><div>Thank you for your time!</div><div><br></div><div>Best wishes,</div><div>Benjamin Blonder</div><span class="m_-654858193824412751HOEnZb"><font color="#888888"><div><br></div></font></span></div><span class="m_-654858193824412751HOEnZb"><font color="#888888"><div class="gmail_extra">-- <br><div class="m_-654858193824412751m_-4879955541096688125gmail_signature"><div dir="ltr"><div dir="ltr" style="font-size:12.8px">Benjamin Blonder<br></div><div dir="ltr" style="font-size:12.8px">Environmental Change Institute</div><div style="font-size:12.8px">School of Geography and the Environment</div><div dir="ltr" style="font-size:12.8px">University of Oxford<br><br>Website: <a href="http://www.benjaminblonder.org/" target="_blank">http://www.benjaminbl<wbr>onder.org</a><br>Photo-blog (Natural Curiosities): <a href="http://bblonder.wordpress.com/" target="_blank">http://bblonder.<wbr>wordpress.com/</a><br>Google Scholar: <a href="http://scholar.google.com/citations?user=l3FNoE8AAAAJ" target="_blank">http://scholar.google<wbr>.com/citations?user=l3FNoE8AAA<wbr>AJ</a></div><div dir="ltr" style="font-size:12.8px">University of Arizona Sky School: <a href="https://skyschool.arizona.edu/" target="_blank">https://skyschool.ariz<wbr>ona.edu/</a></div></div></div>
</div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-pro<wbr>ject.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-projec<wbr>t.org/cgi-bin/mailman/listinfo<wbr>/rcpp-devel</a><br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr" style="font-size:12.8px">Benjamin Blonder<br></div><div dir="ltr" style="font-size:12.8px">Environmental Change Institute</div><div style="font-size:12.8px">School of Geography and the Environment</div><div dir="ltr" style="font-size:12.8px">University of Oxford<br><br>Website: <a href="http://www.benjaminblonder.org/" target="_blank">http://www.benjaminblonder.org</a><br>Photo-blog (Natural Curiosities): <a href="http://bblonder.wordpress.com/" target="_blank">http://bblonder.wordpress.com/</a><br>Google Scholar: <a href="http://scholar.google.com/citations?user=l3FNoE8AAAAJ" target="_blank">http://scholar.google.com/citations?user=l3FNoE8AAAAJ</a></div><div dir="ltr" style="font-size:12.8px">University of Arizona Sky School: <a href="https://skyschool.arizona.edu/" target="_blank">https://skyschool.arizona.edu/</a></div></div></div>
</div>