Microdrive - Classic lib - "4 OUT OF MEMORY, 10:3"

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
thweasel
Member
Posts: 15
Joined: Sun Oct 14, 2018 11:32 am

Microdrive - Classic lib - "4 OUT OF MEMORY, 10:3"

Post by thweasel »

Hi,

Think I found a bug? When reading sectors on the microdrive, one after another (scanning the tape) after ~14 sectors the program crashes "4 OUT OF MEMORY, 10:3". I guess scanning the sectors in this way is the only way to get an index of the tape contents? And the expected behavior should be the contents of the CHAN_M struct buffer is overwritten with each call.

The code here is starting at sector 70 and trying to read to 100, we get 83 when it pops.

Test code being used : https://github.com/thweasel/Microdrive_ ... src/main.c

Checked the addresses and using pointers and direct passing the Struct, both seem to fail in the same way.


Any help or pointers welcome, totally stumped.

Owen
stefano
Well known member
Posts: 1635
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I'm not totally sure, but shouldn't it be safer not to adjust the pointer:
pMD=&MD
..within the loop ?
stefano
Well known member
Posts: 1635
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Nope, it shouldn't matter. Sorry, I'm clearly under a social network syndrome :D
stefano
Well known member
Posts: 1635
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

bug confirmed. There's definitely a relevant memory leak on any mdv sector access, probably close_m is not invoked or is not doing what I expected. I'll first test if1_read_record to verify if it is acting similarly, this should help the bug tracking.
stefano
Well known member
Posts: 1635
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

solved. it should be already available in the toady 's copy of the nightly builds.
thweasel
Member
Posts: 15
Joined: Sun Oct 14, 2018 11:32 am

Post by thweasel »

I forgot about this post in the manic Christmas and job change!!

Cheers Stefano, I haven't actually progressed to the point of loading out a known file and seeing what would happen (using if1_read_record). I will update Z88DK and give it another run see what happens.
thweasel
Member
Posts: 15
Joined: Sun Oct 14, 2018 11:32 am

Post by thweasel »

Spot on, from the initial test my sector scanning code now passes the point it failed at! Excellent work, thanks Stefano :)
stefano
Well known member
Posts: 1635
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

No problem.
I think I created the problem while trying to understand an odd condition you'll probably run into: the record number, when reading a sector is forced to the same value of the sector number. :(

I can't explain this myself, on the z88dk library side I'm only picking the sector data and referring to it with a struct skeleton. I should do one more experiment to determine whether the record number is used only on the "PRINT" files (stream based) only, but in that case I miss the way a binary file is being sorted.
Post Reply