Crash in pretty simple program involving GOSUB and RETURN

Post Reply

Topic author
soutbarr
Active Contributor
Posts: 40
Joined: Wed Mar 13, 2024 4:45 pm
Reputation: 1
Status: Offline

Crash in pretty simple program involving GOSUB and RETURN

Post by soutbarr » Sat May 25, 2024 5:18 pm

This is for the current Basic compiler (I was a part of the community program before it went vmdk), also this is on x86.
Adding version info
VSI BASIC x86-64 X1.8-005 (GEM 50Y3Q) on OpenVMS x86_64 V9.2-2


Alright, when the a program has a single subroutine it works perfectly fine. The moment it has more than one subroutine it breaks and crashes when it encounters it's first return call.

Code: Select all

OPTION TYPE = EXPLICIT
  GOSUB PRINT_HIYA
  PRINT "2nd GOSUB Upnext"
  GOSUB PRINT_HI
EXIT PROGRAM

PRINT_HIYA:
  PRINT "Hiya"
RETURN

PRINT_HI:
  PRINT "Hi"
RETURN

END
That is the Basic program, it compiles and links just fine on execution

Code: Select all

$ r testreturn
Hiya
%SYSTEM-F-ACCVIO, access violation, reason mask=15, virtual address=FFFFFFFF800000B0, PC=00002098010E0004, PS=0000001B

  Improperly handled condition, image exit forced by last chance handler.
    Signal arguments:   Number = 0000000000000005
                        Name   = 000000000000000C
                                 0000000000000015
                                 FFFFFFFF800000B0
                                 00002098010E0004
                                 000000000000001B
    Register dump:
    RAX = FFFFFFFF800000B0  RDI = 000000007ACB38D8  RSI = 0000000000000000
    RDX = 000000007ACB38A8  RCX = 0000000000000000  R8  = 000000007C05D790
    R9  = 0000000000000000  RBX = 000000007ACB3890  RBP = 000000007ACB3950
    R10 = FFFFFFFFFFFFFFFE  R11 = 0000000000000001  R12 = 000000007ACB39A8
    R13 = 0000000000000000  R14 = 000000007ACB3890  R15 = 0000000030F84606
    RIP = 00002098010E0004  RSP = 000000007ACB3880  SS  = 000000000000001B
Last edited by soutbarr on Sat May 25, 2024 5:20 pm, edited 1 time in total.


hb
Master
Posts: 136
Joined: Mon May 01, 2023 12:11 pm
Reputation: 0
Status: Offline

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by hb » Sat May 25, 2024 6:55 pm

Tell the linker to put the code into P0. The FFFFFFFF800000B0 indicates a sign extension problem. To me 800000B0 looks like a P2 jump target. If you have the code in P0 this target is at 000020B0 and then the program works - for me.

I am inclined to suggest that for the time being all basic programs should be linked with code in P0.

Code: Select all

$ bas testreturn
$ link testreturn
$ r testreturn
Hiya
%SYSTEM-F-ACCVIO, access violation, reason mask=15, virtual address=FFFFFFFF800000B0, PC=00002098010E0004, PS=0000001B

  Improperly handled condition, image exit forced by last chance handler.
    Signal arguments:   Number = 0000000000000005
                        Name   = 000000000000000C
                                 0000000000000015
                                 FFFFFFFF800000B0
                                 00002098010E0004
                                 000000000000001B
    Register dump:
    RAX = FFFFFFFF800000B0  RDI = 000000007AC718D8  RSI = 0000000000000000
    RDX = 000000007AC718A8  RCX = 0000000000000000  R8  = 000000007C03D790
    R9  = 0000000000000000  RBX = 000000007AC71890  RBP = 000000007AC71950
    R10 = FFFFFFFFFFFFFFFE  R11 = 0000000000000001  R12 = 000000007AC719A8
    R13 = 0000000000000000  R14 = 000000007AC71890  R15 = 000000001F104606
    RIP = 00002098010E0004  RSP = 000000007AC71880  SS  = 0002868800000004
$ link testreturn/segment=code=p0
$ r testreturn
Hiya
2nd GOSUB Upnext
Hi
$ 

User avatar

cct
Master
Posts: 216
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by cct » Sat May 25, 2024 7:09 pm

Not even sure that is enough . I have given up testing my old suite. It all compiles, linked on P0 but there are so many run time failures - especially any error handling, unless trivial.
Also the debugger is currently toast.

Hoping my ambassador membership comes through soon - I quickly got an email saying I was accepted, but without the OS update, new version of Basic, and the the promised follow up, I cannot do any more
Chris Townley
VMS Ambassador

User avatar

neilrieck
Active Contributor
Posts: 41
Joined: Tue Jan 10, 2023 10:41 am
Reputation: 0
Location: Waterloo, Ontario, Canada
Status: Offline
Contact:

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by neilrieck » Sun May 26, 2024 7:53 am

soutbarr wrote:
Sat May 25, 2024 5:18 pm

As HB already pointed out, you need to link differently (for now)

Code: Select all

kawc77:neil> type crash.bas
OPTION TYPE = EXPLICIT
  GOSUB PRINT_HIYA
  PRINT "2nd GOSUB Upnext"
  GOSUB PRINT_HI
EXIT PROGRAM

PRINT_HIYA:
  PRINT "Hiya"
RETURN

PRINT_HI:
  PRINT "Hi"
RETURN

END
kawc77:neil> bas crash    
kawc77:neil> link/segment=code=p0 crash
kawc77:neil> run crash
Hiya
2nd GOSUB Upnext
Hi
kawc77:neil> 
Remember that this is a limited field trial. That said, I have sent them approx a half dozen problems (one crash; some where output on x86 doesn't exactly match Itanium) and they have been very prompt at fixing them. IMHO, they ported BASIC last because they knew it would be messy.


Topic author
soutbarr
Active Contributor
Posts: 40
Joined: Wed Mar 13, 2024 4:45 pm
Reputation: 1
Status: Offline

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by soutbarr » Sun May 26, 2024 10:45 pm

Oh I know, I just don't know where to submit those bug reports.


snadow
Active Contributor
Posts: 27
Joined: Fri Feb 14, 2020 11:10 am
Reputation: 0
Status: Offline

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by snadow » Mon May 27, 2024 1:36 pm

soutbarr wrote:
Sun May 26, 2024 10:45 pm
Oh I know, I just don't know where to submit those bug reports.
As a "community" user (vs. a person holding a paid-for license with a paid-for support contract), you're in the right place already - here in the forum. VSI will open a case on your behalf if they view your bug as valid and not already submitted by someone else.


jreagan
VSI Expert
Master
Posts: 215
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Crash in pretty simple program involving GOSUB and RETURN

Post by jreagan » Wed Jun 05, 2024 12:15 pm

We haven't updated the BASIC FT compiler yet. I think that linking with /SEG=CODE=P0 should be sufficient.

We are working on the compiler & RTL (they both share knowledge of run-time data structures) fix for this.

Post Reply