NSRunStorage and _NSBlockNumberForIndex exceptions...

  • Hi,

    In my program I have been getting the following error message in the debugger console from time to time:

    2007-11-11 21:10:11.269 AppName[39092:813] Exception raised while text storage 0x126ab1d0 was responding to font set changed notification:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16572) beyond array bounds (16571)
    2007-11-11 21:10:11.273 AppName[39092:813] Exception raised during background layout:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16572) beyond array bounds (16571)

    My app holds a number of documents and you can browse through them (basically like an outliner). It uses an NSTextStorage subclass to display these documents, which does nothing special other than provide a running word count. The above exceptions occur apparently randomly, but are clearly associated with a particular document in the app: the index and bounds numbers match with a text that has an NSFormFeedCharacter as the first character, though I have tried inserting this character at the beginning of other texts to see if loading them throws a similar exception with little luck so far. The exception usually occurs when browsing through documents in a different window, or when the window containing this document either loses or gains focus.

    It looks as though it could be my text storage subclass, I suppose, which can be downloaded here:

    http://www.literatureandlatte.com/freestuff/KBWordCountingTextStorage.zip

    If anyone has any ideas about what might be causing this, I would be very grateful (this is running on Leopard, btw).

    Thanks and all the best,
    Keith

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
  • After more testing, it looks as though this is a bug in the text system and not specifically in my text storage code. There seems to be something in this particular piece of text (brought in from Word) that is causing problems for the text system. To test, I created a very simple text storage based on Ali Ozer's code here:

    http://www.cocoabuilder.com/archive/message/cocoa/2002/2/5/14848

    I put it into a text view, loaded the text that was causing problems, and straight away got the same error:

    2007-11-11 23:03:28.244 TextStorageCrashTest[41297:813] Exception raised while text storage 0x1bc840 was responding to font set changed notification:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16289) beyond array bounds (16289)

    2007-11-11 23:03:28.265 TextStorageCrashTest[41297:813] Exception raised during background layout:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16289) beyond array bounds (16289)

    And so on. Then I started replacing random characters in the problem text in TextEdit ready to send off for a bug report (to garble the content), and ran into exactly the same error on the console for TextEdit.

    For anyone interested, the test project that shows this bug can be downloaded here:

    http://www.literatureandlatte.com/dlbeta/TextStorageCrash.zip

    (Just open the app and then, after the window appears, click New to open a new window loaded from the same file, and watch the errors appear on the console.)

    Off to file a bug report right now...

    All the best,

    Keith

    --- ORIGINAL MESSAGE ---

    Hi,

    In my program I have been getting the following error message in the debugger console from time to time:

    2007-11-11 21:10:11.269 AppName[39092:813] Exception raised while text storage 0x126ab1d0 was responding to font set changed notification:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16572) beyond array bounds (16571)

    2007-11-11 21:10:11.273 AppName[39092:813] Exception raised during background layout:  *** NSRunStorage, _NSBlockNumberForIndex(): index (16572) beyond array bounds (16571)

    My app holds a number of documents and you can browse through them (basically like an outliner). It uses an NSTextStorage subclass to display these documents, which does nothing special other than provide a running word count. The above exceptions occur apparently randomly, but are clearly associated with a particular document in the app: the index and bounds numbers match with a text that has an NSFormFeedCharacter as the first character, though I have tried inserting this character at the beginning of other texts to see if loading them throws a similar exception with little luck so far. The exception usually occurs when browsing through documents in a different window, or when the window containing this document either loses or gains focus.

    It looks as though it could be my text storage subclass, I suppose, which can be downloaded here:

    http://www.literatureandlatte.com/freestuff/KBWordCountingTextStorage.zip

    If anyone has any ideas about what might be causing this, I would be very grateful (this is running on Leopard, btw).

    Thanks and all the best,

    Keith

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today