Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6561291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:34:08+00:00 2026-05-25T13:34:08+00:00

Long story short, I am developing a simple game, and I have a Game

  • 0

Long story short, I am developing a simple game, and I have a Game object that keeps track of the current game state, as well as some additional things that are useful/required later on. One of these is a reference to the UIViewController that loaded the game, which is simply declared as a property on the object:

@interface Game : NSObject {
    //ivars
}

@property (nonatomic, retain) myViewController* viewController;

The getters/setters for this property are generated using @synthesize viewController, and all seems well.

Now there are only two paths through which this property is accessed, when the game is won and when the game is lost. The “game is lost” path works fine. The “game is won” path is causing a bizarre error in which the value of the viewController pointer seems to get overwritten with garbage.

In order to figure out what is going on, I overrode the getters and setters as follows:

- (myViewController*) viewController {
    NSLog(@"Getting");
    return viewController;
}

- (void) setViewController:(myViewController*)controller {
    NSLog(@"Setting");
    viewController = controller;
}

…and set breakpoints inside (I know I’m not retaining the view controller is my setter, but that is not the issue; the view controller remains on the stack and does not actually need to be retained by Game). Here is what I got in GDB:

//first call to setter
po controller
<myViewController: 0x9208130>

//call to getter on the "game is lost" path
(gdb) po viewController
<myViewController: 0x9208130>

//call to setter, starting a new game from the same view controller
(gdb) po controller
<myViewController: 0x9208130>

//call to getter on the "game is lost" path
(gdb) po viewController
0xbea2222c does not appear to point to a valid object.
(gdb) print viewController
$1 = (myViewController *) 0xbea2222c

So at some point, the value of the pointer was changed from 0x9208130 to 0xbea2222c, but I can’t figure out where. There is no code that assigns into the viewController property (or its backing ivar) apart from the call to the setter at the start of the game. Yet clearly something is overwriting the value with garbage on the “game is won” path.

Is this possibly a buffer overrun issue? If so what is a good approach for tracking it down?

Edit

I added a second pointer (as an ivar in another class) that I set to the value of game.viewController at the start of play, and using this pointer for the “game is won” path works. So it appears to me that something is trashing the original pointer. Still no idea what, however.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:34:09+00:00Added an answer on May 25, 2026 at 1:34 pm

    It does not look like there is enough data to diagnose the problem from the information you have posted.

    If you want to further debug this problem, I suggest setting a break point on the address in memory of the pointer ivar. That way you will be notified if it is somehow changed outside of your setter’s use.

    You can accomplish this by breaking at some point during your Game objects creation and selecting to “Watch Variable” on the Game object’s controller ivar.

    Alternatively, asksol has a good example of using gdb in a similar fashion external from Xcode in response to another question here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long story short, I'm developing a theme template for a blog that enables you
Long story short, I have a substantial Python application that, among other things, does
Long story short, I have a struct (see below) that contains exactly one field:
Long story short, I have a SQL file that I want to import as
Long story short, VSS decided I wasn't allowed to have some code changes. I
Long story short*, I did some things with my git repository that I don't
Long story short, I have two regex patterns. One pattern matches things that I
Ok folks.. long story short, I was developing on a computer that I no
Long story short, because of some issues with architecture and the fact that someone
Long story short, I'm making a racing game in Java. I'm self-taught using some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.