• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reference Count Underflow when Writing PDF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reference Count Underflow when Writing PDF


  • Subject: Reference Count Underflow when Writing PDF
  • From: K.Darcy Otto <email@hidden>
  • Date: Wed, 15 Jul 2009 14:00:26 -0700

I have a PDF that I've loaded, combined with another PDF, and now I'm ready to save the result as a new file. My program is using garbage collection, but I understand that PDFKit is not garbage collected. The problem is that I get reference count underflow error when writing the PDF. Here is some code that is shorter, but creates the same problem I'm having:

// Get PDF from disc
NSData *savedData = [[NSData alloc] initWithContentsOfFile:@"oldfile.pdf" options:0 error:&error];
PDFDocument *savedDoc = [[PDFDocument alloc] initWithData:savedData];


// Write saveDoc to file
[savedDoc writeToFile:@"newfile.pdf"];

Actually, there is no problem when writing the file: newfile.pdf is intact after the operation. But I get the following error in the console:

malloc: reference count underflow for 0x13464c0, break on auto_refcount_underflow_error to debug.

And when I break on auto_refcount_underflow, I get the following stack:

#0 0x94721a40 in auto_refcount_underflow_error
#1 0x9472d8e4 in Auto::Zone::dec_refcount_small_medium
#2 0x9472d9b0 in Auto::Zone::block_decrement_refcount
#3 0x931da50c in CFRelease
#4 0x904bfe4c in -[PDFDocument(PDFDocumentInternal) writeToConsumer:withOptions:]
#5 0x904bd9fc in -[PDFDocument writeToURL:withOptions:]
#6 0x904bd97c in -[PDFDocument writeToFile:withOptions:]
#7 0x00006b60 in -[MyDocument openPanelDidEnd:returnCode:contextInfo:] at MyDocument.m:495


Now, #3 suggests there is a release going on that shouldn't be; or at least there should be an extra retain in my code. But when I add "CFRetain(savedDoc);" before writing the file, the error still persists. I've read the Semantics section of Using Core Foundation with Garbage Collection, but I don't see a solution to this problem there (I'm not saying it's not there, just that I don't quite see it). Any help would be greatly appreciated.
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Reference Count Underflow when Writing PDF
      • From: "K. Darcy Otto" <email@hidden>
  • Prev by Date: Re: Efficiency of loading Localizable.strings and NSUserDefaults
  • Next by Date: Re: Plain Text Kind
  • Previous by thread: Re: Plain Text Kind
  • Next by thread: Re: Reference Count Underflow when Writing PDF
  • Index(es):
    • Date
    • Thread