Giter Site home page Giter Site logo

Segfault adding about rcppannoy HOT 8 CLOSED

eddelbuettel avatar eddelbuettel commented on May 30, 2024
Segfault adding

from rcppannoy.

Comments (8)

mikepb avatar mikepb commented on May 30, 2024

Let me try again with gcc instead of clang and update this thread in a few hours.

from rcppannoy.

eddelbuettel avatar eddelbuettel commented on May 30, 2024

There is nothing reproducible in your bug report so my ability to help you from here is limited.

Did you use 0.0.7 from CRAN as your base, or the current master from GitHub (which is marginally ahead and which I called 0.0.7.1) ? FWIW it is worth I can run R CMD check on both just fine (and this build and installs to run tests). But this stuff has been affected by R changes and/or g++ changes.

from rcppannoy.

erikbern avatar erikbern commented on May 30, 2024

i pushed some pretty extensive changes to annoy yesterday but don't think it's a part of rcppannoy yet right? just wanted to double check

from rcppannoy.

eddelbuettel avatar eddelbuettel commented on May 30, 2024

Hi @erikbern and thanks for being so proactive. RcppAnnoy does not automagically copy code from Annoy; it is pretty much a manual copy (along with copious regression checks).

Now, I can't speak for @mikepb, but I dont't think he copied code either. At this point we need more details (as eg provided by R's sessionInfo() along with OS, compiler, ... versions. As I said, "works for me" and also works at CRAN or else they'd come after me..

from rcppannoy.

mikepb avatar mikepb commented on May 30, 2024

Sorry, this was my bad! I had NA for the item value. Here's reproducible code:

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin15.2.0 (64-bit)
Running under: OS X 10.11.3 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppAnnoy_0.0.7

loaded via a namespace (and not attached):
[1] Rcpp_0.12.3      codetools_0.2-14
f <- 1049
knn <- new(AnnoyEuclidean, f)
sv <- rnorm(f)
knn$addItem(NA, sv)
 *** caught segfault ***
address 0xfffff7c600000008, cause 'memory not mapped'

Traceback:
 1: .External(list(name = "CppMethod__invoke_void", address = <pointer: 0x7fb5e3431380>,     dll = list(name = "Rcpp", path = "/usr/local/lib/R/3.2/site-library/Rcpp/libs/Rcpp.so",         dynamicLookup = TRUE, handle = <pointer: 0x7fb5e3558f40>,         info = <pointer: 0x10a7af3d0>), numParameters = -1L),     <pointer: 0x7fb5e3544400>, <pointer: 0x7fb5e354d760>, .pointer,     ...)
 2: knn$addItem(NA, sv)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Should the API check for this error condition?

from rcppannoy.

mikepb avatar mikepb commented on May 30, 2024

Looks like the segfault likely comes from annoy passing the NA to realloc, which then crashes the program.

https://github.com/eddelbuettel/rcppannoy/blob/master/inst/include/annoylib.h#L422

from rcppannoy.

eddelbuettel avatar eddelbuettel commented on May 30, 2024

Thanks for looking into this. We can probably catch that.

from rcppannoy.

eddelbuettel avatar eddelbuettel commented on May 30, 2024

Sorry for taking so long. This basically blew up whenever x in knn$addItem(x, vector) was negative, and NA is a special negative value (actually, - INT_MAX). But because we passed from R's SEXP to an int32_t already, I no longer have R's NA tests (easily) so I just test for negative values.

Commit and fix coming up.

from rcppannoy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.