Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash in empty n_distinct() #1957

Closed
jankatins opened this issue Jun 22, 2016 · 3 comments
Closed

crash in empty n_distinct() #1957

jankatins opened this issue Jun 22, 2016 · 3 comments

Comments

@jankatins
Copy link

@jankatins jankatins commented Jun 22, 2016

The following crashes RStudio (after a minute of 100% CPU):

library(dplyr)
data.frame(a = c("a","b","a"), b=1:3) %>% group_by(a) %>%  summarise(user_count = n_distinct())

It also happens with a simple n_distinct().

Win7, R3.3, compiled from master (e87f6dd). Not sure if this is related: #1871

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Jun 22, 2016

With lldb backtrace:

> data.frame(a = c("a","b","a"), b=1:3) %>% group_by(a) %>%  summarise(user_count = n_distinct())
Process 37498 stopped
* thread #1: tid = 0x877d7, 0x000000010a805824 dplyr.so`Rcpp::PreserveStorage<Rcpp::RObject_Impl<Rcpp::PreserveStorage> >::operator SEXPREC*(this=0x0000000000000000) const + 4 at PreserveStorage.h:47, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010a805824 dplyr.so`Rcpp::PreserveStorage<Rcpp::RObject_Impl<Rcpp::PreserveStorage> >::operator SEXPREC*(this=0x0000000000000000) const + 4 at PreserveStorage.h:47
   44               return ::Rf_inherits( data, clazz) ;
   45           }
   46
-> 47           inline operator SEXP() const { return data; }
   48
   49       private:
   50           SEXP data ;

(lldb) frame select 1
frame #1: 0x000000010a84f21e dplyr.so`dplyr::VisitorSetHash<dplyr::MultipleVectorVisitors>::hash(this=0x0000000101747350, j=0) const + 30 at VisitorSetHash.h:11
   8        public:
   9            size_t hash( int j) const {
   10               const Class& obj = static_cast<const Class&>(*this) ;
-> 11               size_t seed = obj.get(0)->hash(j) ;
   12               int n = obj.size() ;
   13               for( int k=1; k<n; k++){
   14                   boost::hash_combine( seed, obj.get(k)->hash(j) ) ;

(lldb) frame select 2
frame #2: 0x000000010a84f06d dplyr.so`std::__1::pair<boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<int> >, bool> boost::unordered::detail::table_impl<boost::unordered::detail::set<std::__1::allocator<int>, int, dplyr::VisitorHash<dplyr::MultipleVectorVisitors>, dplyr::VisitorEqualPredicate<dplyr::MultipleVectorVisitors> > >::emplace_impl<boost::unordered::detail::emplace_args1<int> >(this=0x0000000101747368, k=0x00007fff5fbf7f44, args=0x00007fff5fbf7f00) + 29 at unique.hpp:407
   404          emplace_return emplace_impl(key_type const& k,
   405              BOOST_UNORDERED_EMPLACE_ARGS)
   406          {
-> 407              std::size_t key_hash = this->hash(k);
   408              iterator pos = this->find_node(key_hash, k);
   409
   410              if (pos.node_) return emplace_return(pos, false);

Hopefully this provides context re: where the error is occurring and what a fix might be.

@hadley
Copy link
Member

@hadley hadley commented Jun 22, 2016

Probably missing an arity check earlier on 😕

@jankatins
Copy link
Author

@jankatins jankatins commented Jun 24, 2016

Thanks a lot, just confirmed the fix :-)

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants