Out of Stack Space Error 28
Hi guys.
I've been using the Martins VB - A Program Registration Scheme for a while and it works ok.
The problem is its all numbers e.g. -0074612515 I want to make it alphanumeric.
#178
As that link says there is a good app on PSC Unique Serial Number Protection **UPDATED AGAIN - Version 1.5**
This uses multiple textboxes to show different ways to show the code. I've taken out the parts that I want and the app works and compiles. Now when I've tried it recently its giving an Out of Stack Space Error 28.
https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
I haven't changed the code much. There are only 2 functions Invert and iSplit from the PSC app along with a dozen variables, all declared.
I've looked at Monitoring the Call Stack
That says From the View menu, choose Call Stack, there is no Call Stack in the View menu. I've run Debug mode but that doesn't help.
How can I get rid of this Out of Stack Space Error 28?
The main purpose of this app is for a Keygen for another app that checks the hard drive serial number against the serial number they enter in. If valid they have access to all the database, it not they can only see 2000 items. As I've said the PSC app uses multiple textboxes to show different codes. In the main app I want to use a function that checks the serial number is valid. I would have to make an array of what's in the textboxes.
Re: Out of Stack Space Error 28
Quote:
How can I get rid of this Out of Stack Space Error 28?
Install more stack space? Stop using so much stack?
How the heck should we know? You're not a noob, so you're not getting any slack from me... not even any stack either ... you know better than to post about what's wrong and not supply the code in question...
99% of the time there's an out of stack error it's because something is recursive and didn't provide an exit condition, or it gets cause in an infinite loop where sub1 calls sub2 calls sub3 calls sub4 calls event which triggers sub1, repeat ad nauseum.
-tg
Re: Out of Stack Space Error 28
Yeah, techgnome's answer almost has to be correct. That's what I was thinking even before I read his reply.
Runaway recursion is clearly the fastest way to gobble up all of your stack.
Another way is an incorrectly declared API call, but that's more likely to just cause a GPF hang, rather than out-of-stack-space. But it's something to check.
Also, there are ways to do recursion other than a procedure (somewhere down the line) calling itself. I'd have to research to be sure, but things like Mid() on left-side and/or possibly Replace() may get into recursive situations. I'm always careful to avoid those, but I know they exist.
Regards,
Elroy
Re: Out of Stack Space Error 28
Thanks for the comments guys.
I've been using VB for the past 20 years and that's the first time I've had the Out of Stack Space Error 28 error.
I've had an app with 80 Forms and hundreds of variables and that ran ok and compiled.
The only API I use is:
Code:
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
To get the hard drive serial number.
I could post my app if its needed.
Re: Out of Stack Space Error 28
That does not get the hard drive serial number, only the volume serial number which is a soft value a user can change fairly easily. It isn't a secure thing to use to fingerprint a PC for license enforcement, though it might be good enough for your purposes.
Getting actual drive serial numbers is a far more complex process.
The most common cause of stack overflows in VB is the use of the DoEvents() function. Usually it occurs when you have controls that can raise events based on "external stimuli" for example MSComm and Winsock. But DoEvents() is always evil in this way and should be avoided at all costs. When you must use it you have to disable all controls that could raise an event, but controls like Winsock can't be disabled.
2 Attachment(s)
Re: Out of Stack Space Error 28
Keithuk,
My main application has over 200 forms on it. It doesn't sound like the number of forms or the number of variables is the problem.
Can't you get the line of code that's crashing???
For instance, I started a new project, and then put the following code into the Form1:
Code:
Option Explicit
Private Sub Form_Load()
Call InfiniteRecursion
End Sub
Private Sub InfiniteRecursion()
InfiniteRecursion
End Sub
And then I ran it, and got:
Attachment 141005
And then I click "Debug" and get:
Attachment 141007
You should be able to show us something similar. If you want to zip and post your project, I'll take a look, but I'd rather stare at snippets of your code.
Regards,
Elroy
Re: Out of Stack Space Error 28
Ok Elroy that code gives Out of Stack Space Error 28. What does InfiniteRecursion do as its not a VB function?
The Debug window is a bit of a pain as you can't select anything once the error occurs.
When you run this app you copy and paste the hard drive number in a textbox then click a button which txtHDDSN.Text = txtHDDSN.Text * -1, which removed the negative.
Then you click another button Generate Unique Request Code (SN + PID) this adds another 24 numbers to the hard drive number. The you click Alpha Replacement Sequence button to find the alphanumeric number of the new Generate Unique Request Code (SN + PID).
As I've said the original PSC codes has multiple textboxes Text3 to Text17 to show different parts of the code. Some shuffled, some reversed. I put all the alpha textboxes Text13 to Text17 separated by - to show all numbers together in a txtFullAlpha textbox.
I didn't really want to click different buttons I wanted to copy and paste the drive number you want the alphanumeric number for so I added cmdAlpha_Click under the HDDSN button. I REM this out and it works without the Out of Stack Space Error 28.
As I've said if you want to check out Unique Serial Number Protection **UPDATED AGAIN - Version 1.5**
Re: Out of Stack Space Error 28
Hi Keithuk,
Quote:
Originally Posted by
Keithuk
What does InfiniteRecursion do as its not a VB function?
InfiniteRecursion is the Sub procedure that you see. It's calling itself, endlessly. That's the simplest form of recursion (a procedure calling itself). What happens is, it pushes the return address on the stack, and then executes. However, since it's recursing, it again pushes its return address on the stack over and over and OVER until stack space runs out. That's just the easiest way to show an "Out Of Stack Space" error.
Quote:
Originally Posted by
Keithuk
The Debug window is a bit of a pain as you can't select anything once the error occurs.
I wasn't really talking about the Debug (Immediate) Window. I was talking about clicking the Debug button once the error occurs. When you do this, the IDE should show you the exact line of code that caused the error. Knowing what line it is (and some of the surrounding code) typically identifies the precise cause of the error. Also, when in this Stop/Debug mode, you can still hover over variables and get their values.
Quote:
Originally Posted by
Keithuk
txtHDDSN.Text = txtHDDSN.Text * -1, which removed the negative.
A much better way to remove the negative would be: txtHDDSN.Text = Abs(txtHDDSN.Text). Your code will actually make an initially positive number negative.
Quote:
Originally Posted by
Keithuk
As I've said if you want to check out Unique Serial Number Protection **UPDATED AGAIN - Version 1.5**
I'm not really up for downloading that project, especially since I don't know exactly which line of code you're having a problem with. Maybe someone else will.
I do wish you the best of luck with it though.
Regards,
Elroy