FAQ  •  Register  •  Login

Screen corruption & possible crash (*solved*)

<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Sun Aug 15, 2010 2:43 pm

Screen corruption & possible crash (*solved*)

I wrote a function to transform Speccy frames to a timer:
  Code:
function Clock(tim as uinteger) as String
   dim secs as Uinteger
   dim mins,sec as ubyte
   dim s$ as String
   s$=""
   secs=int(tim/50)
   mins=int(secs/60)
   sec=secs mod 60
   s$=str(sec)
   if len(s$)=1 then
      s$="0"+s$
   end if
   return str(mins)+":"+s$
end function

dim a as uinteger
for a=0 to 1000
   print at 0,0;Clock(a)
next a

After calling it often (it shows effect around timecode 0:08), there was a screen memory corruption. In my full program the timer was still working, but the keys did not work anymore, and after that, even the minute display was corrupted. Maybe a overflow?
Reducing the Heap size from default to 100 caused no corrupted screen memory, but a complete crash.
Oh, and I'm using the latest devel version.

Edit:
It looks like there is a leak in the STR function, as without STR my program does not crash after a while.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

britlion

Posts: 680

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Mon Aug 16, 2010 9:16 pm

Re: Screen corruption & possible crash

I have a program that uses strings as input and output to functions (without being able to make data types, strings are easiest).

This program breaks badly, and I haven't been able to track where - the spectrum just resets; even with the debugging code in. I'm wondering if I'm hitting a similar problem. Hmm.
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Aug 16, 2010 10:15 pm

Re: Screen corruption & possible crash

This could be a nasty hard memory-corruption bug. I will check it deeply :? and tell you the results.
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Aug 19, 2010 11:07 pm

Re: Screen corruption & possible crash

LCD, I have discovered that, removing line
  Code:
s$ = ""

makes the program to run ok. :?: So this could be an easy bug to fix.
Meanwhile, can you check your program removing this line?
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri Aug 20, 2010 12:16 am

Re: Screen corruption & possible crash

boriel wrote:LCD, I have discovered that, removing line
  Code:
s$ = ""

makes the program to run ok. :?: So this could be an easy bug to fix.
Meanwhile, can you check your program removing this line?


I added this line only for testing. It still happen, but after a longer time, even longer if I remove DIM s$ as String.
This is the actual version of Clock Function:
  Code:
function Clock(tim as uinteger) as String
   dim mins,sec as ubyte
   dim secs as uinteger
   secs=int(tim/50)
   mins=int(secs/60)
   sec=secs mod 60
   m$=str(mins)
   if len(m$)=1 then
      m$="0"+m$
   end if
   s$=str(sec)
   if len(s$)=1 then
      s$="0"+s$
   end if
   return m$+":"+s$
   return str(int(tim/50))+" "
end function

Still causing a crash. After Meeting in Wittenberg this weekend, I can mail you the complete source code. After one minute (or less) of playing, the game locks up.
Sorry it it is not that easy.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Nov 12, 2010 11:08 pm

Re: Screen corruption & possible crash

Ok, back into this UltraNasty bug. It seems to be related to the STR$() function (which is already buggy in the Spectrum ROM, by the way).
I've investigated a bit further, and this code also crashes the same way, and it's much simpler:
  Code:
DIM i as Uinteger
DIM j as Uinteger = 0
Dim s as String

Function str0 as String
   s = ""
   s = str(j)
   return s
End Function

for i = 0 to 1000
    print str0()
next


Removing s = "" makes the program to take longer to crash. I guess this is related to the str( ) function. But need more work :?
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Sat Nov 13, 2010 1:45 am

Re: Screen corruption & possible crash

But at least, you know where it sits, the nasty bug. This means, there is a chance o fix it.
OK, it is buggy in Spectrum ROM, but it does not crash like that. Is there a special prize for finding nasty bugs, except beating until the guy who reported this bug forgets about this bug? ;) ;) ;)
Okay, I could shorten my bugtest source code a little bit, but I took it directly from a game which I write, and reduced it quickly a little bit to show what happens, just to be the first who reports it ;)
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Nov 14, 2010 12:48 am

Re: Screen corruption & possible crash

It seems already fixed.
Can you download the new fresh version 1.2.6-r1605 and try it? It is working to me now.
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Mon Nov 15, 2010 12:53 am

Re: Screen corruption & possible crash

boriel wrote:It seems already fixed.
Can you download the new fresh version 1.2.6-r1605 and try it? It is working to me now.

That was *Fast*. Thank you!
Today it is too late, but I will check it as soon as possible, probably tomorrow (Probably, because tomorrow I'm in the court in case of my broken leg).
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1158

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Nov 15, 2010 7:26 am

Re: Screen corruption & possible crash

In court???? :shock: I knew you broke your leg, but why going to court?

Anyway: It was the STR$ function. Note that VAL() also had this bug and has been fixed.
<<

LCD

Posts: 521

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Mon Nov 15, 2010 11:33 pm

Re: Screen corruption & possible crash

boriel wrote:In court???? :shock: I knew you broke your leg, but why going to court?

Because of months of pain (I still have pains when the weather changes). And the guy who is responsible for this even started to tell the witness lies about me. This will not be forgiven. It was a accident, so I wanted him to pay medicament costs, but now the situation changed apruptly after this.
boriel wrote:Anyway: It was the STR$ function. Note that VAL() also had this bug and has been fixed.

Oh, good, so one bugreport and two fixes. Maybe you know it already: You are great!

Edit: Tested, this bug is exterminated. It works now as expected. Big thanx to Boriel and good night.
The thread can be closed now.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO