Closed Bug 700421 Opened 8 years ago Closed Last year

Syntax errors in xpcom components aren't reported

Categories

(Core :: XPConnect, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED INACTIVE

People

(Reporter: florian, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

A syntax error in the JS file of an xpcom component causes it to fail to load, but there's no error message related to the actual error (neither in the error console, nor in the terminal on debug builds).

The only visible error (Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]) doesn't help at all. This bug is causing significant (and recurrent) wastes of time for several developers (I had the confirmation on IRC while asking for a workaround that at least 2 other people had already painfully become aware of this bug in past experiences).


Notes:
 - Reference errors from code executed during the initialization of the service were correctly reported during my testing. The bug seems only on syntax errors.
 - I observed this on a Mac debug build based on Mozilla 7.
 - For the readers looking for a workaround rather than willing to fix the bug, here is how I finally found my syntax error (after wasting over an hour and a half looking for the error / a way to locate it) : ./xpcshell component/<component-name>.js
 That gave me a very clear "SyntaxError: missing ) after argument list" error message with location information.
Would be great to have exacts steps to reproduce (with some example component).
jdm's been doing work on this kind of stuff over in bug 463122. Maybe he might be interested in taking a crack at this one too? :-)
Attached patch testcase (obsolete) — Splinter Review
This is enough to reproduce on a current mozilla-central debug builds.
In the error console, at startup I see:

Error: [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  location: "JS frame :: file:/// ... /NightlyDebug.app/Contents/MacOS/components/nsDefaultCLH.js :: clh_handle :: line 44"  data: no]
Source File: file:/// ... /NightlyDebug.app/Contents/MacOS/components/nsDefaultCLH.js
Line: 44

If I paste this in the error console:
Components.classes["@mozilla.org/broken;1"].getService();
The result is:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  location: "JS frame :: javascript:%20Components.classes["@mozilla.org/broken;1"].getService(); :: <TOP_LEVEL> :: line 1"  data: no]


However, if I execute:
./xpcshell components/broken.js

The result I see is:
components/broken.js:4: SyntaxError: missing ; before statement:
components/broken.js:4:   dump("test"));

components/broken.js:4: ..............^
Comment on attachment 582116 [details] [diff] [review]
testcase

You're missing broken.js from the patch, right?
Attached patch testcaseSplinter Review
(In reply to Josh Matthews [:jdm] from comment #5)
> Comment on attachment 582116 [details] [diff] [review]
> testcase
> 
> You're missing broken.js from the patch, right?

yes, forgot to hg add, sorry about that :(.

The content of that file isn't very important, I first tested with a file containing only one ) character and it gave the same result. I later changed the content to something more likely to be a valid component with a syntax error, so that the xpcshell error looked like a real error.
Attachment #582116 - Attachment is obsolete: true
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.