Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upgetItemsVector crashes R #24
Comments
|
Fichtre. Confirmed. @erikbern Any idea from the top of your head? I am doing std::vector<double> getItemsVector(int32_t item) {
std::vector<float> fv;
ptr->get_item(item, &fv[0]);
std::vector<double> dv(fv.size());
std::copy(fv.begin(), fv.end(), dv.begin());
return dv;
}which is pretty straight up from your annoymodule. But clearly |
|
Tears go away if diff --git a/src/annoy.cpp b/src/annoy.cpp
index 04aa5d7..db5a4cd 100644
--- a/src/annoy.cpp
+++ b/src/annoy.cpp
@@ -113,7 +113,7 @@ public:
}
std::vector<double> getItemsVector(int32_t item) {
- std::vector<float> fv;
+ std::vector<float> fv(vectorsz);
ptr->get_item(item, &fv[0]);
std::vector<double> dv(fv.size());
std::copy(fv.begin(), fv.end(), dv.begin());I'll make that change. Thanks to @pommedeterresautee for the bug report! |
|
For completeness: edd@brad:~/git/rcppannoy(master)$ Rscript /tmp/annoycrash.R
[1] 0 28 17 19 49 32 38 31 47 33 12 2 44 26 9 1 6 23 34 35 39 22 11 43 3
[26] 4 7 18 5 41 45 37 13 24 30 14 27 42 36 16
[1] -0.56047565 -0.23017749 1.55870831 0.07050839 0.12928773 1.71506500
[7] 0.46091619 -1.26506126 -0.68685287 -0.44566196 1.22408175 0.35981384
[13] 0.40077144 0.11068272 -0.55584115 1.78691316 0.49785048 -1.96661711
[19] 0.70135587 -0.47279140 -1.06782365 -0.21797492 -1.02600443 -0.72889125
[25] -0.62503928 -1.68669331 0.83778703 0.15337312 -1.13813698 1.25381494
[31] 0.42646423 -0.29507148 0.89512569 0.87813348 0.82158107 0.68864024
[37] 0.55391765 -0.06191171 -0.30596265 -0.38047099
edd@brad:~/git/rcppannoy(master)$ |
|
weird that it was working before |
|
I carried a bunch of your new tests over but I can only imagine that this one was not covered but what I have. |
|
@eddelbuettel do you plan to push an update on Cran? |
|
Sure, but maybe not immediately. Can you rebuild locally? |
|
I have rebuilt succesfully, but I want to release a package on Cran depending on RcppAnnoy :-) |
|
Oh, I see :) In that case I will gladly push a fix. |
|
Thanks again for the bug report. RcppAnnoy 0.0.10 is now on CRAN. |
|
Awesome! I ll push mine :-) |
Calling
getItemsVectormake R crash. BTWgetItemsVectoris not in the tests :-)