Welcome, Guest.
Please login or register.
INC bug ?
Forum Login
Login Name: Create a new account
Password:     Forgot password

XBLite Forum    General Boards    XBLite Compiler  ›  INC bug ?
Users Browsing Forum
No Members and 1 Guests

INC bug ?  This thread currently has 3,639 views. Print Print Thread
1 Pages 1 Recommend Thread
26
September 21, 2008, 10:02am Report to Moderator Report to Moderator
Guest User
I had an exception raised when excuting this code

Quoted Text
INC mControl.nMenus


and none when using this one :

Quoted Text
mControl.nMenus = mControl.nMenus + 1


That was very weird so it took a look to the assembly code :

Quoted Text
; [3449] INC mControl.nMenus
     mov     eax,d[%mControl.sab_edit]               ;;; i663a
     mov     esi,d[eax+4]               ;;; i73
     inc     d[eax+4]               ;;; i78
     jnc     > A.372               ;;; i79
     int     3               ;;; i80
A.372:


So this is the problem, the code executes INT3 if carry is set but INC does not modify carry flag so you can have unexpected exceptions when using INC (totaly randomly so it is difficult to find why).
Logged
E-mail E-mail
XBLiteAdmin
September 26, 2008, 11:26am Report to Moderator Report to Moderator
Administrator Group
Posts: 44
Hi,

I'm unable to explain this situation without more code to look at.

Could you post your struct for mControl.

thanks,
D.
Logged Offline
Site Site Private Message Private message Reply: 1 - 3
26
September 26, 2008, 3:35pm Report to Moderator Report to Moderator
Guest User
composites are defined as :
Code
PACKED RGBA_F
	SINGLE		.r
	SINGLE		.g
	SINGLE		.b
	SINGLE		.a
END TYPE

TYPE MENU_COLOR_SET
RGBA_F		.text
RGBA_F		.base
END TYPE

TYPE MENU_CONTROLER
ULONG						.font
ULONG						.nMenus
ULONG						.focused
MENU_COLOR_SET	.focus
MENU_COLOR_SET	.active
MENU_COLOR_SET	.inactive
END TYPE


and the function is :
Code
FUNCTION MENU_Create (pX,pY,width,title$)
SHARED MENU_CONTROLER mControl
SHARED MENU_HANDLER menu[]

cMenu=mControl.nMenus
IF cMenu>$$MAX_MENUS THEN RETURN -1

'mControl.nMenus = mControl.nMenus + 1
INC mControl.nMenus

menu[cMenu].flags=0
menu[cMenu].nItems=0
menu[cMenu].pos.x=pX
menu[cMenu].pos.y=pY
menu[cMenu].width=width
menu[cMenu].name =title$

RETURN cMenu

END FUNCTION


Alone this code causes exception.If i clear carry flag before using INC/DEC (composite.member), the exception does not occur.If the carry flag is set before any INC/DEC (composite.member), exception raises each time.

Code
ASM clc
INC mControl.nMenus

will not cause exception

Code
ASM stc
INC mControl.nMenus

will cause exception each time

Code
PRINT "someting"
INC mControl.nMenus

will avoid exception (i suppose PRINT clears carry flag)

This problems seems to occur only with composites ULONG members.
I attached a bit of code that reproduces problem.In this program, i suppose the 'IF THEN' code set the carry flag so the problem occurs.This is dependency walker output :
Quoted Text
00:00:00.203: First chance exception 0x80000003 (Breakpoint) occurred in "TESTINC.EXE" at address 0x0040105A by thread 1.





This post contains attachments; to download them you must login.

Logged
E-mail E-mail Reply: 2 - 3
eto.ethome.sk
November 26, 2008, 11:43pm Report to Moderator Report to Moderator
Baby Member
Posts: 5
I have experienced exactly the same situation today. Invoking INC caused second chance exception, which took down whole program. I was using PACKED type with ULONG memebers, are you interested in my source code for further anlysis?
Logged Offline
Site Site Private Message Private message ICQ ICQ AIM AIM YIM YIM Windows Live Messenger WLM Reply: 3 - 3
1 Pages 1 Recommend Thread
Print Print Thread

XBLite Forum    General Boards    XBLite Compiler  ›  INC bug ?

Thread Rating
There is currently no rating for this thread