zxing-cpp
zxing-cpp copied to clipboard
zxing dead loop while detecting qrcode
There is a server for image transferring. when an image comes to system, it is detected by zxing for qrcode. The server works well most of the time. Sometime, there happens a dead loop. The call stack is as follows. Thread 1 (process 47568): #0 0x000000000053c222 in __gnu_cxx::__normal_iteratorzxing::Ref<zxing::qrcode::FinderPattern, std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > > >::__normal_iterator(zxing::Refzxing::qrcode::FinderPattern const&) () #1 0x000000000053c27b in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::begin() () #2 0x000000000053f5d0 in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::_M_insert_aux(__gnu_cxx::__normal_iteratorzxing::Ref<zxing::qrcode::FinderPattern, std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > > >, zxing::Refzxing::qrcode::FinderPattern const&) () #3 0x000000000053f7fa in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::push_back(zxing::Refzxing::qrcode::FinderPattern const&) () #4 0x000000000053b08e in zxing::multi::MultiFinderPatternFinder::selectBestPatterns() () #5 0x000000000053bcd2 in zxing::multi::MultiFinderPatternFinder::findMulti(zxing::DecodeHints const&) () #6 0x00000000005396b3 in zxing::multi::MultiDetector::detectMulti(zxing::DecodeHints) () #7 0x0000000000536da0 in zxing::multi::QRCodeMultiReader::decodeMultiple(zxing::Refzxing::BinaryBitmap, zxing::DecodeHints) () #8 0x0000000000501770 in BarcodeDecoder::decode(std::basic_string, std::allocator > const&, unsigned char, unsigned long, std::basic_string, std::allocator >&) () #9 0x000000000047dc1a in WWS::FtsHandler::onSendAck(unsigned long) () #10 0x000000000047fd80 in WWS::FtsHandler::onPackData(char const, unsigned long) () #11 0x0000000000480090 in WWS::FtsHandler::onPackHead(char const, unsigned long) () #12 0x00000000004800eb in WWS::FtsHandler::onData(char const, unsigned long) () #13 0x0000000000480334 in WWS::FtsHandler::onRecv(char const, unsigned long) () #14 0x00000000004bce92 in WWS::Asynchat::onCanRead() () #15 0x00000000004c6c79 in WWS::Poller::poll(int) () #16 0x00000000004c9e93 in WWS::PollerThread::thread() () #17 0x00000000004b20b4 in WWS::threadFunction(void*) () #18 0x00007f0a758a873d in start_thread () from /lib64/libpthread.so.0 #19 0x0000003faa2d44bd in clone () from /lib64/libc.so.6
@shlwang I have not encountered this and by looking at the attached stack trace I'm unclear as to what you mean by "dead loop".
Would it be possible for you to provide an image that upon decoding exhibits this issue?
@Benjamin-Dobell , it need some effort to dump the content. Will try. It happens on product. I found one CPU always running at 100% by one specific worker thread(other worker threads don't), and the stack is dumped from that specific thread.
@Benjamin-Dobell , for this image, it can reproduce the dead loop issue. Could you take a look? The url for the image is http://img04.taobaocdn.com/L1/134/3839/ftssrvlk/0/21/f8d03a9f4a332de7eec11d2bffec89ba.jpg
@shlwang nope, cant reproduce.
Hi TimZaman, QRCodeMultiReader is replaced by MultiFormatReader as a workaround. It seems that the QRCodeMultiReader causes deadloop issue. Here is the diff,
- DecodeHints hints(DecodeHints::DEFAULT_HINT);
+ DecodeHints hints(DecodeHints::QR_CODE_HINT);
+ /// DecodeHints hints(DecodeHints::DEFAULT_HINT);
hints.setTryHarder(1);
Ref<BinaryBitmap> image(new BinaryBitmap(binarizer));
+ MultiFormatReader delegate;
+ // GenericMultipleBarcodeReader reader(delegate);
+ results.push_back(delegate.decode(image, hints));
- QRCodeMultiReader reader;
- results = reader.decodeMultiple(image, hints);
+ // QRCodeMultiReader reader;
+ // results = reader.decodeMultiple(image, hints);
Hey everyone, if you have solutions to issues, please submit them as a (minimal) pull request rather than dumping a diff in comments. That way I can merge them in.