Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

HTML tmLanguage causes crash #4

Closed
matiaskorhonen opened this issue Jun 25, 2015 · 0 comments
Closed

HTML tmLanguage causes crash #4

matiaskorhonen opened this issue Jun 25, 2015 · 0 comments

Comments

@matiaskorhonen
Copy link

The HTML tmLanguage file causes SyntaxKit to crash on "<h1 title='Hello Title'>Hello World!</h1>\n" .

My code:

let path = NSBundle.mainBundle().pathForResource("HTML", ofType: "tmLanguage")!
let plist = NSDictionary(contentsOfFile: path)! as [NSObject: AnyObject]
let html = Language(dictionary: plist)!
let parser = Parser(language: html)

let input = "<h1 title='Hello Title'>Hello World!</h1>\n"

parser.parse(input) { scope, range in
    print("\(scope) - \(range)")
}

I used the HTML plist from TextMate's html.tmbundle.

It managed to output:

meta.tag.block.any.html - (0,24)
punctuation.definition.tag.begin.html - (0,1)
entity.name.tag.block.any.html - (1,2)
punctuation.definition.tag.end.html - (23,1)

And then crashed with:

2015-06-25 20:37:35.479 MyOSXApp[2481:41424] An uncaught exception was raised
2015-06-25 20:37:35.479 MyOSXApp[2481:41424] *** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: Range or index out of bounds
2015-06-25 20:37:35.479 MyOSXApp[2481:41424] (
    0   CoreFoundation                      0x00007fff9411f03c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8cbc876e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9411eeed +[NSException raise:format:] + 205
    3   Foundation                          0x00007fff96a1951e -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 365
    4   Foundation                          0x00007fff96a19398 -[NSRegularExpression(NSMatching) matchesInString:options:range:] + 162
    5   SyntaxKit                           0x00000001005d75c2 _TFC9SyntaxKit6ParserP33_3B8D38F1D3A332B2216177DC3565447D5parsefS0_FTSS7inRangeVSC8_NSRange5scopeGSqSS_10expressionSS8capturesGSqVS_17CaptureCollection__GSqVS_9ResultSet_ + 898
    6   SyntaxKit                           0x00000001005d6c13 _TFC9SyntaxKit6ParserP33_3B8D38F1D3A332B2216177DC3565447D5parsefS0_FTSS7inRangeVSC8_NSRange8callbackFT5scopeSS5rangeS1__T__Su + 3091
    7   SyntaxKit                           0x00000001005d5eeb _TFC9SyntaxKit6Parser5parsefS0_FTSS5matchFT5scopeSS5rangeVSC8_NSRange_T__T_ + 715
    8   MyOSXApp                            0x000000010003885e _TFC12MyOSXApp16WindowController13windowDidLoadfS0_FT_T_ + 2414
    9   MyOSXApp                            0x0000000100038992 _TToFC12MyOSXApp16WindowController13windowDidLoadfS0_FT_T_ + 34
    10  AppKit                              0x00007fff8d6d5947 -[NSWindowController _windowDidLoad] + 586
    11  CoreFoundation                      0x00007fff9402bbdf -[NSSet makeObjectsPerformSelector:] + 223
    12  AppKit                              0x00007fff8d53511b -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1166
    13  AppKit                              0x00007fff8d70fa0e -[NSNib _instantiateNibWithExternalNameTable:options:] + 677
    14  AppKit                              0x00007fff8d70f65e -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 143
    15  AppKit                              0x00007fff8dc5955c -[NSStoryboard instantiateControllerWithIdentifier:] + 181
    16  AppKit                              0x00007fff8d50bf74 NSApplicationMain + 840
    17  MyOSXApp                            0x000000010000ac27 main + 87
    18  libdyld.dylib                       0x00007fff97c925c9 start + 1
)
2015-06-25 20:37:35.480 MyOSXApp[2481:41424] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: Range or index out of bounds'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff9411f03c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8cbc876e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9411eeed +[NSException raise:format:] + 205
    3   Foundation                          0x00007fff96a1951e -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 365
    4   Foundation                          0x00007fff96a19398 -[NSRegularExpression(NSMatching) matchesInString:options:range:] + 162
    5   SyntaxKit                           0x00000001005d75c2 _TFC9SyntaxKit6ParserP33_3B8D38F1D3A332B2216177DC3565447D5parsefS0_FTSS7inRangeVSC8_NSRange5scopeGSqSS_10expressionSS8capturesGSqVS_17CaptureCollection__GSqVS_9ResultSet_ + 898
    6   SyntaxKit                           0x00000001005d6c13 _TFC9SyntaxKit6ParserP33_3B8D38F1D3A332B2216177DC3565447D5parsefS0_FTSS7inRangeVSC8_NSRange8callbackFT5scopeSS5rangeS1__T__Su + 3091
    7   SyntaxKit                           0x00000001005d5eeb _TFC9SyntaxKit6Parser5parsefS0_FTSS5matchFT5scopeSS5rangeVSC8_NSRange_T__T_ + 715
    8   MyOSXApp                            0x000000010003885e _TFC12MyOSXApp16WindowController13windowDidLoadfS0_FT_T_ + 2414
    9   MyOSXApp                            0x0000000100038992 _TToFC12MyOSXApp16WindowController13windowDidLoadfS0_FT_T_ + 34
    10  AppKit                              0x00007fff8d6d5947 -[NSWindowController _windowDidLoad] + 586
    11  CoreFoundation                      0x00007fff9402bbdf -[NSSet makeObjectsPerformSelector:] + 223
    12  AppKit                              0x00007fff8d53511b -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1166
    13  AppKit                              0x00007fff8d70fa0e -[NSNib _instantiateNibWithExternalNameTable:options:] + 677
    14  AppKit                              0x00007fff8d70f65e -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 143
    15  AppKit                              0x00007fff8dc5955c -[NSStoryboard instantiateControllerWithIdentifier:] + 181
    16  AppKit                              0x00007fff8d50bf74 NSApplicationMain + 840
    17  MyOSXApp                            0x000000010000ac27 main + 87
    18  libdyld.dylib                       0x00007fff97c925c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

The crash seems to be happening on line 103 of Parser.swift

Parsing worked fine when I tested SyntaxKit with the YAML plist included in the SyntaxKit fixtures.

This is on OS X 10.10.3 with Xcode 7 beta 2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant