• 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
SIGBUS/SIGSEGV error problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SIGBUS/SIGSEGV error problems


  • Subject: SIGBUS/SIGSEGV error problems
  • From: Mike Brinkman <email@hidden>
  • Date: Mon, 11 Aug 2003 21:18:35 -0400

I can't figure out why this method is causing my application to crash:

- (void)updateSum
{
int i; // counter
float sum; // sum of NSNumbers
XObject *myObject;

sum = 0;

for (i = 0; i < [myArray count]; i++)
{
myObject = [[XObject alloc] init];
myObject = [myArray objectAtIndex:i];

// increment sum with floatValue of current object's amount
sum += [[myObject amount] floatValue];

// release myObject
[myObject release];
}

[sumField setFloatValue:sum];
}

All this method is supposed to do is sum the values from an NSNumber object
in an NSMuatableArray, and place the value in a field. XObject is a subclass
of NSObject. XObject releases all of its objects in its dealloc method and
calls [super dealloc].

updateSum gets called when I add another object to myArray. It works fine
with the [myObject release] method commented out, but I get a signal 10
(SIGBUS) error if it's there and I try to add another object to myArray. If
I try [myObject autorelease] I get a signal 11 (SIGSEGV) error.

Does myObject need to be released since it's a local instance of XObject?
I'm trying to be really careful about memory leaks.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: SIGBUS/SIGSEGV error problems
      • From: Stephane Le Cornec <email@hidden>
    • Re: SIGBUS/SIGSEGV error problems
      • From: Buddy Kurz <email@hidden>
    • Re: SIGBUS/SIGSEGV error problems
      • From: Koen van der Drift <email@hidden>
    • Re: SIGBUS/SIGSEGV error problems
      • From: Pete Yandell <email@hidden>
    • Re: SIGBUS/SIGSEGV error problems
      • From: Phill Kelley <email@hidden>
  • Prev by Date: Re: Question about poseAsClass
  • Next by Date: Re: GCC3?
  • Previous by thread: Re: Message number 3
  • Next by thread: Re: SIGBUS/SIGSEGV error problems
  • Index(es):
    • Date
    • Thread