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

GenericGF::multiply(int,int) BAD_ACCESS crash #12

Open
TimZaman opened this issue May 15, 2015 · 10 comments
Open

GenericGF::multiply(int,int) BAD_ACCESS crash #12

TimZaman opened this issue May 15, 2015 · 10 comments

Comments

@TimZaman
Copy link

Hi guys, i am doing some test on a huge barcode batch. It crashes often on multiply for some reason, see the trace below. Can't get my head around why, any ideas?

Crashed Thread: 125 QThread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007ffe73094600

VM Regions Near 0x7ffe73094600:
 MALLOC_SMALL 00007ffcbf825000-00007ffcc0000000 [ 8044K] rw-/rwx SM=ZER 
--> 
 STACK GUARD 00007fff4ff8d000-00007fff5378d000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0

(...)

Thread 125 Crashed:: QThread
0 com.test 0x000000010bf6c4de zxing::GenericGF::multiply(int, int) + 62
1 com.test 0x000000010bf6d04f zxing::GenericGFPoly::evaluateAt(int) + 175
2 com.test 0x000000010bf6e80d zxing::ReedSolomonDecoder::decode(zxing::ArrayRef<int>, int) + 269
3 com.test 0x000000010bf7604e zxing::datamatrix::Decoder::correctErrors(zxing::ArrayRef<char>, int) + 414
4 com.test 0x000000010bf76448 zxing::datamatrix::Decoder::decode(zxing::Ref<zxing::BitMatrix>) + 648
5 com.test 0x000000010bf710e9 zxing::datamatrix::DataMatrixReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 137
6 com.test 0x000000010bf83374 zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) + 148
7 com.test 0x000000010bf83553 zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 131
8 com.test 0x000000010beeac50 scanprocessor::decode_image_barcode(cv::Mat const?, std::__1::vector<int, std::__1::allocator<int> >) + 1680
9 com.test 0x000000010becc37b scanprocessor::getBarcodes(cv::Mat, double, std::__1::vector<int, std::__1::allocator<int> >, int) + 9739
10 com.test 0x000000010beb7ba7 scanprocessor::process(int, _CameraFile*, int, int, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 49575
11 com.test 0x000000010bcb0fce scanprocessor::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 1982
12 QtCore 0x000000010ed22743 QObject::event(QEvent*) + 755
13 QtWidgets 0x000000010df9e98b QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
14 QtWidgets 0x000000010dfa1c0c QApplication::notify(QObject*, QEvent*) + 7964
15 QtCore 0x000000010ecf7fab QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 987
16 QtCore 0x000000010ed57e38 postEventSourceDispatch(_GSource*, int (*)(void*), void*) + 24
17 libglib-2.0.0.dylib 0x00000001118d8728 g_main_context_dispatch + 282
18 libglib-2.0.0.dylib 0x00000001118d8a0b g_main_context_iterate + 404
19 libglib-2.0.0.dylib 0x00000001118d8a63 g_main_context_iteration + 55
20 QtCore 0x000000010ed57331 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 97
21 QtCore 0x000000010ecf488d QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381
22 QtCore 0x000000010eb34b15 QThread::exec() + 117
23 QtCore 0x000000010eb38679 QThreadPrivate::start(void*) + 313
24 libsystem_pthread.dylib 0x00007fff90484268 _pthread_body + 131
25 libsystem_pthread.dylib 0x00007fff904841e5 _pthread_start + 176
26 libsystem_pthread.dylib 0x00007fff9048241d thread_start + 13
@TimZaman TimZaman changed the title zxing::GenericGF::multiply bad acces? zxing::GenericGF::multiply bad access? May 15, 2015
@Benjamin-Dobell
Copy link
Member

@TimZaman What's GenericGF's size? I didn't write this code (it's awful 😉), however just looking at the code in initialize the algorithm will only work if size is a power of two.

@TimZaman
Copy link
Author

Yep quite horrid, seems to work 999.999 out of a million though. The 1/1.000.000 part doesnt work, sadly. Any ideas how i approach to debug this? Love some guidance

@SebGDev
Copy link
Contributor

SebGDev commented May 15, 2015

@TimZaman: Just guessing, maybe the fix of the GenericGF memory leak could help:
SebGDev@03c3fa6

@Vidz1235
Copy link

Vidz1235 commented May 15, 2015 via email

@Vidz1235
Copy link

Thankyou jesus! I hope this works$#3
On May 15, 2015 2:20 AM, "Sebastian" notifications@github.com wrote:

@TimZaman https://github.com/TimZaman: Just guessing, maybe the fix of
the GenericGF memory leak could help:
SebGDev/zxing-cpp@03c3fa6
SebGDev@03c3fa6


Reply to this email directly or view it on GitHub
#12 (comment)
.

@TimZaman
Copy link
Author

Nope doesn't work with the latest update. Keep jesus out of this, Vidz.

On Fri, May 15, 2015 at 10:27 AM, Vidz1235 notifications@github.com wrote:

Thankyou jesus! I hope this works$#3
On May 15, 2015 2:20 AM, "Sebastian" notifications@github.com wrote:

@TimZaman https://github.com/TimZaman: Just guessing, maybe the fix of
the GenericGF memory leak could help:
SebGDev/zxing-cpp@03c3fa6
<
SebGDev@03c3fa6


Reply to this email directly or view it on GitHub
<
#12 (comment)

.


Reply to this email directly or view it on GitHub
#12 (comment)
.

@Benjamin-Dobell
Copy link
Member

Please try insert a conditional breakpoint in the constructor with
condition:

(size & (size - 1)) != 0

@TimZaman
Copy link
Author

Something like this, chief?

GenericGF::GenericGF(int primitive_, int size_, int b)
  : size(size_), primitive(primitive_), generatorBase(b), initialized(false) {
  if (size <= INITIALIZATION_THRESHOLD) {
    initialize();
  }

  if ((size & (size - 1)) != 0){
    throw IllegalArgumentException("(size & (size - 1)) != 0");
  }
}

@Benjamin-Dobell
Copy link
Member

I meant using a debugger, but that should do the trick.

@TimZaman TimZaman changed the title zxing::GenericGF::multiply bad access? GenericGF::multiply BAD_ACCESS crash May 15, 2015
@TimZaman TimZaman changed the title GenericGF::multiply BAD_ACCESS crash GenericGF::multiply(int,int) BAD_ACCESS crash May 15, 2015
@axxel
Copy link

axxel commented Oct 23, 2017

@TimZaman If you see any chance of resurrecting the datamatrix image content that caused this issue, I'd be very interested in getting my hands on that for testing. I recently removed a ton of temporary memory allocations that were ported from Java to this new c++ port in the GF-related code and also 'dehorrified' it a little ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants