Skip to content

Crashing in Javascript Core when setTimeout() is used #905

@bdkjones

Description

@bdkjones

Bryan here; guy behind CodeKit. I've tracked down an issue that I believe is attributable to JSHint. However, the explanation behind it is incredibly complicated so please bear with me.

Here's a screenshot of some Javascript code:

Screen Shot 2013-03-07 at 16 37 35

SUMMARY

See the two commented-out lines? Well, when I uncomment them, JSHint throws an exception when run in Javascript Core and fails to run. As soon as I comment the lines out, JSHint runs fine.

JSLint does not show the same problem; it runs correctly regardless of whether these lines are commented out. This indicates to me that Javascript Core is not the likely cause, since I can isolate the crash to JSHint exclusively.

The interesting part is that if I copy/paste the entire code into the textbox at JSHint.com and run it there, JSHint runs correctly. If I run JSHint on the file from the command line (using node.js), it also runs fine. This implies that there's something going on specifically with JSHint running in Javascript Core --- some sort of incompatibility or issue that only appears when JSHint is running inside Javascript Core.

EXCEPTION INFO

Here's the exception that Javascript Core throws when JSHint crashes on the code above. This is literally all the information it provides:

JavascriptCore Exception thrown: ReferenceError: Can't find variable: console on line 105 of (null)

I don't believe the issue is in my app, since I use the exact same code to run JSLint and that works just fine every time.

CONTENT BETWEEN QUOTES

The plot thickens. If I modify one of these "setTimeout" lines to look like this:

Screen Shot 2013-03-07 at 16 54 57

JSHint now runs correctly. However, as soon as I add any content between those quotation marks (other than a space), the exception is thrown and JSHint fails. Literally anything inside the quotes will do it --- a single letter, a function name, etc.

I've tried all sorts of various edits to these lines and this is what I've narrowed it down to. As long as nothing but spaces appear inside the quotation marks, JSHint runs fine.

EXAMPLE FILES

The link below will take you to Dropbox, where I have posted a zip file containing two files. The first is the exact file as I received it from one of my users, with no changes. The second file is one where I have commented out each "setTimeout" line until I got JSHint to run correctly. You can use a file-difference tool to see the exact lines I commented out.

Link: http://dl.dropbox.com/u/25530182/jsHint_files/files.zip

Please let me know if I can provide any additional information. Thanks for looking into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions