PhantomJS crashes on a specific sequence of actions through n-p (OS X)...
First of all, big "Thank you!" to the creator and all contributors. It's awesome to be able to use PhantomJS in node.
The issue that I am currently facing:
- PhantomJS crashes after certain sequence of actions is executed through node-phantom. Trying to execute the same actions when directly phantom runs your code, doesn't reproduce the crash. The error seems to be caused by accessing page that is already deallocated.
I have created a gist with a mocha test reproducing the issue, as well as the same code rewritten for running by phantom (that doesn't break it) and a crash report from phantom: https://gist.github.com/nicroto/9407322
I have debugged the problem, thoroughly, checked page-id's on my side and on node-phantom's side, and they are all correct - I am never accessing id that has been closed before, here is a log (phantomCall and pageCall are logged by my code, while phantom stdout is logged by node-phantom):
phantomCall: createPage
phantomCall: createPage
phantomCall: createPage
phantom stdout: 0,0,createPage
phantom stdout: responding:1,0,pageCreated
phantom stdout: 0,1,createPage
phantom stdout: responding:2,1,pageCreated
phantom stdout: 0,2,createPage
phantom stdout: responding:3,2,pageCreated
pageCall: start-open, args: {"0":"http://localhost:49585"}, id: 1
pageCall: start-open, args: {"0":"http://localhost:49585"}, id: 2
pageCall: start-open, args: {"0":"http://localhost:49585"}, id: 3
phantom stdout: 1,3,pageOpenWithCallback,http://localhost:49585
phantom stdout: 2,4,pageOpenWithCallback,http://localhost:49585
phantom stdout: 3,5,pageOpenWithCallback,http://localhost:49585
phantom stdout: responding:1,3,pageOpened,success
phantom stdout: responding:2,4,pageOpened,success
phantom stdout: responding:3,5,pageOpened,success
pageCall: callback-open, args: {"0":null,"1":"success"}, id: 1
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 1
pageCall: callback-open, args: {"0":null,"1":"success"}, id: 2
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 2
pageCall: callback-open, args: {"0":null,"1":"success"}, id: 3
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 3
phantom stdout: 1,6,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:1,6,pageEvaluated,null
phantom stdout: 2,7,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:2,7,pageEvaluated,null
phantom stdout: 3,8,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:3,8,pageEvaluated,null
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 1
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 2
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 3
pageCall: close, id: 1
phantomCall: createPage
phantom stdout: 1,9,pageClose
phantom stdout: responding:1,9,pageClosed
phantom stdout: 0,10,createPage
phantom stdout: responding:4,10,pageCreated
pageCall: start-open, args: {"0":"http://localhost:49585"}, id: 4
phantom stdout: 4,11,pageOpenWithCallback,http://localhost:49585
phantom stdout: responding:4,11,pageOpened,success
pageCall: callback-open, args: {"0":null,"1":"success"}, id: 4
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 4
phantom stdout: 4,12,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:4,12,pageEvaluated,null
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 4
pageCall: close, id: 4
phantomCall: createPage
phantom stdout: 4,13,pageClose
phantom stdout: responding:4,13,pageClosed
phantom stdout: 0,14,createPage
phantom stdout: responding:5,14,pageCreated
pageCall: start-open, args: {"0":"http://localhost:49585"}, id: 5
phantom stdout: 5,15,pageOpenWithCallback,http://localhost:49585
phantom stdout: responding:5,15,pageOpened,success
pageCall: callback-open, args: {"0":null,"1":"success"}, id: 5
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 5
phantom stdout: 5,16,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:5,16,pageEvaluated,null
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 5
pageCall: start-evaluate, args: {"0":"(function(){var a = 'success';});"}, id: 2
phantom stdout: 2,17,pageEvaluate,(function(){var a = 'success';});
phantom stdout: responding:2,17,pageEvaluated,null
pageCall: callback-evaluate, args: {"0":null,"1":null}, id: 2
pageCall: start-open, args: {"0":"http://tsenkovasdasdasdasd.net"}, id: 3
phantom stdout: 3,18,pageOpenWithCallback,http://tsenkovasdasdasdasd.net
phantom stderr: PhantomJS has crashed.
I haven't tested this on anything but OS X 10.9.
I hope someone will have an answer to this and thanks in advance to anyone that might try to solve it.