Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29437563: Issue 5239 - JsValue access crash (Closed)

Created:
May 12, 2017, 11:55 a.m. by anton
Modified:
May 12, 2017, 3:44 p.m.
Reviewers:
sergei, diegocarloslima
CC:
Felix Dahlke, René Jeschke
Visibility:
Public.

Description

Issue 5239 - JsValue access crash

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -1 line) Patch
M libadblockplus-android/jni/JniJsValue.cpp View 1 chunk +2 lines, -1 line 1 comment Download

Messages

Total messages: 3
anton
May 12, 2017, 11:56 a.m. (2017-05-12 11:56:05 UTC) #1
diegocarloslima
On 2017/05/12 11:56:05, anton wrote: LGTM
May 12, 2017, 3 p.m. (2017-05-12 15:00:10 UTC) #2
sergei
May 12, 2017, 3:38 p.m. (2017-05-12 15:38:07 UTC) #3
LGTM

I have added a comment merely for reference, if something like this triggers
again we will know what to try.

https://codereview.adblockplus.org/29437563/diff/29437564/libadblockplus-andr...
File libadblockplus-android/jni/JniJsValue.cpp (right):

https://codereview.adblockplus.org/29437563/diff/29437564/libadblockplus-andr...
libadblockplus-android/jni/JniJsValue.cpp:170: {
I thought about adding some static_assert like below for 64 bit platforms but it
seems we are not building for 64 bit platforms
static_assert(reinterpret_cast<void*>(static_cast<jlong>(reinterpret_cast<uintptr_t>((void*)0xAFFFFFFFFFFFFFFF)))
== (void*)0xAFFFFFFFFFFFFFFF, "Conversion is invalid for 64 bits");

which is basically repeating our operations
originalPointer = (void*)0xAFFFFFFFFFFFFFFF
here we do
pHere = static_cast<jlong>(reinterpret_cast<uintptr_t>(originalPointer))
then in JniLongToTypePtr
ptrValue = reinterpret_cast<void*>(pHere)
and ptrValue should be equal to originalPointer.

Maybe we could put at least
static_assert(sizeof(jlong) >= sizeof(uintptr_t), "jlong should be enough large
to keep positive uintptr_t");
pay attention that currently sizeof(jlong) > sizeof(uintptr_t) always, and
sizeof(jlong) == sizeof(uintptr_t) only on 64 bits.

Powered by Google App Engine
This is Rietveld