divyang4481 / firebreath

Automatically exported from code.google.com/p/firebreath
0 stars 0 forks source link

Crash when a javascript exception is thrown in an event or other javascript callback #102

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
 * FireBreath version: 1.3.0rc3.
 * Issue tested with FireFox and Chrome

As posted on the mailing list:

In C++, I have my API class derived from JSAPIAuto and in a method of
this class, I call FireEvent:

void MyClass::MyMethod()
{
    FB::VariantMap event;
    event["member"] = "Valid Member";
    FireEvent("onTestEvent", FB::variant_list_of(event));
}

In Javascript, I respond to this event:

function onTestEvent(event) {
    alert( event );  // This is okay
    alert( event.member );  // This is okay and display "Valid Member"
    alert( event.abc );  // This will display null because we didn't
define it
    alert( event.abc.xyz ); // This dereferences the null member and will
crash the plug-in
}

In other Javascript functions, dereferencing a null value in this way
simply stops executing the Javascript, but when responding to the
FireEvent() method it causes the plug-in to crash.

Original issue reported on code.google.com by georg.fritzsche on 8 Nov 2010 at 1:03

GoogleCodeExporter commented 8 years ago

Original comment by georg.fritzsche on 8 Nov 2010 at 1:03

GoogleCodeExporter commented 8 years ago
to be clear, this issue is not actually caused by "dereferencing an invalid 
member" as it may seem at first.  The actual issue I believe would be caused by 
anything you do to cause a javascript exception to occur inside the 
callback/event in javascript.

The variable "event" is not actually plugin code; it's converted to an actual 
javascript object before the function call and can be treated as such.

Can you put a try ... catch block around your code in onTestEvent to verify 
that this is caused by an exception?  I should be able to look at it later this 
week, possibly Tuesday.

Original comment by taxilian on 8 Nov 2010 at 4:46

GoogleCodeExporter commented 8 years ago
I am not able to reproduce this; I suspect that we have fixed it with one of 
the recent bugfixes as a side-effect.

Original comment by taxilian on 9 Nov 2010 at 10:14

GoogleCodeExporter commented 8 years ago

Original comment by taxilian on 9 Nov 2010 at 11:43

GoogleCodeExporter commented 8 years ago
As suggested, I've tested firebreath-stable-1.3-nightly73 and I can confirm 
that the problem no longer occurs. Many thanks.

Original comment by Steven.K...@gmail.com on 17 Nov 2010 at 11:59

GoogleCodeExporter commented 8 years ago
awesome.

Original comment by taxilian on 17 Nov 2010 at 3:41