nw.js: Crashing when reading undefined variable inside a iframe script

(NWJS v0.15.0 sdk stable win x64) Example code:

"use strict";
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
setTimeout(()=>{ 
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = "my-script.js";
    iframe.contentWindow.document.head.appendChild(script);
},2500);

Inside my-script.js:

"use strict";
foo = UndefinedVariable; //The variable is undefined, the scripts loads fine and executes, 
// but nw.js crashes when the execution reach this point. No console.error is printed. Only crashes. 

debug.log

[0530/032119:ERROR:process_info.cc(608)] range at 0x10c740fe00000000, size 0x2ba fully unreadable
[0530/032119:ERROR:process_info.cc(608)] range at 0x10c7411e00000000, size 0x2ba fully unreadable
[0530/032119:ERROR:process_info.cc(608)] range at 0x0, size 0x2ba fully unreadable
[0530/032119:WARNING:in_range_cast.h(38)] value 2998168657146 out of range
[0530/032119:WARNING:in_range_cast.h(38)] value 2998168653368 out of range
[0530/032119:WARNING:in_range_cast.h(38)] value 2998168657186 out of range
[0530/032119:WARNING:in_range_cast.h(38)] value 108084205055182070 out of range
[0530/032119:WARNING:in_range_cast.h(38)] value 2998169270288 out of range

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 27 (10 by maintainers)

Most upvoted comments

@frankhale yeah I know. I’ll try to reproduce my situation in a small sample. Will test the above code now and come back with results.

Update hmm the above code doesn’t crash my build. When my crash happens again, I’ll be sure to make a note of what did it and try to reproduce the issue.

Yes and here it is : http://dl.nwjs.io/live-build/06-03-2016/nw15-024592f-5c2963f-0b926c0-42b9671/v0.15.2/

0.15.2 will be released in next week. You can use this build if you cannot wait. The quality of this build is same as releases according to our tests.

@rogerwang you probably saved our project. Can you let us know when we can expect next update, since this is very important issue for us?

Thank you in advance.

@rohan-deshpande you can try

process.on('uncaughtException', function uncaughtExceptionHandler(err) {
  console.error(err);
  process.stdout.write(err.message);
});