Calling exported string functions - PB 4.2 beta 2
Posted: Wed Jan 30, 2008 2:53 pm
Hi,
this quite serious problem is shown in the generated ASM file, but first, if you wish to reproduce this bug, tailbite the following to create a simple userlib (or even create a dll instead) :
Userlib :
Now a client program :
Run the client (after creating the userlib) and select the menu option. CRASH!
The problem is generated by the HeyHo(100) call in the TEST_PROC() procedure and would appear to be one of stack corruption.
The problem is quite easily seen in the ASM corresponding to the TEST_PROC() procedure; see the two instances of
ASM for the TEST_PROC() procedure.
All of this runs fine with PB 4.1 and indeed the generated ASM file only has one instance of the PUSH dword [_PB_StringBasePosition] instruction in this case!
this quite serious problem is shown in the generated ASM file, but first, if you wish to reproduce this bug, tailbite the following to create a simple userlib (or even create a dll instead) :
Userlib :
Code: Select all
ProcedureDLL.s HeyHo(a)
Protected a$
a$=Str(a)
ProcedureReturn a$
EndProcedure
Code: Select all
Procedure TEST_PROC()
tarea.s = HeyHo(100)
MessageRequester("Bloody hell's bells!", tarea)
EndProcedure
If OpenWindow(0,0,0,640,300,"Tally bally ho!",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
CreateMenu(0,WindowID(0))
MenuTitle("test")
MenuItem(1, "testing")
Repeat
EventID = WaitWindowEvent()
If EventID=#PB_Event_Menu And EventMenu()=1
TEST_PROC()
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf
The problem is generated by the HeyHo(100) call in the TEST_PROC() procedure and would appear to be one of stack corruption.
The problem is quite easily seen in the ASM corresponding to the TEST_PROC() procedure; see the two instances of
Code: Select all
PUSH dword [_PB_StringBasePosition]
Code: Select all
; :
; Procedure TEST_PROC()
macro MP0{
_Procedure0:
PS0=8
XOR eax,eax
PUSH eax
; tarea.s = HeyHo(100)
PUSH dword [_PB_StringBasePosition]
PUSH dword [_PB_StringBasePosition]
PUSH dword 100
CALL PB_HeyHo
LEA ecx,[esp+4]
POP edx
CALL SYS_AllocateString
; MessageRequester("Bloody hell's bells!", tarea)
PUSH dword [esp]
PUSH dword _S1
CALL _PB_MessageRequester@8
; EndProcedure
XOR eax,eax
_EndProcedure1:
PUSH dword [esp]
CALL _SYS_FreeString@4
ADD esp,4
RET
}
;