Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Micromite MMBasic Ver 5.04.10 Beta Post ReplyPost New Topic
<< Prev Page of 6 Next >>
Author
Message << Prev Topic | Next Topic >>
disco4now
Guru
Guru


Joined: 18 December 2014
Location: Australia
Online Status: Offline
Posts: 306
Posted: 11 October 2018 at 8:20pm | IP Logged Quote disco4now

out of memory errors when a string was passed to a SUB or FUNCTION
An error fixed in 5.04.08 now appears in 5.04.09 and 5.04.10 Beta9
with MX170 chip.


Change log for Micromite MMBasic Ver 5.04.08  

Bug Fixes:                                            

      * Corrected a bug which caused EXIT DO to skip the first line after the LOOP command.  

      * Corrected a bug which caused EXIT FOR to fail if the whole FOR loop was on a single line  
        (with colons as command separators).  

    * Fixed a bug which could cause out of memory errors when a string was passed to a SUB or  FUNCTION.  


The code below loops forever on 5.04.08
Running on 5.04.09 or 5.04.10 beta9 it fails with Error: Not enough memory
on the third iteration of the loop


Quote:
Option Explicit
DIM STRING cleartext
DIM integer gain1(4)=(257,247,225,180,22)
DIM integer x

do
x=x+
1
DisplayValue
300,134,"CH1 "+str$(gain1(0))+" "+str$(gain1(1))+" "+str$(gain1(2))+" "+str$(gain1(3))+" "+str$(gain1(4))
print x
loop

SUB DisplayValue x As integer, y As integer, s As STRING
'TEXT x,y,cleartext,CM,fStandard,,RGB(blue),RGB(blue)
'TEXT x,y,s,CM,fStandard,,RGB(white),cBGnd
cleartext=string$(len(s)," ")
END SUB



The error showed up when I upgraded a larger program, but this code is enough to
reproduce it. An LCD is not required, just an MX170 chip with MMMbasic.

Can someone confirm they get the same thing.

Regards
Gerry





Back to Top View disco4now's Profile Search for other posts by disco4now
 
Vito
Newbie
Newbie


Joined: 11 October 2016
Location: Australia
Online Status: Offline
Posts: 16
Posted: 11 October 2018 at 8:45pm | IP Logged Quote Vito

Yes on version 5.4.1

Something is not freeing RAM after executing SUB.

Place a memory statement after x=x+1 in DO loop, will print whats happening to RAM.

Option Explicit
DIM STRING  cleartext
DIM integer gain1(4)=(257,247,225,180,22)
DIM integer x

do
 x=x+1
 Memory
 DisplayValue 300,134,"CH1 "+str$(gain1(0))+" "+str$(gain1(1))+" "+str$(gain1(2))+" "+str$(gain1(3))+" "+str$(gain1(4))
 print x
loop

SUB DisplayValue x As integer, y As integer, s As STRING
  'TEXT x,y,cleartext,CM,fStandard,,RGB(blue),RGB(blue)
  'TEXT x,y,s,CM,fStandard,,RGB(white),cBGnd
  cleartext=string$(len(s)," ")
END SUB
Back to Top View Vito's Profile Search for other posts by Vito
 
disco4now
Guru
Guru


Joined: 18 December 2014
Location: Australia
Online Status: Offline
Posts: 306
Posted: 14 October 2018 at 4:44pm | IP Logged Quote disco4now

Hi Geoff,

Here is another code snippet that runs OK under 5.04.08 but fails under 5.04.09 and 5.04.10 beta 9.

It is using the longstring Cfunctions.Not sure if it is connected to out of memory error above or something different.

Quote:
' This code run OK on MMbasic 5.04.08 however
'it fails on MMBasic 5.04.09 and 5.04.10 Beta9
CONST longStringMaxLen=4096
option autorun on

dim float htmlBuffer(longStringMaxLen/4)
dim AS INTEGER i

readHTMLTemplate

?
"DONE",mm.ver
end

sub readHTMLTemplate
LOCAL string A(16)
for i= 1 to 16
A(i)=
string$(254,"X")
next i

SClear htmlBuffer()

for i = 1 to 16
? i,
" - ";
pause 1000
SAddStr htmlBuffer(), A(i)
? SLen(htmlBuffer())
next i
end sub

CSub SAddStr float, string
00000000
10800011 00000000 10A0000F 00000000 90A30000 8C820000 00623021 1060000A
AC860000
24420004 00822021 24A50001 00831821 90A20000 A0820000 24840001
1483FFFC 24A50001 03E00008 00000000
end CSub

CSub SClear float
00000000 54800001 AC800000 03E00008 00000000
end CSub

CFunction SLen (float) INTEGER
00000000
10800005 00003821 8C860000 00C01021 03E00008 00E01821 00003021 00C01021
03E00008 00E01821
end CFunction





It gives the following error

> RUN
 1      -  254
 2      -  508
 3      -  762
 4      -

CPU exception #6 (bus error on ifetch) at address 0x58585858
Processor restarted


