4 Replies - 230 Views - Last Post: 03 August 2012 - 02:15 PM Rate Topic: -----

#1 Behemyth  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 19-July 12

Stack Overflow and a Seed

Posted 03 August 2012 - 12:38 PM

I have a procedural program that creates a puzzle from a seed. As usual this seed is derived from the system time and I use it to debug a specific puzzle if I want to revisit it. Recently though, an error occurs very so often "An unhandled exception of type 'System.StackOverflowException' occurred in IceMaze.exe. A index in the program greatly exceeds the bound of the array that it is tied with. I then examine the trace point I placed in VC++ and derive the seed number from that. Strangely, after I enter the seed and run the program it works with no flaws and the index is within bounds. While I wont be able to give any code, are there any general problems that might be occurring in a situation like this? Also, when I run the program with a desired seed, the output is the same as expected.

Is This A Good Question/Topic? 0
  • +

Replies To: Stack Overflow and a Seed

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,008
  • Joined: 05-May 12

Re: Stack Overflow and a Seed

Posted 03 August 2012 - 12:45 PM

I'm confused how you can "examine the trace point I placed in VC++ and derive the seed number from that." Are you logging the random seed that you are using?

The last time I saw your code, I though I remember seeing a srand() call within a loop. Did you move it out of the loop?

This post has been edited by Skydiver: 03 August 2012 - 12:46 PM

Was This Post Helpful? 0
  • +
  • -

#3 Behemyth  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 19-July 12

Re: Stack Overflow and a Seed

Posted 03 August 2012 - 02:04 PM

In the output, the trace point gives a value every time the point is passed, so yes. I do not have a srand() called within a loop, but a goto statement restarts the program if the procedural maze hits a dead end.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is online

  • member icon


Reputation: 4019
  • View blog
  • Posts: 12,408
  • Joined: 25-December 09

Re: Stack Overflow and a Seed

Posted 03 August 2012 - 02:14 PM

Quote

While I wont be able to give any code, are there any general problems that might be occurring in a situation like this?

Quote

but a goto statement restarts the program

To me this (goto) is an indication of bad program design. Is this why you won't provide any code?


It sounds like you are not properly initializing a variable somewhere. Insure all your variables are properly initialized when you create them.

Jim

This post has been edited by jimblumberg: 03 August 2012 - 02:17 PM

Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,008
  • Joined: 05-May 12

Re: Stack Overflow and a Seed

Posted 03 August 2012 - 02:15 PM

Chances are you have one or more uninitialized variables. You'll have to review your code closely.

Or you may have a variable that initialized, but you recycle it without resetting it to it's initial value.

I suggest implementing my original suggestion in the other thread and either switch to using vector<>, or implement your own wrapper around that two dimensional array so that you can monitor all the array indices being used.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1