Memory-overwrites
Nick Mueller
Posts: 815
Hi!
I know that this is a *very* unprecise question and that your answers will be even more vague. But I'll give it a try:
Writing an application, I see from time to time that I'm getting memory overwrites. I'm using the TV-object and when I do get an overwrite, I get fancy patterns in one of the screen's corners. Well, moving things around, I sometimes happen to fix them. Ain't the right way, I know!
The worst case I have now is with including the OBJ "keyboard". Just by the sole OBJ-statement (without any initialisation) my app doesn't start.
Now where do I have to look at?
The stack? But I only have one cock running my app and another one running some ASM I wrote.
I tried to write padding arrays of longs to see who might be the cause, but didn't help.
TIA,
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
I know that this is a *very* unprecise question and that your answers will be even more vague. But I'll give it a try:
Writing an application, I see from time to time that I'm getting memory overwrites. I'm using the TV-object and when I do get an overwrite, I get fancy patterns in one of the screen's corners. Well, moving things around, I sometimes happen to fix them. Ain't the right way, I know!
The worst case I have now is with including the OBJ "keyboard". Just by the sole OBJ-statement (without any initialisation) my app doesn't start.
Now where do I have to look at?
The stack? But I only have one cock running my app and another one running some ASM I wrote.
I tried to write padding arrays of longs to see who might be the cause, but didn't help.
TIA,
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Comments
The causes of this kind of behavior are legion. The best way to find the problem is to carefully go through the code checking that your assumptions about addresses, subscripts, stack sizes, etc. are actually followed rather than just assumed. Strange or odd problems can be due to stack overflow, but usually are not.
<G> I didn't want to hear that answer.
What I'd like to know is, that are pitfalls specific to SPIN. I'm (or was) familiar with many languages (and their pitfalls). So I do already pay attention to indices.
If I still don't get an answer I like, I'll try to boil it down and post the code.
Thanks,
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 4/11/2007 11:32:33 PM GMT
I bet it is my error, but really don't have even the slightest clue where it is.
This example is quite boiled down, so you don't have to wade through lots of code. I have put comments where the problems appear (two traps)
Hope that someone of the (more than me) enlightened ones can help me.
TIA!
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Post Edited (Nick Mueller) : 4/13/2007 1:50:40 PM GMT
I have found one error on init colors. You have lost the index on left side of this expression.
That was discarded by the HTML-formatter (or whoever). The "[noparse][[/noparse] i ]" was interpreted as format-in-italic. Putting blanks around the i fixed that.
It is in the code.
I have fixed the posting of the code to display the brackets.
Thanks,
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Post Edited (Nick Mueller) : 4/13/2007 1:58:07 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thanks, I'm aware of that and did check (albeit, I didn't post it). I do have more than 6000 stack/free.
That should be enough?
Even if I include a "_STACK = 200"*) and compile, it hangs when just including/importing the keyboard.spin-OBJ.
Could someone actually compile my code and say what I did wrong? I know that I sound dumb, but I also know, that I'm programming since decades.
*)
That's something really puzzling me. Reading in the printed manual at page 107 it says that it will explain more, but I can't find more about it. I'm aware that there is some Stack-checker available (filling with A5-pattern). OTOH, I can't see why 6000 longs free shouldn't be enough.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
It looks like you're not actually using the graphics except to display text. There's a text-only display driver for TV output that takes very little memory. Have a look at "tv_text.spin" and "tv_text_demo.spin". There's also a more capable windowed text display routine by Phil Pilgrim (see: http://forums.parallax.com/showthread.php?p=590631).
Ah! graphics just takes the memory without some kind of defining/claiming it at compile-time. I have to do that by hand. Right?
> It looks like you're not actually using the graphics except to display text.
Well, I need the characters in different sizes. And maybe some lines. I'll try the single-buffered.
Thanks
Nick (more RAM!)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Now I found my error.
Taking an N-th look at Graphics_Demo, I see the _stack statement claiming the memory for the bitmap and the buffer. And -tata!- it no longer compiles.
Thanks for your helping hands!
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.