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

segfault on OS X Mojave #74

Open
kousu opened this issue Mar 20, 2019 · 3 comments
Open

segfault on OS X Mojave #74

kousu opened this issue Mar 20, 2019 · 3 comments

Comments

@kousu
Copy link
Contributor

kousu commented Mar 20, 2019

I'm getting a segfault if I use GenericMultipleBarcodeReader. I'm on OS X Mojave and I installed zxing-cpp from brew.

It triggers on this image:

code.png

$ zxing --search-multi code.png 
Segmentation fault: 11

It does not trigger on this image:

table.png

$ zxing --search-multi table.png 
decoding failed

( I discovered this while trying to use the python wrapper: lubo/zxinglight#5 )

It seems like for some reason the thing ..compiled..wrong?? It's crashing in GenericMultipleBarcodeReader::translateResultPoints(). The disassembly is showing that it's trying to execute %rdi=*((void*)0x18) which doesn't make any sense.

$ lldb -- zxing --search-multi code.png 
(lldb) target create "zxing"
Current executable set to 'zxing' (x86_64).
(lldb) settings set -- target.run-args  "--search-multi" "code.png"
(lldb) run
Process 15820 launched: '/usr/local/bin/zxing' (x86_64)
Process 15820 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
    frame #0: 0x00000001000483af zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints(zxing::Ref<zxing::Result>, int, int) + 249
zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints:
->  0x1000483af <+249>: movq   0x18, %rdi
    0x1000483b7 <+257>: cmpq   0x20, %rdi
    0x1000483bf <+265>: je     0x1000483dc               ; <+294>
    0x1000483c1 <+267>: movq   $0x0, (%rdi)
Target 0: (zxing) stopped.
(lldb)
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x00000001000483af zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints(zxing::Ref<zxing::Result>, int, int) + 249
    frame #1: 0x00000001000478ef zxing`zxing::multi::GenericMultipleBarcodeReader::doDecodeMultiple(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints, std::__1::vector<zxing::Ref<zxing::Result>, std::__1::allocator<zxing::Ref<zxing::Result> > >&, int, int, int) + 315
    frame #2: 0x00000001000476c0 zxing`zxing::multi::GenericMultipleBarcodeReader::decodeMultiple(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 116
    frame #3: 0x000000010001fc16 zxing`decode_multi(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 123
    frame #4: 0x000000010001fea2 zxing`read_image(zxing::Ref<zxing::LuminanceSource>, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 450
    frame #5: 0x0000000100022251 zxing`main + 2747
    frame #6: 0x00007fff5c2b0ed9 libdyld.dylib`start + 1
    frame #7: 0x00007fff5c2b0ed9 libdyld.dylib`start + 1
@kousu
Copy link
Contributor Author

kousu commented Mar 20, 2019

Hmm. I built from master just now and instead see:

$ ./zxing -v code.png 
Hybrid binarizer succeeded: 
    {2-3}LZ7BDOso7qsr7cs0MV5NDQPYxEVeCMxsupw5zFGQf4GBn3u+nOcRjmKZT6UZO886fmqy/i6NTuUlc+otO6ZlpvXEVc0Dfvw1G+2s/zKElUi552dZv8bDvP88q89DmylL4bu6mtzTUKaDr+GI4WgoTZ
Global binarizer succeeded: 
    {2-3}LZ7BDOso7qsr7cs0MV5NDQPYxEVeCMxsupw5zFGQf4GBn3u+nOcRjmKZT6UZO886fmqy/i6NTuUlc+otO6ZlpvXEVc0Dfvw1G+2s/zKElUi552dZv8bDvP88q89DmylL4bu6mtzTUKaDr+GI4WgoTZ
$ ./zxing -v --search-multi code.png 
Hybrid binarizer failed: zxing::IllegalArgumentException: This luminance source does not support cropping.
Global binarizer failed: zxing::IllegalArgumentException: This luminance source does not support cropping.

@Benjamin-Dobell
Copy link
Member

It's not binary compatible, but have you looked into https://github.com/nu-book/zxing-cpp?

I'm very seriously considering deprecating this repository because their port is an fresh idiomatic port to C++, rather than the attempted 1-to-1 Java to C++ port that exists here.

@kousu
Copy link
Contributor Author

kousu commented Mar 20, 2019

Ah, no I hadn't seen that. I found yours because it's what the python and brew versions use.

I also found https://github.com/dlbeer/quirc/ which is interesting: it's written in a minimalist BSD style, but it still comes with both encoding, decoding, and even webcam support (on OpenBSD and Linux, no Darwin 😢 )

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

2 participants