-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt Script issues #173
Comments
…or descriptor should set a default 'get' property when adding a 'set' property. Prevents crash in old Qt Script engine (WebKit).
I believe this is caused by having a |
Thanks for the detailed explanation the problem. Really strange - |
…or descriptor should set a default 'get' property when adding a 'set' property. Prevents crash in old Qt Script engine (WebKit).
@zloirock I just updated the PR to make it |
Nope, getter should be a function. |
Using
|
Ok. Can you revert it to
|
My use of I tried all the combinations of Your test fails for me:
I'm not sure where to go from here. I'll try and dig through some old WebKit bugs and see if there is anything in Should I give this a try? |
|
I think my use of core-js/modules/_object-assign.js Lines 10 to 19 in 7a90ad4
|
This list in not very encouraging: The |
I've reproduced the crash in a clean This code will cause a crash.
|
|
… for 'Object.defineProperty()' instead of an 'accessor descriptor'. Fixes RegExp.exec() creash in Qt Script.
@zloirock Any reason the I just changed my PR, #174 to do this:
Your test above works:
console output:
|
Looks like it is possible to change an object property to |
I think this might be the related bug in Qt Script/WebKit: Here's the part of the stack that has an infinite loop:
|
This is what I wrote in my previous comment.
Setters should prevent enumerability. The last line should be missed in the output. Please, try something like that for detection this bug: Object.defineProperty(Object.prototype, 'key', {
set: function(){ return 42 },
configurable: true
});
try {
/^([a-z0-9.+-]+:)/i.exec('foo:bar');
} catch(e){
console.log('buggy');
}
delete Object.prototype.key;
try {
/^([a-z0-9.+-]+:)/i.exec('foo:bar');
console.log('works');
} catch(e){} this detection: try {
Object.defineProperty(/./, 'key', {
get: function(){ throw 42; },
}).exec('');
} catch(e){
console.log('detected');
} and also this code (detection for another WebKit bug (maybe related)): console.log(Object.create(Object.defineProperty({}, 'a', {
get: function(){ return Object.defineProperty(this, 'a', {value: 7}).a; }
})).a === 7); |
undefined
Symbol()
. Causes RegExp.exec() to crash.Symbol()
polyfill causes RegExp.exec() to crash in old WebKit.
The last two detection tests do not crash the environment. The first one does crash the environment.
This crash cannot be caught with a try/catch. I've debugged the WebKit code in question and adding a getter or setter on Adding a getter or setter to Here's the call stack of the infinite loop: I've tried deleting the property on The bug appears to have something to do with this check: Before any getters or settings are defined, the call to At this point, I don't know of any work around for this. I think defining any getters or settings on |
It's simple to fix - just don't add setters to console.log(Object.create(Object.defineProperty({}, 'a', {
get: function(){ return Object.defineProperty(this, 'a', {value: 7}).a; }
})).a === 7 ? 'correct' : 'buggy'); If this detection will not work - need to find another way detection this platform. Can you try to find it? |
I removed creation symbol in |
Okay. That's good news. I wasn't sure if the Your test does not work. It returns
I found this bug is present in this engine:
Returns This one is also present:
Returns This one is also present, but you wouldn't be able to clean up I can probably find some more detection tests if those don't work. Please let me know. Also note that |
Safari 5 also fails these tests but works fine with |
@zloirock What about looking for some We could check for There is also |
@bendiy please, try it with this fix. |
The latest change does not crash, but I think there's something wrong with Symbols. Using your test above:
The Symbol is enumerated.
Should I blacklist Symbols in my build? |
Yep, with this fallback symbols should work in Qt Script, but they are enumerable like in engines without descriptors. I don't see another way. I don't think it's critical for this engine. |
Great. Thanks for all your help on this issue and your work on this wonderful library. |
Thanks for your help with fixing this problem :) |
This also fixed the crash I was getting with
|
@bendiy looks like this bug es-shims/es5-shim#365 |
@bendiy please, try it with this fix. |
OK. Will try in a minute. Here's the issue I'm seeing:
In Chrome, |
Nope, the fix didn't work. It still throws the same error. Here's what calls it:
Here: core-js/modules/es6.date.to-json.js Line 7 in f97bb26
|
Now? BTW can you check result of
This calling wrapped in |
No, same error. It's calling
I think what's going on here is that
|
Seems to work fine. |
Errors uncaught in |
Ok, for example, if you will change return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1 to return Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1 || new Date(NaN).toJSON() !== null the same error? |
Yes, same error. But, if I preload your |
Yep, I thought about it, but it will not work with commonjs entry points. Can you try to find a way to catch this error? If it will not work - I will just change the order of loading modules. |
If I run this before anything is loaded, it throws the uncaught exception.
However, if I just add a
So something is funky in the |
Ok. I had changed the order of loading in the config and entry points. Very interesting bugs in this engine :) |
Symbol()
polyfill causes RegExp.exec() to crash in old WebKit.
Seems to be working now.
Unfortunately, I doubt I've seen the last of the bugs. Probably why Qt is deprecating Qt Script in it's next release due out this month. Unfortunately, their new Thanks again for all of your help on this. |
Here's another issue with Qt Script that might be the original cause of the regexp crash:
Apparently I just wanted to log it here in case someone comes across this in the future. |
I'm adding the
core-js
polyfill to Qt's scripting environment, Qt Script.Qt Script
is a WebKit/JavaScriptCore engine that dates back to 2011.I've created the polyfill/shim with this command:
I have to blacklist a few modules as they cause issues/crashes:
es6.date.to-iso-string
es6.object.assign
es6.weak-map
es7.reflect
I'm trying to get
es6.object.assign
to work. If I do not include it in the blacklist, so it IS in the build, loading the polyfill crashes theQt Script
environment. I have tracked the crash down to this call toRegExp.exec()
:core-js/modules/es6.regexp.split.js
Line 18 in 7a90ad4
I have found that after the
Object.assign()
module callsSymbol()
, any call toRegExp.exec()
will crash the environment. The call toSymbol()
is located here:core-js/modules/_object-assign.js
Line 14 in 7a90ad4
Adding a simple
RegExp.exec()
call right after that line will crash the environment:The
Qt Script
environment appears to break whenObject.assign()
's call toSymbol()
callsObject.defineProperty()
whichsetSymbolDesc
is a reference to here:core-js/modules/es6.symbol.js
Line 55 in 7a90ad4
After that call, I see a new
Symbol
all over theprototype
of most objects (Array, Object, RegExp, etc.):Object.prototype
before call toSymbol()
:Object.prototype
after call toSymbol()
:Regexp.prototype
before call toSymbol()
:Regexp.prototype
after call toSymbol()
:Calling
var foo = Symbol();
anywhere seems to cause this problem as well. I'm not sure what the issue here is. ShouldObject.assign()
's call toSymbol()
pass it a parameter instead ofundefined
? There are no other calls toSymbol()
with anundefined
parameter in the full shim polyfill code.I believe this
Symbol()_g.dmlijp036315rk9
on theRegExp.prototype.__proto__
is causing the crash.The text was updated successfully, but these errors were encountered: