BBC BASIC
« Program Crashes in BASIC routine! »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:39pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Program Crashes in BASIC routine!  (Read 209 times)
Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx Program Crashes in BASIC routine!
« Thread started on: Jan 26th, 2018, 8:14pm »

HELP, HELP, HELP.

I have come to a grinding halt on my 3D design program.
It has developed a bug, which crashes the program during a BASIC procedure (PROCmultinodebox approx. line no. 16805)

I am not expecting anyone to get immersed in the code but if some one could offer a possible solution I would be very grateful.

The code can be found here

https://1drv.ms/f/s!AqibHqCkE1VQllkSrc7Jifpn2wZS

To cause the crash:

Load "Multiple Nodes VI(testing) I"

add quick object (keep it simple like a cube)
highlight object by clicking on the cube
rotate whole project
change rotate target to object and own centre
rotate the object a few times
select highlight multiple nodes
draw box around cube

the program should crash.

I have looked for memory leaks and obvious things like running out of memory but to no avail.

Can you help?

An aside :- What circumstances would cause "!loop = 0" to throw the error "address out of range" and yes I have a DIM loop 3 declaration.

Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Program Crashes in BASIC routine!
« Reply #1 on: Jan 26th, 2018, 9:24pm »

on Jan 26th, 2018, 8:14pm, Ric wrote:
the program should crash.

What sort of "crash"? Unfortunately that word is used by different people to mean different things. If it's what I would call a 'true' crash (something like a memory access violation) then you really need to install a Postmortem Debugger - for example Microsoft's WinDbg - so that you can see exactly what is happening, in terms of register values, memory contents (including the stack) etc.

Of course as an assembly language programmer it may well be that you already have such a debugger installed - it is invaluable for analyzing failures in your own code - in which case you might want to list here what it is reporting. If it's crashing inside BBC BASIC I may be better able to interpret the report than you are.

Quote:
What circumstances would cause "!loop = 0" to throw the error "address out of range"

Most likely it would indicate the value of 'loop' being less than &10000. In Windows the bottom 64 Kbytes of memory is reserved and cannot be legitimately accessed. For example try this:

Code:
      loop = &1000
      !loop = 0 

That will throw 'Address out of range' every time.

Richard.
« Last Edit: Jan 26th, 2018, 10:26pm by Richard Russell » User IP Logged

Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx Re: Program Crashes in BASIC routine!
« Reply #2 on: Jan 28th, 2018, 6:15pm »

Thanks Richard,

The address out of range was the result of a school boy error. Ho hum.
I will look into the debugger and let you know.

Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx Re: Program Crashes in BASIC routine!
« Reply #3 on: Jan 28th, 2018, 8:55pm »

Richard,

The error is"Unhandled exception at 0x00403362 in bbcwin6.exe: 0xC0000005: Access violation reading location 0x95099FA3. occurred"

As far as I can see it occurs in a piece of assembly that I have not written. What do you need from me to decipher it?

Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: Program Crashes in BASIC routine!
« Reply #4 on: Jan 28th, 2018, 10:29pm »

on Jan 28th, 2018, 8:55pm, Ric wrote:
Unhandled exception at 0x00403362... Access violation reading location 0x95099FA3

Do you have register values and a disassembly of the instruction that faulted?

I can't be sure without that extra information, but the report would certainly be consistent with heap corruption, which has always been the most likely cause. It's hard to imagine how else your program could provoke such a failure.

Having had a very quick look at your code, there's a huge amount of indirection, which obviously greatly increases the risk of memory corruption (because BBCBASIC provides no checking that the address you're writing to is valid).

Couldn't you have used structures or arrays-of-structures instead for much of it? That would make accidental memory corruption much less likely, e.g. because of automatic array-bounds checking, and would probably run faster!

I fear that you've written a particularly hard-to-debug program, but I expect you know that. Good luck!

Richard.
User IP Logged

Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx Re: Program Crashes in BASIC routine!
« Reply #5 on: Feb 1st, 2018, 3:14pm »

Thanks Richard,

Just the fact you thought it was the heap being corrupted gave me a massive leg up in what to look for.
Simple and easy solution when you find it ( note to self, always DIM enough memory! )

The reason for all the indirection is I personally find it easier to convert the sections of code required to be is ASM much quicker and simpler to implement, once I have the "safe" BASIC routines working.

Regards

Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls