[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

crash[coco8] Bug in JSC parser

Uploaded Image: alert.gif
"WARNING: This page activates a bug that can crash the application if it is running with JavascriptCore VM (distributed by Apple)."


"JSC parser bug (with print)"
self print: 'Run in ', ['
[self print: 1.
 [self print: 2.
   [self print: 3.
    [self print: 4.
     [self print: 5.
     [self print: 6.
     [self print: 7.
     [self print: 8.
     [self print: 9.
     [self print: 10.
     [self print: 11.
     [self print: 12.
     [self print: 13.
     [self print: 14.
     [self print: 15.
     [self print: 16.
     [self print: 17.
     [self print: 18.
     [self print: 19.
     [self print: 20.
self print: ''-----------''.
     self print: -20 ] value.
     self print: -19 ] value.
     self print: -18 ] value.
     self print: -17 ] value.
     self print: -16 ] value.
     self print: -15 ] value.
     self print: -14 ] value.
     self print: -13 ] value.
     self print: -12 ] value.
     self print: -11 ] value.
     self print: -10 ] value.
     self print: -9 ] value.
     self print: -8 ] value.
     self print: -7 ] value.
     self print: -6 ] value.
     self print: -5 ] value.
    self print: -4 ] value.
   self print: -3 ] value.
  self print: -2 ] value.
 self print: -1 ] value.
' evaluate ] ms ,'ms'


Execution results
OSXChrome 224ms
OSXSafari 27678ms
iOS (iPad 8Gb)coco824118ms (do not crash)
iOS (iPhone6s 1Gb)coco8crash (always a crash)

Simpler S8 expression

"JSC parser bug (reduced)"
self print: 'Run in ', ['
[[[[[[[[[[[[[[[[[[[[ 
] value] value] value] value] value] value] value
] value] value] value] value] value] value] value
] value] value] value] value] value] value
' evaluate ] ms ,'ms'


Execution results
OSXChrome 61ms
OSXSafari 3723ms
iOS (iPad 8Gb)coco85340ms (do not crash)

When running with xcode debugger:
Before evaluation memory in use was 64mb; memory comsumption climbs up to 670Mb, and after evaluation goes to 457Mb

Multiple evaluations show peaks of 670Mb and memory returns to 450MbApplication is stable, no indication of presence of the bug.

iOS (iPhone6s 1Gb)coco8always a crash, no crash dump

When running with xcode debugger:
Message from debugger: Terminated due to memory issue
Before evaluation memory in use was 64mb; memory comsumption climbs up to aprox. 600Mb, then, fast exit with memory full


Pure javascript expression

"JSC parser bug (javascript)"
self nativeCodeFollows !
((function(){return ((function(){return ((function(){return ((function(){return 
((function(){return ((function(){return ((function(){return ((function(){return 
((function(){return ((function(){return ((function(){return ((function(){return 
((function(){return ((function(){return ((function(){return ((function(){return 
((function(){return ((function(){return ((function(){return ((function(){return 
(1);
})() + 1);})() + 1);})() + 1);})() + 1);
})() + 1);})() + 1);})() + 1);})() + 1);
})() + 1);})() + 1);})() + 1);})() + 1);
})() + 1);})() + 1);})() + 1);})() + 1);
})() + 1);})() + 1);})() + 1);})() + 1)


Execution results
The bug is not present using this Javascript expression.
The memory consumption is also observed parsing the following expression :-(
"High memory consumption parsing simple expression"
(((((((
(((((((
(((((((
(((((((
((((((( 1234
)))))))
)))))))
)))))))
)))))))
)))))))