[TIMOB-23745] Android: Crash using Math.random
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-10T13:09:04.000+0000 |
Affected Version/s | Release 6.0.0 |
Fix Version/s | Release 6.0.0 |
Components | Android |
Labels | n/a |
Reporter | Martin Guillon |
Assignee | Christopher Williams |
Created | 2016-08-08T18:21:43.000+0000 |
Updated | 2016-08-23T22:25:07.000+0000 |
Description
trying to execute Math.random() in JS code will crash the app:
console.log(Math.random());
08-06 17:15:14.558: A/DEBUG(197): #01 pc 0072d450 /data/app/akylas.alpi.maps-1/lib/arm/libkroll-v8.so (v8::internal::JSArrayBuffer::SetupAllocatingData(v8::internal::Handle<v8::internal::JSArrayBuffer>, v8::internal::Isolate*, unsigned int, bool, v8::internal::SharedFlag)+64)
08-06 17:15:14.559: A/DEBUG(197): #02 pc 008362b4 /data/app/akylas.alpi.maps-1/lib/arm/libkroll-v8.so (v8::internal::Runtime_GenerateRandomNumbers(int, v8::internal::Object**, v8::internal::Isolate*)+996)
08-06 17:15:14.559: A/DEBUG(197): #03 pc 00000098 <unknown>
[~farfromrefuge]Do you have a sample to reproduce this? Is it just simply calling Math.random()?
Just calling Math.random().toString() I get:
After using debug libraries, the ultimate crash is coming inside v8 itself when it calls JSArrayBuffer::SetupAllocatingData as Martin showed above. That method pretty much just deals with the array buffer allocator, which is something we create and set on the Isolate in V8Runtime. Looks like my copy-paste coding of that small impl must not behave properly on Android? My guess is that it's crashing on the Allocate(length) call, presumably when either realloc or memset is called. I'm going to try and just have Allocate always use calloc().
https://github.com/appcelerator/titanium_mobile/pull/8196
Once the PR is confirmed/merged, it needs to be cherry-picked to master branch.
Verified the fix.
Math.random()
does not cause the crash. Closing. Environment: Appc Studio : 4.7.1.201608190732 Ti SDK : 6.0.0.v20160822133504 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-26 Node: 4.4.4 Nexus 6 - Android 6.0.1