Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 04:37 27 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMiteWEB V5.07.07a24+ - Now with TFTP

     Page 2 of 5    
Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5903
Posted: 09:33am 14 Mar 2023
Copy link to clipboard 
Print this post

I spoke too soon:
Connected

*** PANIC ***

Out of Heap memo

After 15 reports.

JIm
VK7JH
MMedit   MMBasic Help
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 09:35am 14 Mar 2023
Copy link to clipboard 
Print this post

Thanks Jim. I will try your proposal after my ongoing test is done.

What about the buff%()? Should it be emptied between the updates? I suppose not.
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 09:52am 14 Mar 2023
Copy link to clipboard 
Print this post

Tested with updating only one location every second minute. Crashed after 15 updates. Checked openweathermap and it allows 60 calls per minute; so that should not be a problem.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 10:03am 14 Mar 2023
Copy link to clipboard 
Print this post

We need to narrow down the cause. If you write a simple json parser in Basic rather than using the json$ function does that fix it?
json$() uses the system heap. It is third party code and is supposed to clean up after itself but who knows
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 10:03am 14 Mar 2023
Copy link to clipboard 
Print this post

Tested with DIM buff%(1024) and updates each 15s to save time. PANIC after 15 updates.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 10:45am 14 Mar 2023
Copy link to clipboard 
Print this post

FYI:
I also had a ***Panic*** error message when using JSON (V5.07.07a16). But only with certain JSON data from Openweathermap (which I don't want to pass on unedited because of ID). I'm pretty sure it's a JSON issue. I will test it again on the CMM2.
Regards
Michael
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 10:53am 14 Mar 2023
Copy link to clipboard 
Print this post

  Quote  I will test it again on the CMM2.

The CMM2 is very different. It uses MMBasic heap rather than system heap and cleans up regardless after each call so the two aren't comparable. The PicoMite can't do the same thing.
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 10:53am 14 Mar 2023
Copy link to clipboard 
Print this post

Yes it seems to be a JSON issue. I removed all JSON statements and just retrieved the the data. Updating did not stop (no PANIC). Printed the buff%(); looks like this:
RUN
ntp address 195.148.70.12
got ntp response: 14/03/2023 12:51:22
****************Update nbr:     1
tcp address 188.166.16.132
Connected
488
2478231517896319611
4189032028242606906
3184384918481155378
3474028082218757154
2462480755104232238
2482157843938108791
4189021006120835898
7593470440261300280
8462101260445295214
8315162384941609828
........
etc
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5903
Posted: 10:55am 14 Mar 2023
Copy link to clipboard 
Print this post

I added this (and the memory command)
Print "Heap: ";Hex$(MM.Info(stack)),MM.Info(HEAP)

Heap: 200413E8  78080

Heap and memory didn't change. Still crashed after 15 calls.

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 11:04am 14 Mar 2023
Copy link to clipboard 
Print this post

I think I may have found something. Are you parsing something that comes back as an empty string?
This can happen if it is an array (rather an array element) or some other things in json I don't understand (raw, object , null)

If you are then there is a possible memory leak which will eventually cause the issue. If so I can then probably fix it.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 11:34am 14 Mar 2023
Copy link to clipboard 
Print this post

Try it without this

TEXT 0,120,"Regn: "+Json$(buff%(),"rain.1h")+" mm/h"


You can see the returned data with

  Quote  longstring print buff%()


and you will see that rain.1h doesn't exist. I should be protecting against this error but I think this is the problem
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 11:36am 14 Mar 2023
Copy link to clipboard 
Print this post

In fact I removed it just before your message!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 11:40am 14 Mar 2023
Copy link to clipboard 
Print this post

V5.07.07a25


PicoMiteWebV5.07.07a25.zip


Fixes memory leak in json$ function if the naughty user requests a field that doesn't exist
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 329
Posted: 11:44am 14 Mar 2023
Copy link to clipboard 
Print this post

Naughty user send big THANKS to Peter, Jim & TwoFingers!
22 updates now and no PANIC.

Will now go over to a25.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 02:57pm 14 Mar 2023
Copy link to clipboard 
Print this post

Btw.
I think there are still (crash) problems with A25. Not associated with JSON. I test ...

Some OT for Openweathermap:
' Windrose converts a degree cardinal direction into a compass direction.

Degree=360-11
Print Degree, windrose16$(Degree)
End

Function windrose16$(Degree)
Local WD$(16)=("NNO","NO","ONO","O","OSO","SO","SSO","S","SSW","SW","WSW","W",
"WNW","NW","NNW","N","NNO")

windrose16$=WD$(Int(((Degree+360*(Degree<11.25))-11.25)/22.5))

End Function
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 03:05pm 14 Mar 2023
Copy link to clipboard 
Print this post

Didn't crash for me
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 116
Posted: 03:53pm 14 Mar 2023
Copy link to clipboard 
Print this post

In:
"Windows MMBasic Version 5.07.03b15
...

 349
Error in line 8: Expected closing bracket"

Michal
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 03:59pm 14 Mar 2023
Copy link to clipboard 
Print this post

@Peter

Please try this:
MFile$="ABC"
path$=".\nsa8\"+MFile$
End

For me it causes a crash.

Michael

Edit:
Works:
a$="test"+"TEST"
End

Crashes:
a$="\"+"test"  'crash
End

Edited 2023-03-15 02:32 by twofingers
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 712
Posted: 05:00pm 14 Mar 2023
Copy link to clipboard 
Print this post

  twofingers said  @Peter

Please try this:
MFile$="ABC"
path$=".\nsa8\"+MFile$
End

For me it causes a crash.

Michael

Edit:
Works:
a$="test"+"TEST"
End

Crashes:
a$="\"+"test"  'crash
End


Commit:
MFile$="ABC"
> path$=".\nsa8\"+MFile$

CRASH
RESET

>
> print mm.ver
5.070723
>
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3658
Posted: 05:33pm 14 Mar 2023
Copy link to clipboard 
Print this post

Now that \ starts an escape you need to change the strings.

(Ideally it wouldn't crash, though.)

John
 
     Page 2 of 5    
Print this page
© JAQ Software 2024