bugGNUstep - Bugs: bug #27311, Keyed archiving related exceptions...

Group
 
 

bug #27311: Keyed archiving related exceptions with NSScrollView

Submitter:  Quentin Mathé <qmathe>
Submitted:  Mon 24 Aug 2009 04:32:42 PM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  FredKiefer
Open/Closed:  Declined
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 27 Aug 2009 11:42:09 AM UTC, comment #2: 

Hi Fred,

Thanks for the explanation :-) My conclusion was too quick indeed.

After further investigations, I found the problem was elsewhere. It seems there is a problem when a scrollview with no visible vertical scroller is unarchived. I attached a patch and an updated test example which gives me a 'nil subview insertion' exception.

The stack trace is:
#0  -[NSException raise] (self=0x9c015d0, _cmd=0xb7a8ea60) at NSException.m:835
#1  0xb78f8181 in +[NSException raise:format:arguments:] (self=0xb7a8e840, _cmd=0xb7a8ea48, name=0xb7a8e5d0,
    format=0xb7ed7e40, argList=0xbfadb40c "`k�\t") at NSException.m:785
#2  0xb78f80be in +[NSException raise:format:] (self=0xb7a8e840, _cmd=0xb7ed8fa8, name=0xb7a8e5d0,
    format=0xb7ed7e40) at NSException.m:771
#3  0xb7d6e22e in -[NSView addSubview:positioned:relativeTo:] (self=0x9c010e0, _cmd=0xb7ed9168, aView=0x0,
    place=NSWindowAbove, otherView=0x0) at NSView.m:709
#4  0xb7d6e1c4 in -[NSView addSubview:] (self=0x9c010e0, _cmd=0xb7eb4880, aView=0x0) at NSView.m:696
#5  0xb7d1c92e in -[NSScrollView initWithCoder:] (self=0x9c010e0, _cmd=0xb7a99188, aDecoder=0x9c040e8)
    at NSScrollView.m:1600
#6  0xb79176d0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x9c040e8, _cmd=0xb7a99148, index=3)
    at NSKeyedUnarchiver.m:219
#7  0xb7917109 in -[NSKeyedUnarchiver(Internal) _decodeArrayOfObjectsForKey:] (self=0x9c040e8,
    _cmd=0xb7a661f8, aKey=0xb7a656d8) at NSKeyedUnarchiver.m:114
#8  0xb7837934 in -[GSMutableArray initWithCoder:] (self=0x9c01080, _cmd=0xb7a99188, aCoder=0x9c040e8)
    at GSArray.m:541
#9  0xb79176d0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x9c040e8, _cmd=0xb7a99148, index=2)
    at NSKeyedUnarchiver.m:219
#10 0xb791a1cf in -[NSKeyedUnarchiver decodeObjectForKey:] (self=0x9c040e8, _cmd=0xb7ed9820, aKey=0xb7ed7f60)
    at NSKeyedUnarchiver.m:600
#11 0xb7d7cd6f in -[NSView initWithCoder:] (self=0x9c00e90, _cmd=0xb7a99188, aDecoder=0x9c040e8)
    at NSView.m:4507
#12 0xb79176d0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x9c040e8, _cmd=0xb7a99148, index=1)
    at NSKeyedUnarchiver.m:219
#13 0xb791a1cf in -[NSKeyedUnarchiver decodeObjectForKey:] (self=0x9c040e8, _cmd=0xb7a991b8, aKey=0xb7a98b4c)
    at NSKeyedUnarchiver.m:600
#14 0xb7917e14 in +[NSKeyedUnarchiver unarchiveObjectWithData:] (self=0xb7a98fc0, _cmd=0xb6f111a8,
    data=0x9c05e60) at NSKeyedUnarchiver.m:316

I think the problem is invisible most of the time because scroll views (especially the ones created in Gorm) tends to use a vertical scroller by default.
I'm not sure to fully understand the scroll view unarchiving code, I added several notes/questions in the patch itself.
The scroll view archives/unarchives its subviews, at least that's what I expect, so I don't see why -addSubview: vScroller was added here.

For the plist generator, why not define an enum { GSPLGeneratorWritingSuccess, GSPLGeneratorWritingTableIndexFull } and use it as the return type of -writeObject:, -storeObject: and -markOffset:for:.
Then in -generate, you can do:

  while (!done && (index_size <= 4))
    {
  [self setup];
  if ([self writeObjects] == GSPLGeneratorWritingTableIndexFull)
            {
      [self cleanup];
      index_size += 1;
    }
          else // GSPLGeneratorWritingSuccess
            {
              done = YES;
            }
    }


(file #18649, file #18650)

Quentin Mathé <qmathe>
Group Member
Mon 24 Aug 2009 07:10:51 PM UTC, comment #1: 

Hi Quentin,

as far as I can tell this in no bug, not even a real problem. Have a look at the code in [BinaryPLGenerator generate] there I have to decide which index size to use. This depends on the number of objects involved and as I don't know that in advance I start off small and increase the number when needed. When there isn't enough space in the index table an exception will be raised and a bigger index size gets used. Not the best programming practice I admit, if you have any better solution it is more then welcome.

This is why you only get the exception with gdb (And I even failed to get it there).

Fred Kiefer <FredKiefer>
Group Member
Mon 24 Aug 2009 04:32:42 PM UTC, original submission:  

Base and Gui r28524 - Ubuntu 9.04 x86 - GCC 4.3.3

To serialize a scroll view with NSKeyedArchiver doesn't seem to work well when this view was loaded from a gorm file. The crash doesn't happen immediately but a bit later.

I attached a test app that shows the problem.

When you run the test app, no exception is logged. However when the same test app is run inside GDB with a breakpoint on -[NSException raise], GDB stops on an exception.
NSArchiver appears to work fine as no exception can be detected with or without GDB.

The code that leads to the crash is:
[NSKeyedArchiver archivedDataWithRootObject: scrollView]

If I create a simple scroll view with [[NSScrollView alloc] initWithFrame:] and tries to serialize it, GDB breaks on -[NSKeyedUnarchiver unarchiveObjectWithData:] rather than on the archiving phase as described previously. So the issue doesn't seem to be only related to the nib/gorm loading.

Here is the test app stack trace:

2009-08-24 15:50:56.439 Test[21969] Try unarchiving: <NSScrollView: 0x91ea3c8>
[Switching to Thread 0xb73b28d0 (LWP 21969)]

Breakpoint 1, -[NSException raise] (self=0x91e43c0, _cmd=0xb7afaa60)
    at NSException.m:835
835   if (_reserved == 0)
(gdb) bt
#0  -[NSException raise] (self=0x91e43c0, _cmd=0xb7afaa60) at NSException.m:835
#1  0xb7964181 in +[NSException raise:format:arguments:] (self=0xb7afa840,
    _cmd=0xb7afaa48, name=0xb7afa600, format=0xb7b1a6d8, argList=0xbff63c20 "")
    at NSException.m:785
#2  0xb79640be in +[NSException raise:format:] (self=0xb7afa840, _cmd=0xb7b1b048,
    name=0xb7afa600, format=0xb7b1a6d8) at NSException.m:771
#3  0xb79df3d0 in -[BinaryPLGenerator markOffset:for:] (self=0x91e0ff8,
    _cmd=0xb7b1b2d0, offset=2157, object=0x918aba0) at NSPropertyList.m:3226
#4  0xb79e1154 in -[BinaryPLGenerator storeObject:] (self=0x91e0ff8, _cmd=0xb7b1b250,
    object=0x918aba0) at NSPropertyList.m:3741
#5  0xb79df265 in -[BinaryPLGenerator writeObjects] (self=0x91e0ff8, _cmd=0xb7b1b310)
    at NSPropertyList.m:3209
#6  0xb79e1464 in -[BinaryPLGenerator generate] (self=0x91e0ff8, _cmd=0xb7b1b240)
    at NSPropertyList.m:3784
#7  0xb79decdb in +[BinaryPLGenerator serializePropertyList:intoData:] (
    self=0xb7b1aa80, _cmd=0xb7b1b150, aPropertyList=0x91e0620, destination=0x91e0730)
    at NSPropertyList.m:3132
#8  0xb79db110 in +[NSPropertyListSerialization dataFromPropertyList:format:errorDescription:] (self=0xb7b1ace0, _cmd=0xb7b04048, aPropertyList=0x91e0620, aFormat=200,
    anErrorString=0xbff63e40) at NSPropertyList.m:2251
#9  0xb7981d62 in -[NSKeyedArchiver finishEncoding] (self=0x9136d58, _cmd=0xb7b03f80)
    at NSKeyedArchiver.m:804
#10 0xb797ecd1 in +[NSKeyedArchiver archivedDataWithRootObject:] (self=0xb7b03da0,
    _cmd=0x804aba0, anObject=0x92620c8) at NSKeyedArchiver.m:450
#11 0x08048aeb in -[Controller applicationDidFinishLaunching:] (self=0x90ee648,
    _cmd=0xb7e6e018, notif=0x91ea300) at Controller.m:16
#12 0xb799cf49 in -[NSNotificationCenter _postAndRelease:] (self=0x8efafc8,
    _cmd=0xb7b0afc8, notification=0x91ea300) at NSNotificationCenter.m:1161
#13 0xb799d86b in -[NSNotificationCenter postNotificationName:object:userInfo:] (
    self=0x8efafc8, _cmd=0xb7b0afd0, name=0xb7f16a60, object=0x8ff6ab0, info=0x0)
    at NSNotificationCenter.m:1220
#14 0xb799d722 in -[NSNotificationCenter postNotificationName:object:] (self=0x8efafc8,
    _cmd=0xb7e6db00, name=0xb7f16a60, object=0x8ff6ab0) at NSNotificationCenter.m:1200
#15 0xb7c1b05c in -[NSApplication _didFinishLaunching] (self=0x8ff6ab0, _cmd=0xb7e6dc88)
    at NSApplication.m:1139
#16 0xb7c1c3b7 in -[NSApplication run] (self=0x8ff6ab0, _cmd=0xb7e63040)
    at NSApplication.m:1456
#17 0xb7bfbbbd in NSApplicationMain (argc=1, argv=0xbff64564) at Functions.m:74
#18 0x08048c2e in main (argc=Cannot access memory at address 0x1b0004
) at main.m:13

Quentin.

Quentin Mathé <qmathe>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #18649:  KeyedArchiverTableViewTest.tar.gz added by qmathe (3KiB - application/x-gzip)
file #18635:  KeyedArchiverTableViewTest.tar.gz added by qmathe (40KiB - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Posted a comment)
  • -email is unavailable- added by qmathe (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-08-27 qmathe Attached File- Added KeyedArchiverTableViewTest.tar.gz, #18649
        Attached File- Added NSScrollView-archiving.m.patch, #18650
    2009-08-24 FredKiefer StatusNone Invalid
        Assigned toNone FredKiefer
        Open/ClosedOpen Declined
    2009-08-24 qmathe Attached File- Added KeyedArchiverTableViewTest.tar.gz, #18635

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code