x64 call convention parsing bug

Post bugreports for the Linux version here
User avatar
idle
Addict
Addict
Posts: 3601
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

x64 call convention parsing bug

Post by idle »

bug is in x64 call parsing, it is set off by a float or double parameter, if the last parameter is changed to an integer the code works
result on linux x64 PB 5.72

bug reported from saki
viewtopic.php?f=7&t=76745

g 7
h 10
bug below
g 8873415
h

Code: Select all

Procedure bar(a,b,c,d,e,f,g,h.s=" ",i=9,j.d=10.0)
 
  Debug g
  Debug h
   
EndProcedure   

Procedure foo()
  Protected a,text.s   
 
  For a = 1 To 10
    text=Str(a)
    bar(1,2,3,4,5,6,7,text,9,#PI)
  Next
 
  Debug " bug below "
 
  For a = 1 To 10
     bar(1,2,3,4,5,6,7,Str(a),9,#PI)
  Next
   
EndProcedure

foo()
User avatar
NicTheQuick
Enthusiast
Enthusiast
Posts: 776
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: x64 call convention parsing bug

Post by NicTheQuick »

Confirmed on Ubuntu 20.10 x64 with Purebasic 5.73.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Shardik
Addict
Addict
Posts: 1831
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: x64 call convention parsing bug

Post by Shardik »

@idle,

good catch! Congratulations!

I can confirm your described bug in x64 call parsing (and the disappearance of the bug when changing j.d=10.0 or j.f=10.0 to j.i=10) in PB 5.73 x64 for these two operating systems:
  • Linux Mint 19.3 'Tricia' x64 with Cinnamon and GTK3
  • MacOS 11.2.1 'Big Sur'
On MacOS 10.9.5 'Mavericks' with PB 5.73 x86 idle's example code runs like a charm, so the x86 call parsing is working correctly and the call parsing bug is limited to the Linux and MacOS x64 versions.
Last edited by Shardik on Mon Feb 15, 2021 7:57 pm, edited 1 time in total.
User avatar
skywalk
Addict
Addict
Posts: 3488
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: x64 call convention parsing bug

Post by skywalk »

True Detectives 8)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
NicTheQuick
Enthusiast
Enthusiast
Posts: 776
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: x64 call convention parsing bug

Post by NicTheQuick »

Looks like there is one PUSH to much if I am reading that right:

Code: Select all

; bar(1,2,3,4,5,6,7,text,9,#PI)         | ; bar(1,2,3,4,5,6,7,Str(a),9,#PI)
  SUB    rsp,8                          |   PUSH   qword [PB_StringBasePosition]
  PUSH   qword 9                        |   PUSH   qword 9
                                        |   PUSH   qword [PB_StringBasePosition]
                                        |   SUB    rsp,8
                                        |   PUSH   qword [PB_StringBasePosition]
                                        |   PUSH   qword [v_a]
                                        |   POP    rdi
                                        |   POP    rsi
                                        |   CALL   PB_Str
                                        |   ADD    rsp,8
  PUSH   qword [v_text]                 |   ADD    qword [PB_StringBasePosition],2
  PUSH   qword 7                        |   PUSH   qword 7
  FLD    qword [D1]                     |   FLD    qword [D1]
  SUB    rsp,8                          |   SUB    rsp,8
  FSTP   qword [rsp]                    |   FSTP   qword [rsp]
  PUSH   qword 6                        |   PUSH   qword 6
  PUSH   qword 5                        |   PUSH   qword 5
  PUSH   qword 4                        |   PUSH   qword 4
  PUSH   qword 3                        |   PUSH   qword 3
  PUSH   qword 2                        |   PUSH   qword 2
  PUSH   qword 1                        |   PUSH   qword 1
                                        |   MOV    rsi,[PB_StringBase]
                                        |   ADD    [rsp+56],rsi
  POP    rdi                            |   POP    rdi
  POP    rsi                            |   POP    rsi
  POP    rdx                            |   POP    rdx
  POP    rcx                            |   POP    rcx
  POP    r8                             |   POP    r8
  POP    r9                             |   POP    r9
  MOVSD  xmm0,qword [rsp]               |   MOVSD  xmm0,qword [rsp]
  ADD    rsp,8                          |   ADD    rsp,8
  CALL  _Procedure0                     |   CALL  _Procedure0
  ADD    rsp,32                         |   ADD    rsp,24
                                        |   SUB    rsp,8
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
idle
Addict
Addict
Posts: 3601
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: x64 call convention parsing bug

Post by idle »

Shardik wrote:@idle,

good catch! Congratulations!

I can confirm your described bug in x64 call parsing (and the disappearance of the bug when changing j.d=10.0 or j.f=10.0 to j.i=10) in PB 5.73 x64 for these two operating systems:
  • Linux Mint 19.3 'Tricia' x64 with Cinnamon and GTK3
  • MacOS 11.2.1 'Big Sur'
On MacOS 10.9.5 'Mavericks' with PB 5.73 x86 idle's example code runs like a charm, so the x86 call parsing is working correctly and the call parsing bug is limited to the Linux and MacOS x64 versions.
Thanks for confirming the bug on MacOS, hopefully this will get treated with urgency.
User avatar
Saki
Enthusiast
Enthusiast
Posts: 673
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: x64 call convention parsing bug

Post by Saki »

Good Morning Idle.
Yep, confirmed on MacOS BigSur / PB573
地球上の平和
Post Reply