bugGNUstep - Bugs: bug #8498, [MinGW] NSUnarchiver crashes

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #8498: [MinGW] NSUnarchiver crashes

Submitted by:  Willem Rein Oudshoorn <wim>
Submitted on:  Thu 08 Apr 2004 09:45:58 AM UTC  
 
Category: Base/FoundationSeverity: 2 - Minor
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: Willem Rein Oudshoorn <wim>
Open/Closed: Closed

Sat 12 Feb 2005 03:21:54 PM UTC, comment #5:

Closed as there was no more feedback in the last year.

Fred Kiefer <FredKiefer>
Project Member
Sun 11 Apr 2004 06:43:18 AM UTC, comment #4:

I fixed the bug in NSNumber and added a simple mechanism for retaining decoded objects ... store them in an NSMutableArray until the NSUnarchiver is deallocated.

Richard Frith-Macdonald <CaS>
Project Member
Sun 11 Apr 2004 03:39:49 AM UTC, comment #3:

I have attached a modified version of the original example which causes a segfaul in NSUnarchiver.m when unarchiving an NSNumber object.

I believe that this is because the NSNumber object is released and, since NSNumber objects are cached, this causes an issue when the object is subsequently reused.

I am reverting the previous fix until this problem is corrected. GJC

Gregory John Casamento <gcasa>
Project Administrator
Fri 09 Apr 2004 10:29:40 AM UTC, comment #2:

The attached patch should fix this.
It will retain the objects in the objMap and release them
when clearing the map. But note that we really need
to be carefull when retaining the objects, otherwise code like

- initWithCoder:..
{
[self dealloc];
return something_else;
}

will crash the unarchiver.
This rules out the replacement of objMap with an
NSArray.

If nobody objects I will commit this shortly.

Wim Oudshoorn.

Willem Rein Oudshoorn <wim>
Project MemberIn charge of this item.
Thu 08 Apr 2004 11:58:05 AM UTC, comment #1:

Actually, it is a generic bug, Linux is just lucky!
The bug is as follows:
NSUnarchiver has an ivar, "objMap" which is a map
from "ref" to "Objects". However the the "Objects"
are NOT retained. This means that if they are deallocated
the reference in this map becomes invalid. Solution is
to retain the objects in this map.

Willem Rein Oudshoorn <wim>
Project MemberIn charge of this item.
Thu 08 Apr 2004 09:45:58 AM UTC, original submission:

It seems that if you call release on an decoded object
that is shared with other objects lead to a crash.

In particular:

Obj1 ---> string
Obj2 ----/

and if in initWithCoder of Obj1 (and Obj2) we have:

[coder decodeValuesOfObjCType: "@", &string];
[string release];

the decoding crashes.
The funny thing is that this seems to be a windows
specific problem. It works fine on Linux.

The attached program will demonstrate the problem:

./TestCoder Encode test.enc

this will create test.enc

./TestCoder Decode test.enc

which decodes the created test.enc. This crashes
on MinGW but not on Linux and the generated
files test.enc are identical, so it is probably
in de unarchiving code.

Willem Rein Oudshoorn <wim>
Project MemberIn charge of this item.

 

Attached Files
file #1203:  testCoderWithNumber.tar.bz2 added by gcasa (2KiB - application/x-bzip2 - Illustrates the problem with encoding numbers.)
file #1196:  NSUnarchiver.patch added by wim (2KiB - application/octet-stream - Patch to retain temporary the objects so initwithcoder can release them)
file #1192:  testCoder.tar.bz2 added by wim (2KiB - application/octet-stream - Demonstrating crash.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 6 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sat 12 Feb 2005 03:21:54 PM UTCFredKieferOpen/ClosedAnalyzed=>Closed
Sun 11 Apr 2004 06:43:18 AM UTCCaSStatusNone=>Fixed
Sun 11 Apr 2004 03:39:49 AM UTCgcasaAttached File-=>Added testCoderWithNumber.tar.bz2, #1184
Fri 09 Apr 2004 10:30:19 AM UTCwimOpen/ClosedOpen=>Analyzed
Fri 09 Apr 2004 10:29:40 AM UTCwimAttached File-=>Added NSUnarchiver.patch, #1177
Thu 08 Apr 2004 09:45:58 AM UTCwimAttached File-=>Added testCoder.tar.bz2, #1173

Back to the top


Powered by Savane 3.1-cleanup1