It is currently Wed Apr 14, 2021 12:20 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 1:36 am 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 3585
Location: New Zealand
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


Quote:
g 7
h 10
bug below
g 8873415
h



Code:
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()


Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 10:40 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 761
Location: Germany, Saarbrücken
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 2:19 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1825
Location: Germany
@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.

Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 4:19 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3461
Location: Boston, MA
True Detectives 8)

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 4:59 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 761
Location: Germany, Saarbrücken
Looks like there is one PUSH to much if I am reading that right:
Code:
; 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.


Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 9:40 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 3585
Location: New Zealand
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: x64 call convention parsing bug
PostPosted: Mon Feb 15, 2021 9:44 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 630
Location: Pandora
Good Morning Idle.
Yep, confirmed on MacOS BigSur / PB573

_________________
地球上の平和


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye