journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.68k stars 1.26k forks source link

ArrayIndexOutOfBoundsException #675

Open JChrist opened 2 years ago

JChrist commented 2 years ago

Description of the problem:

There are quite a few crashes reported in Play Store for Android SDKs 8.1, 9, 10 and 11 (at least). The stacktrace for Android SDK 11 is the following. For other Android versions, it is the same, with line numbers on OS methods changing and always going through RawImageData.java:33:

java.lang.ArrayIndexOutOfBoundsException: 
  at java.lang.System.arraycopy (System.java:524)
  at com.journeyapps.barcodescanner.RawImageData.cropAndScale (RawImageData.java:33)
  at com.journeyapps.barcodescanner.SourceData.createSource (SourceData.java:12)
  at com.journeyapps.barcodescanner.DecoderThread.createSource (DecoderThread.java:6)
  at com.journeyapps.barcodescanner.DecoderThread.decode (DecoderThread.java:9)
  at com.journeyapps.barcodescanner.DecoderThread.access$000 (DecoderThread.java)
  at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage (DecoderThread.java:12)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:236)
  at android.os.HandlerThread.run (HandlerThread.java:67)

Which library version are you using? E.g. 3.2.0 4.3.0

Which phone/tablet are you using, and which Android version does it run? (e.g. Samsung Galaxy S5, Android 5.0) Spotted on Play Store, sample with the stacktrace is Redmi Note 8T Android 11 (SDK 30). There are a lot of others as well, such as Redmi 6 Android 9 (SDK 28), etc

Does the same happen on other devices or an emulator? On devices.

Can you reproduce the issue in the sample project included with the library? If not, can you provide your own sample project or sample code that produces this error? Unfortunately not, since I'm reporting the crashes collected by Play Store.

In the case of an error do you have a stack trace or adb logs? For Android 11:

java.lang.ArrayIndexOutOfBoundsException: 
  at java.lang.System.arraycopy (System.java:524)
  at com.journeyapps.barcodescanner.RawImageData.cropAndScale (RawImageData.java:33)
  at com.journeyapps.barcodescanner.SourceData.createSource (SourceData.java:12)
  at com.journeyapps.barcodescanner.DecoderThread.createSource (DecoderThread.java:6)
  at com.journeyapps.barcodescanner.DecoderThread.decode (DecoderThread.java:9)
  at com.journeyapps.barcodescanner.DecoderThread.access$000 (DecoderThread.java)
  at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage (DecoderThread.java:12)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:236)
  at android.os.HandlerThread.run (HandlerThread.java:67)
ghost commented 2 years ago

Just got quite similar error:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=307200 srcPos=306792 dst.length=331776 dstPos=165312 length=576
       at java.lang.System.arraycopy(System.java)
       at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:43)
       at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:125)
       at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:135)
       at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:143)
       at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22)
       at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:154)
       at android.os.HandlerThread.run(HandlerThread.java:61)

Which library version are you using? E.g. 3.2.0 3.4.1

Which phone/tablet are you using, and which Android version does it run? (e.g. Samsung Galaxy S5, Android 5.0) PAX A920 (smart POS device) running Android 7.1.2

SayokMajumder commented 1 year ago

We are also facing the same issue:

Lib Version: zxing_embedded_version = "4.3.0" zxing_core_version = "3.3.3"

Device: OnePlus Nord CE 2 Lite 5G

OS Version: 12

Log:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=1555200 srcPos=1555303 dst.length=724546 dstPos=572470 length=874
       at java.lang.System.arraycopy(System.java:522)
       at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:214)
       at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:214)
       at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:214)
       at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:214)
       at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:214)
       at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:214)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loopOnce(Looper.java:238)
       at android.os.Looper.loop(Looper.java:349)
       at android.os.HandlerThread.run(HandlerThread.java:67) 
shanky367 commented 1 year ago

I also faced the same issue while using zxing lib. Lib Version: _zxing_embedded_version = "4.3.0" zxing_coreversion = "3.3.3"

Device: OnePlus Nord CE 2 Lite 5G OS Version: 12

Log: Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=1555200 srcPos=1555303 dst.length=724546 dstPos=572470 length=874 at java.lang.System.arraycopy(System.java:522) at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:214) at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:214) at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:214) at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:214) at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:214) at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:214) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:238) at android.os.Looper.loop(Looper.java:349) at android.os.HandlerThread.run(HandlerThread.java:67)

Ezyger commented 1 year ago

Same problem over here.

Lib Version: zxing_embedded_version = "4.3.0" zxing_core_version = "3.3.0"

Device: OS Version: 10

Motorola: (46%) Moto G7 Play (42%) Moto G7 Power (3%) Moto G8 (<1%)

Xiaomi: (40%) Redmi Note 8 (39%) MI 8 Lite (1%)

LGE K22 (13%)

Samsung (<1%) Galaxy M52 5G Galaxy A20s (<1%)

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=768000 srcPos=768015 dst.length=147294 dstPos=74816 length=1169 at java.lang.System.arraycopy(System.java:527) at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:43) at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:125) at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:135) at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:143) at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22) at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:67)

JanMisker commented 1 year ago

We experience the same, unfortunately not on our own test devices but we do see crash reports with these logs in the PlayStore :(. Does anyone have a reproducible case for it? Or found a workaround?

grzesiek2010 commented 1 year ago

Hi I'm Grzegorz from ODK Collect I've just spotted a similar crash report in our app. There is just one instance of it: image

and here is the stacktrace:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=495616 srcPos=495020 dst.length=746496 dstPos=151200 length=864
       at java.lang.System.arraycopy(System.java:527)
       at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:43)
       at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:125)
       at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:135)
       at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:143)
       at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22)
       at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:251)
       at android.os.HandlerThread.run(HandlerThread.java:67)

We use the newest v4.3.0

madhumitha998 commented 11 months ago

We experience the same, unfortunately not on our own test devices but we do see crash reports with these logs in the PlayStore :(. Does anyone have a reproducible case for it? Or found a workaround?

Same, seeing these errors on sentry.

Hamoda96 commented 4 months ago

have the same problem

Log :

   Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=495616 srcPos=495020 dst.length=746496 dstPos=151200 length=864
   at java.lang.System.arraycopy(System.java:527)
   at com.journeyapps.barcodescanner.RawImageData.cropAndScale(RawImageData.java:43)
   at com.journeyapps.barcodescanner.SourceData.createSource(SourceData.java:125)
   at com.journeyapps.barcodescanner.DecoderThread.createSource(DecoderThread.java:135)
   at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:143)
   at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22)
   at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38)
   at android.os.Handler.dispatchMessage(Handler.java:103)
   at android.os.Looper.loop(Looper.java:251)
   at android.os.HandlerThread.run(HandlerThread.java:67)

Mobile info :

Screenshot from 2024-02-19 01-20-41

what is the soluation for this crash ?