You probably want to check cells->size() and make sure it is > 0. Also you should always check cells->get_eos() which indicates that this is the last set of cells for the scan and that the scan is complete. I will file an issue to modify the ScanCells::get() method to return a bool indicating whether there are cells or not instead of crashing in such cases.
Thanks -Sanjit On Mon, Mar 28, 2011 at 9:46 AM, Sanjit Jhala <[email protected]> wrote: > Hi Naveen, > > Take a look at the Future API (src/cc/Hypertable/Lib/Future.h) to see how > it implements the ResultCallback class. It does check for errors, end of > scan, whether the scan has been cancelled etc. In fact you might want to > directly use or derive from the Future API instead of implementing your own > callback from scratch. One caveat is that if you are going to destroy > asynchronous scanners before the scan finishes, you must call the cancel > method on the Future object to avoid a deadlock. An example can be found > in src/cc/Hypertable/Lib/tests/future_abrupt_end_test.cc . > > -Sanjit > > > On Sun, Mar 27, 2011 at 10:12 AM, Doug Judd <[email protected]> wrote: > >> Hi Naveen, >> >> Thanks for the report. We'll look into it on Monday. >> >> - Doug >> >> >> On Sat, Mar 26, 2011 at 9:02 PM, Naveen Koorakula < >> [email protected]> wrote: >> >>> Hi guys, >>> >>> Just deployed 0.9.5.0.pre with hypernode (our hypertable nodejs binding), >>> which uses the new C++ async scanner api. I'm seeing an error on an async >>> read. >>> >>> The error looks like: >>> /usr/local/include/boost/smart_ptr/intrusive_ptr.hpp:166: T* >>> boost::intrusive_ptr<T>::operator->() const [with T = >>> Hypertable::CellsBuilder]: Assertion `px != 0' failed. >>> >>> This traces back to a class I defined in the binding, that derives from >>> ResultCallback. >>> >>> class ScanCallback: public Hypertable::ResultCallback { >>> public: >>> ScanCallback() : m_cells(8) {} >>> virtual ~ScanCallback() {} >>> >>> void >>> scan_ok (TableScannerAsync *scanner, ScanCellsPtr &cells) { >>> ScopedLock lock(mutex); >>> Cells cc; >>> => cells->get(cc); >>> for (Hypertable::Cells::iterator ci = cc.begin(), >>> cend = cc.end(); ci != cend; ci++) { >>> m_cells.add(*ci); >>> } >>> } >>> ... >>> } >>> >>> The error is happening at the [ cells->get(cc) ] call marked in the code >>> fragment above. >>> >>> The backtrace looks like: >>> (gdb) bt >>> #0 0x00007ffff64e3ba5 in raise () from /lib/libc.so.6 >>> #1 0x00007ffff64e76b0 in abort () from /lib/libc.so.6 >>> #2 0x00007ffff64dca71 in __assert_fail () from /lib/libc.so.6 >>> #3 0x00007fffd1b6a3eb in >>> boost::intrusive_ptr<Hypertable::CellsBuilder>::operator-> (this=0xcaf608) >>> at /usr/local/include/boost/smart_ptr/intrusive_ptr.hpp:166 >>> #4 0x00007fffd1b630ca in Hypertable::ScanCells::get (this=0xcaf5a0, >>> cells=...) at /a/hypertable/current/include/Hypertable/Lib/ScanCells.h:50 >>> #5 0x00007fffd1b650ac in HyperConn::ScanCallback::scan_ok >>> (this=0xcede80, scanner=0xc2fb00, cells=...) at ../binding.cc:70 >>> #6 0x00007fffd186d6d8 in >>> Hypertable::TableScannerAsync::maybe_callback_ok (this=0xc2fb00, >>> scanner_id=<value optimized out>, next=<value optimized out>, >>> do_callback=255, cells=...) at /home/developer/s\ >>> rc/hypertable/src/cc/Hypertable/Lib/TableScannerAsync.cc:334 >>> #7 0x00007fffd1871b9a in Hypertable::TableScannerAsync::handle_result >>> (this=0xc2fb00, scanner_id=0, event=<value optimized out>, is_create=<value >>> optimized out>) at /home/developer/src/hypertable/src/\ >>> cc/Hypertable/Lib/TableScannerAsync.cc:267 >>> #8 0x00007fffd18753b4 in Hypertable::TableScannerHandler::run >>> (this=0xcac410) at >>> /home/developer/src/hypertable/src/cc/Hypertable/Lib/TableScannerHandler.cc:40 >>> #9 0x00007fffd173bfab in operator() (this=0xc96890) at >>> /home/developer/src/hypertable/src/cc/AsyncComm/ApplicationQueue.h:154 >>> #10 boost::detail::thread_data<Hypertable::ApplicationQueue::Worker>::run >>> (this=0xc96890) at /usr/local/include/boost/thread/detail/thread.hpp:56 >>> #11 0x00007fffcf33cb70 in thread_proxy () from >>> /a/hypertable/current/lib/libboost_thread.so.1.40.0 >>> #12 0x00007ffff683a971 in start_thread () from /lib/libpthread.so.0 >>> #13 0x00007ffff659692d in clone () from /lib/libc.so.6 >>> #14 0x0000000000000000 in ?? () >>> >>> >>> Tracing it back, it is happening in Hypertable/Lib/ScanCells.h:50 >>> >>> void ScanCells::get(Cells &cells) { m_cells->get(cells); } >>> >>> The value contained by the intrusive_ptr m_cells is null at this point. >>> >>> (gdb) >>> #4 0x00007fffd1b630ca in Hypertable::ScanCells::get (this=0xcaf5a0, >>> cells=...) at /a/hypertable/current/include/Hypertable/Lib/ScanCells.h:50 >>> (gdb) p m_cells >>> $1 = {px = 0x0} >>> >>> >>> ---- >>> >>> So my question is: what does >>> >>> ResultCallback::scan_ok(TableScannerAsync *scanner, ScanCellsPtr &cells) >>> >>> indicate ? Are there any checks that need to be done before we can >>> attempt to read off the cells contained in the ScanCellsPtr &cells ? >>> Couldn't find anything obvious in code, hence asking.. >>> >>> TIA, >>> --Naveen >>> founder & ceo, campfire labs. 415 425 5412. We're hiring! >>> http://www.campfirelabs.com/jobs >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Hypertable Development" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/hypertable-dev?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Hypertable Development" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/hypertable-dev?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Hypertable Development" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hypertable-dev?hl=en.
