HELIUM: Call to c4stream_write with critical array may cause crash
Description
The optimized call `GetPrimitiveArrayCritical` is unsafe because, after calling it, nearly any Java or JNI call prior to calling `ReleasePrimitiveArrayCritical` will cause a crash. This includes logging.
One of the last uses of the critical call is used copying a Blob data array, prior to calling `c4stream_write`. That seemed like a good idea, because the array is potentially very large. Unfortunately, LiteCore has started logging from its method and that causes a crash.
This fix is simple: use the normal call: `GetByteArrayElements` instead.
Activity
Show:
Fixed
Pinned fields
Click on the next to a field label to start pinning.
The optimized call `GetPrimitiveArrayCritical` is unsafe because, after calling it, nearly any Java or JNI call prior to calling `ReleasePrimitiveArrayCritical` will cause a crash. This includes logging.
One of the last uses of the critical call is used copying a Blob data array, prior to calling `c4stream_write`. That seemed like a good idea, because the array is potentially very large. Unfortunately, LiteCore has started logging from its method and that causes a crash.
This fix is simple: use the normal call: `GetByteArrayElements` instead.