It originally came to light here

Regards
Gerry




Edited by disco4now on 14 October 2018 at 4:45pm
Back to Top View disco4now's Profile Search for other posts by disco4now
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 22 October 2018 at 4:41pm | IP Logged Quote Geoffg

Thanks guys, both examples fail for me also.

This is half the battle - getting something simple that demonstrates the problem. Now that I have this I can start chasing the cause.

I will get back to you.

Geoff

Edited by Geoffg on 22 October 2018 at 4:46pm
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 26 October 2018 at 2:59pm | IP Logged Quote Geoffg

I have figured out what is going wrong here (thanks for the demo code - it made it so much easier to track down the problem).

The first is the bug reported by disco4now which caused an out of memory error when a string was repeatedly passed to a SUB or FUNCTION. This was caused by a memory leak introduced when I was optimising the performance of MMBasic for V5.04.09. I plan to put out a new beta version soon and the fix will be in that.

This just goes to show that every change to the core MMBasic code also runs the real risk of introducing new bugs. This is most annoying because after years of chasing bugs MMBasic is quite solid if left alone.

The second bug also reported by disco4now caused a CPU exception when a string was repeatedly passed to a CSUB or CFUNCTION. This is more complicated so bear with me while I explain it:

When using the Long String Library the memory for each long string was supposed to be declared as an array of floats and this array was passed to the CSUBs to be manipulated as a long string. Unfortunately this caused an exception in V5.04.09 because of a bug in the code for passing an array of floats. This is something I will also fix this in the next beta.

However, using an array of floats for a long string has its own issue. The Micromite Plus now uses double precision so each float is eight bytes whereas the standard Micromite still uses single precision floats of four bytes each. This means that a program written for the Micromite will allocate double the memory on the Micromite Plus. Rather than requiring programmers to write different code for each version I have modified the Long Strings documentation to state that the memory for a long string should be declared as an array of integers (which is a consistent eight bytes per integer). This is the new doco for Long Strings: 2018-10-26_143801_Long_Strings.pdf

Because the bug that affected disco4now code was related to passing arrays of floats this new version of the Long Strings Library (using integers) also works as a workaround for the bug reported by disco4now above.

Geoff
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 446
Posted: 26 October 2018 at 3:16pm | IP Logged Quote Azure

Hi Geoff,

That is a very clear description of what was going wrong, thanks for that, it helps us novice users increase our understanding of MMBasic.

There is a minor typo in the document, the description of SLCase, it is written as "SULase str".
Back to Top View Azure's Profile Search for other posts by Azure
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 444
Posted: 26 October 2018 at 5:48pm | IP Logged Quote Paul_L

Brilliant work Geoff!
Geoffg wrote:
This just goes to show that every change to the core MMBasic code also runs the real risk of introducing new bugs. This is most annoying because after years of chasing bugs MMBasic is quite solid if left alone.

You can say that again.

Paul in NY
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
jman
Guru
Guru
Avatar

Joined: 12 June 2011
Location: New Zealand
Online Status: Offline
Posts: 687
Posted: 28 October 2018 at 5:56pm | IP Logged Quote jman

Hi Geoff

I assume the out of memory error from the code below is due to the issue reported above. (No long strings)


Do
 Test "2.54"
 Memory
Loop

Sub Test(E$)
  Pause 25
End Sub



RAM:
   0K ( 0%) 0 Variables
  14K (27%) General
  36K (73%) Free
[2] Test "2.54"
Error: Not enough memory



Regards

Jman
Back to Top View jman's Profile Search for other posts by jman
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 28 October 2018 at 11:48pm | IP Logged Quote Geoffg

Hi John, yes it is.

I have just checked your test code on my current in house beta and it runs fine. I will be turning this into a public beta for people to download in a few days.

Geoff
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 29 October 2018 at 2:26pm | IP Logged Quote Geoffg

I have a new version of the Micromite beta firmware V5.04.10 (Beta 10) and it can downloaded from: http://geoffg.net/micromite.html
Look for "Micromite Firmware V5.04.10 Beta Test Version" at the bottom of the page.

This version (Beta 10) mostly adds bug fixes and covers everything that has been reported to date. Especially important is a fix for the "Out of memory" errors that kept cropping up in V5.04.09 and later beta versions. The file Change Log.pdf in the zip file contains the details.

I will give this a couple of weeks and if nothing serious has turned up I will make it into a final release. If you do find any issues or bugs in this beta please report them in this thread and I will try to fix them ASAP.

Thanks to everyone for the past bug reports,
Geoff
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 444
Posted: 29 October 2018 at 2:44pm | IP Logged Quote Paul_L

Geoffg,

Thanks again from all of us for working so assiduously on this major project!

Will you be turning V5.04.10 into a DOS version anytime soon?

Paul in NY
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 29 October 2018 at 3:52pm | IP Logged Quote Geoffg

Yes, the download referred to above contains the DOS version of V5.04.10 (Beta 10).
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 


<< Prev Page of 6 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.12