[Rcpp-devel] My R package that passes CRAN tests crashes on Windows when using Rcpp code - only with antivirus software installed
Benjamin Blonder
benjamin.blonder at ouce.ox.ac.uk
Mon Nov 6 20:14:28 CET 2017
Hi Tim,
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!
Ben
On Wed, Nov 1, 2017 at 4:37 PM, Tim Keitt <tkeitt at utexas.edu> wrote:
> Hi Ben,
>
> 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.
>
> THK
>
> http://www.keittlab.org/
>
> On Wed, Nov 1, 2017 at 10:47 AM, Benjamin Blonder <
> benjamin.blonder at ouce.ox.ac.uk> wrote:
>
>> 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.
>>
>> 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.
>>
>> A minimally reproducible example is below:
>>
>> library(hypervolume)
>> data(iris)
>> hv = hypervolume_svm(iris[,1:2])
>>
>> On a debug trace, the problem occurs when hypervolume_svm() eventually
>> internally calls kdtree_ball_query_multiple(), which is just a wrapper
>> for an Rcpp call to a C++ function (in the package's src/convert.cpp):
>>
>> SEXP kdtree_ball_query_multiple(SEXP tr, SEXP ptlist, SEXP nr, SEXP nc,
>> SEXP r, SEXP verb)
>>
>> {
>>
>> XPtr<KDTree> tree = as<XPtr<KDTree> >(tr);
>>
>> int nrow = as<int>(nr);
>>
>> int ncol = as<int>(nc);
>>
>> NumericVector data(ptlist);
>>
>> double radius = as<double>(r);
>>
>> bool verbose = as<int>(verb);
>>
>>
>>
>> vector<vector< double > > dataMatrix
>>
>> = convertMatrixToVector(data.begin(), nrow, ncol);
>>
>>
>>
>> vector<int> finalCounts;
>>
>>
>>
>> if (ncol != tree->ndims())
>>
>> {
>>
>> throw(length_error("Points not same dimensionality as data in kdtree"));
>>
>>
>> }
>>
>>
>>
>> RProgress::RProgress pb("[:bar]", nrow);
>>
>> if (verbose==1)
>>
>> {
>>
>> Rcpp::Rcout << "Ball query... \n";
>>
>> pb.tick(0);
>>
>> }
>>
>>
>>
>> for (int i=0; i<nrow; i++)
>>
>> {
>>
>>
>>
>> vector<int> thisIndices;
>>
>> vector<double> thisDistances;
>>
>>
>>
>> vector<double> thisPoint = dataMatrix[i];
>>
>> tree->ball_query(thisPoint, radius, thisIndices, thisDistances);
>>
>>
>>
>> // store the number of points within the ball for each point
>>
>> finalCounts.push_back(thisIndices.size());
>>
>>
>>
>> if (i%10==0 && verbose==1)
>>
>> {
>>
>> pb.update(1.0*(i+1)/nrow);
>>
>> }
>>
>>
>>
>> }
>>
>>
>>
>> if (verbose==1)
>>
>> {
>>
>> Rcpp::Rcout << "\ndone.\n";
>>
>> }
>>
>>
>>
>> pb.update(1);
>>
>>
>>
>> return(wrap(finalCounts));
>>
>> }
>>
>> 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.
>>
>> 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?
>>
>> 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.
>>
>> Code for the package is up at https://github.com/bblonder/hypervolume.
>>
>> Thank you for your time!
>>
>> Best wishes,
>> Benjamin Blonder
>>
>> --
>> Benjamin Blonder
>> Environmental Change Institute
>> School of Geography and the Environment
>> University of Oxford
>>
>> Website: http://www.benjaminblonder.org
>> Photo-blog (Natural Curiosities): http://bblonder.wordpress.com/
>> Google Scholar: http://scholar.google.com/citations?user=l3FNoE8AAAAJ
>> University of Arizona Sky School: https://skyschool.arizona.edu/
>>
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>
>
--
Benjamin Blonder
Environmental Change Institute
School of Geography and the Environment
University of Oxford
Website: http://www.benjaminblonder.org
Photo-blog (Natural Curiosities): http://bblonder.wordpress.com/
Google Scholar: http://scholar.google.com/citations?user=l3FNoE8AAAAJ
University of Arizona Sky School: https://skyschool.arizona.edu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20171106/26ea3b7d/attachment-0001.html>
More information about the Rcpp-devel
mailing list