If you have been folllowing the thread posted by Tim Wisseman, he reported a problem with the compiler producing erroneous addresses for Global variables which would GPF (or lock up) his program.
I have come accross the exact same problem I believe. It is hard to make a sample test program since I have over 5000 lines of code and to reproduce the error is very difficult.
I think this is a very serious error in the compiler and deserves PBs "full attention" to solve it. Here is what I have experienced so far and I'll try to document it as best as possible:
My program works fine. I add a few lines of code and then all of a sudden the program is locking up at a section of code that was written a long time ago and works perfectly. In doing some testing here is what I noticed:
Here is a major procedure in my program which process a bunch of messages sent to this routine:
The problem is this:
My Procedure has a very complex Select Case structure (and lots of If Blocks). Near the end of the Select case structure (noted in code) if I add another sub call (even if it is a dummy with no code in it), I then have problems with a sub call near the top quarter of the Select case structure.
The NewForm sub call does get executed but when some code in it accesses a:
Global Array
The program now locks up. I used the msgbox command in different places until I found where the program locked up. I was able to even have the program lick up when I used the varptr command with that global array.
Here is what I think is happening.
In certain circumstances when there are many procedure calls and the Select case/If Then blocks get nested a bit deep, the compiler somehow "loses" some tracking information about some Global variables, so when some code later in the program uses those variables, the compiler puts erronneous addresses for the variables and memory is probably overwritten.
I know "absolutely" this is a BUG in the Compiler, since if I simply add a single line of code (which is a call to a dummy procedure that does nothing), then the program locks up at a previously written section that has worked flawlessly. When I remove the single line of code, then everything works just fine.
There is absolutely NO way that adding a single line of code that is a sub call to a dummy procedure (no code in the sub), can cause a bug in my software. This is impossible !
I am still not sure "exactly" the mechanism of the problem yet, since it will not likely show up on a small sized program that has less structure in it. This makes it hard to document expect in a very large program (which some programmers cannot give out the code).
I have come accross the exact same problem I believe. It is hard to make a sample test program since I have over 5000 lines of code and to reproduce the error is very difficult.
I think this is a very serious error in the compiler and deserves PBs "full attention" to solve it. Here is what I have experienced so far and I'll try to document it as best as possible:
My program works fine. I add a few lines of code and then all of a sudden the program is locking up at a section of code that was written a long time ago and works perfectly. In doing some testing here is what I noticed:
Here is a major procedure in my program which process a bunch of messages sent to this routine:
Code:
' -------------------------------------------------------------------------------- Sub EZ_Events(FormName$, CID&, CMsg&, CVal&, Cancel&) EXPORT Local TMP$, I&, hCtrl&, WS&, EX&, MyColor& Local D$, X&, N&, P1&, P2& Select case FormName$ case "PARENT" ' or any Form Name you choose Select case CID& case %EZ_Window ' This is a Window message if CMsg&=%EZ_Close then CheckSave EZ_UnloadForm "TopTool" end if if CMsg&=%EZ_FreeNow then EZ_RedrawForm "" ' redraws desktop end if case 230 if CMsg&=%EZ_Change then BringForward end if case 901,101 ' New Form if CMsg&=%EZ_ToolTip then EZ_SetToolTip "New Form" else ' ------------------------------------------------ ' The lock up occurs during the following sub call NewForm ' ------------------------------------------------- end if case 902,102 ' Open Form if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Open Form" else OpenForm end if case 903,103 ' Save Form if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Save Form" else if MainFlag& then SaveForm 0 end if case 904,104 ' Save Form As if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Save Form As" else if MainFlag& then SaveForm 1 end if case 905,105 ' close form if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Close Form" else if MainFlag& then X&=CloseMainForm() end if end if case 906 ' exit program EZ_UnloadForm "Parent" case 911, 106 ' Edit Form if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Edit Form" else DisplayFormProps end if case 107 ' Edit Menu if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Drag Form from Inside" else if App_CanDrag& then App_CanDrag&=0 else App_CanDrag&=1 end if end if case 941, 110 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Edit Mode" else SetEditMode 1 end if case 942,111 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Test Mode" else SetEditMode 0 end if case 943,112 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Reset Tab Order" else SetZorder 0 end if case 931, 108 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Add Toolbar" else if App_EditMode& then MakeControl 50 end if case 932,109 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Edit Toolbar" else if App_EditMode& then DisplayToolbarProps end if case 961,113 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Generate Form Code" else DisplayGenProps end if case 962,114 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Generate Project Code" else end if case 115 if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Move the Next Control you Select to 0,0" else if App_CenterFlag&=0 then App_CenterFlag&=-1 else App_CenterFlag&=0 end if end if case 913 to 918 X&=CID&-913 N&=X& if X&=3 then N&=4 if X&=4 then N&=8 if X&=5 then N&=16 EZ_SetFGrid N& D$="Character Size" for I&=0 to 5 if I&=X& then TMP$="X" else TMP$="" if I&=1 then D$="1 X 1" if I&=2 then D$="2 X 2" if I&=3 then D$="4 X 4" if I&=4 then D$="8 X 8" if I&=5 then D$="16 X 16" EZ_SetMenuItem SMenu1B&, 913+I&, D$ , TMP$ next I& case 951 to 956 X&=CID&-950 if X&>2 then N&=(X&-2)*4 else N&=X& end if EZ_SetGrid N&, N& for I&=1 to 6 if I&>2 then N&=(I&-2)*4 else N&=I& end if if I&=X& then TMP$="X" else TMP$="" D$=ltrim$(str$(N&)) EZ_SetMenuItem SMenu5&, 950+I&,D$+" X "+D$ , TMP$ next I& case 971 to 973 SetDFont CID&-971 case 981 to 997 if App_EditMode& then MakeControl CID&-980 end if case else end select case "MAIN" Select case CID& case %EZ_Window if CMsg&=%EZ_Close then if App_CheckSave& then CheckSave EZ_UnloadForm "FLOAT1" end if if CMsg&=%EZ_FreeNow then for X&=0 to ubound(App_Menus) if App_Menus(X&)<>0 then EZ_DelMenu App_Menus(X&) end if next X& end if if CMsg&=%EZ_Focus then EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_Focus" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if if CMsg&=%EZ_NoFocus then EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_NoFocus" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if if CMsg&=%EZ_Change then EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_Change" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if if CMsg&=%EZ_LButtonDown then EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_LButtonDown" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) if App_CanDrag&<>0 then EZ_DragForm "Main" end if end if if CMsg&=%EZ_LButtonDC then if App_EditMode&=1 then DisplayFormProps else EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_LButtonDC" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if end if if CMsg&=%EZ_RButtonUp then EZ_SetText "Parent", 200, "%EZ_Window" EZ_SetText "Parent", 201, "%EZ_RButtonUp" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if case 50 to 99 ' toolbar messages Select case CMsg& case %EZ_Click D$="%EZ_Click" EZ_SetText "Parent", 200, "Toolbar Button"+str$(CID&-50) EZ_SetText "Parent", 201, D$ EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) case %EZ_ToolTip D$="%EZ_ToolTip" EZ_SetToolTip "Button"+str$(CID&-50) case else D$="" End Select case 100 to 400 if CMsg&=%EZ_LButtonDC then DisplayProps CID& elseif CMsg&=%EZ_RButtonUp then AlignDialog CID& else Select case CMsg& case %EZ_Click D$="%EZ_Click" case %EZ_DClick D$="%EZ_DClick" case %EZ_Focus D$="%EZ_Focus" case %EZ_NoFocus D$="%EZ_NoFocus" case %EZ_Disable D$="%EZ_Disable" case %EZ_Change D$="%EZ_Change" case %EZ_Timer D$="%EZ_Timer" case %EZ_ToolTip D$="%EZ_ToolTip" case %EZ_LButtonDown D$="%EZ_LButtonDown" case %EZ_FreeNow D$="%EZ_FreeNow" case %EZ_SubClass D$="" ' this message will be continuous case else D$="" End Select if D$<>"" then EZ_SetText "Parent", 200, App_CName$(CID&-99) EZ_SetText "Parent", 201, D$ EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if end if if CMsg&=%EZ_Drag then end if if CMsg&=%EZ_Drop then end if case >=500 ' menus N&=(CID&-495)/5 if N&<=%App_Max_Menu then D$=ltrim$(rtrim$(App_F.FMenuItems(N&))) if left$(D$,3)="..." then D$=mid$(D$,4) D$=remove$(D$,"&") EZ_SetText "Parent", 200, "M: "+D$ EZ_SetText "Parent", 201, "N/A" EZ_SetText "Parent", 202, ltrim$(str$(CVal&)) end if case else end select case "FLOAT1" Select case CID& case 101 to 117 if CMsg&=%EZ_Click then MakeControl CID&-100 if CMsg&=%EZ_ToolTip then MakeToolTips CID&-100 case 118 if CMsg&=%EZ_Click then MakeControl 49 if CMsg&=%EZ_ToolTip then MakeToolTips 49 case 200 if CMsg&=%EZ_Change then App_ActiveLayer&=val(mid$(EZ_GetText("FLOAT1", 200), 7)) EZ_DisplayLayer "Main", App_ActiveLayer&, 0 end if case 300 if CMsg&=%EZ_Click then DoToolBar end if if CMsg&=%EZ_ToolTip then EZ_SetToolTip "Hide Visual Designer" end if case else end select case "PROPS" Select case CID& case %EZ_Window if CMsg&=%EZ_Close then EZ_ShowForm "Float1" EZ_Enable "Main" end if case 103 if CMsg&=%EZ_Click then BrowseBitmaps case 104 if CMsg&=%EZ_Click then BrowseIcons case 108 if CMsg&=%EZ_Change then Select Case rtrim$(EZ_GetText("Props", 108)) case "Custom Bitmap" BrowseBitmaps EZ_SelectItem "Props", 107,1 case else D$=ltrim$(rtrim$(EZ_GetText("Props", 108))) EZ_SetText "Props", 102, D$ if left$(D$,6)="%Large" then EZ_SelectItem "Props", 107,1 else EZ_SelectItem "Props", 107,0 end if End Select end if case 109 if CMsg&=%EZ_Change then Select Case rtrim$(EZ_GetText("Props", 109)) case "Custom Icon" BrowseIcons case else D$=ltrim$(rtrim$(EZ_GetText("Props", 109))) EZ_SetText "Props", 102, D$ End Select end if case 120, 121 if CMsg&=%EZ_Click then if CID&=120 then TMP$="Foreground" ColorPickVal&=App_C(0).CFGColor ColorType&=1 else TMP$="Background" ColorPickVal&=App_C(0).CBGColor ColorType&=2 end if TMP$="Select "+TMP$+" Color" EZ_Form "ColorPick", "Props", TMP$,0,0, 24,24, "CRMN" if CID&=120 then ' App_C(0).CFGColor=ColorPickVal& else ' App_C(0).CBGColor=ColorPickVal& end if end if case 122 if CMsg&=%EZ_Click then if rtrim$(App_C(0).CFontName)<>"" then EZ_DefFont -1, rtrim$(App_C(0).CFontName), App_C(0).CFontPitch, rtrim$(App_C(0).CFontProp) else if App_DefaultFName$<>"" then EZ_DefFont -1, App_DefaultFName$, App_DefaultFSize&, App_DefaultFProp$ else EZ_DefFont -1, "System", 10, "BV" end if end if if EZ_ChooseFont( "Props", MyColor&, "") then SetCFont 1 else SetCFont 0 end if end if case 199 ' Delete if EZ_MsgBox("Props", "{S}Are you sure you want to delete this Control ?", "Delete Control", "YN") then EZ_UnloadForm "Props" DeleteControl App_PNum& App_PNum&=0 UpdateCombo end if case 200 ' cancel EZ_UnloadForm "Props" App_PNum&=0 case 201 ' Apply SetData App_PNum& EZ_UnloadForm "Props" RedoControl App_PNum& App_PNum&=0 SetZorder 0 UpdateCombo EZ_DisplayLayer "Main", App_ActiveLayer&, 0 case else End Select case "FORMPROPS" Select case CID& case %EZ_Window if CMsg&=%EZ_Close then EZ_ShowForm "Float1" EZ_Enable "Main" end if case 121 if CMsg&=%EZ_Click then TMP$="Background" ColorType&=2 TMP$="Select "+TMP$+" Color" EZ_Form "ColorPick2", "FormProps", TMP$,0,0, 24,24, "CRMN" end if case 200 ' cancel EZ_UnloadForm "FormProps" case 201 ' Apply UpdateControls TMP$=rtrim$(EZ_GetText("FormProps", 100)) TMP$=remove$(TMP$, ANY " |[email protected]#$%^&*()-+={}[]\:;'<>,.?/") TMP$=remove$(TMP$, chr$(34)) if TMP$="" then TMP$="Form1" end if App_F.FName=TMP$ App_F.FTitle=rtrim$(EZ_GetText("FormProps",101)) App_F.FColor=ColorPickVal& App_F.FProps=GetFormProps() App_F.FMenu&=EZ_GetCheck("FormProps", 120) TMP$=EZ_GetText("FormProps", 130) for N&=1 to %App_Max_Menu App_F.FMenuItems(N&)="" next N& N&=0 do P1&=instr(TMP$, chr$(13)+chr$(10)) if P1&<>0 then D$=left$(TMP$, P1&-1) TMP$=mid$(TMP$, P1&+2) else P2&=instr(TMP$, chr$(13)) if P2&<>0 then D$=left$(TMP$, P1&-1) TMP$=mid$(TMP$, P1&+1) else D$=TMP$ TMP$="" if D$="" then exit do end if end if if D$<>"" then N&=N&+1 if N&>%App_Max_Menu then exit do App_F.FMenuItems(N&)=D$ end if loop EZ_UnloadForm "FormProps" App_CheckSave&=0 EZ_UnloadForm "Main" BuildForm UpdateCombo App_CheckSave&=1 case else End Select case "COLORPICK" Select case CID& case %EZ_Window if CMsg&=%EZ_Close then DisplaySample 1 end if case 100 to 131 ColorPickVal&=CID&-100 ActiveColor 1 EZ_SetFocus "ColorPick", 201 if ColorType&=1 then App_C(0).CFGColor=ColorPickVal& if App_C(0).CBGColor=-1 then App_C(0).CBGColor=15 else App_C(0).CBGColor=ColorPickVal& if App_C(0).CFGColor=-1 then App_C(0).CFGColor=0 end if case 200 App_C(0).CFGColor=-1 App_C(0).CBGColor=-1 EZ_UnloadForm "ColorPick" case 201 EZ_UnloadForm "ColorPick" End Select case "COLORPICK2" Select case CID& case %EZ_Window if CMsg&=%EZ_Close then EZ_UnloadControl "FormProps", 150 EZ_SetForm "FormProps", 0 if ColorPickVal&>=0 then EZ_Color 0, ColorPickVal& else EZ_Color -1,-1 end if EZ_Label 150, 1,16.5,16,5, "", "F" EZ_Color -1,-1 end if case 100 to 131 ColorPickVal&=CID&-100 ColorType&=3 ActiveColor 1 EZ_SetFocus "ColorPick2", 201 case 200 ColorPickVal&=-1 EZ_UnloadForm "ColorPick2" case 201 EZ_UnloadForm "ColorPick2" End Select case "TOPTOOL" Select Case CID& case %EZ_Window case 101 to 107 if CMsg&=%EZ_Click then X&=CID&-100 Select case X& case 1 D$=App_CodeDeclare$(1) TMP$="Constants in Clipboard !" case 2 D$=App_CodeGlobal$(1) TMP$="Globals in Clipboard !" case 3 D$=App_CodeMain$(1) TMP$="EZ_Form in Clipboard !" case 4 D$=App_CodeDesign$(1) TMP$="Controls in Clipboard !" case 5 D$=App_CodeEvent$(1) TMP$="Events in Clipboard !" case 6 D$=App_CodeSubs$(1) TMP$="Subs in Clipboard !" case 7 D$=App_CodeSkeleton$(1) TMP$="Skeleton in Clipboard !" case else D$="" End Select if D$<>"" then EZ_SetClipboard D$ EZ_SetText "TopTool", 200, TMP$ else EZ_SetClipboard "" EZ_SetText "TopTool", 200, "NO Code Generated !" end if elseif CMsg&=%EZ_ToolTip then X&=CID&-100 Select case X& case 1 D$="Constants" case 2 D$="Globals" case 3 D$="Form" case 4 D$="Controls" case 5 D$="Events" case 6 D$="Subroutines" case 7 D$="Skeleton" case else D$="" End Select EZ_SetToolTip D$ end if case 108 if CMsg&=%EZ_Click then EZ_HideForm "TopTool" EZ_ShowForm "Parent" EZ_ShowPopUps "Parent" elseif CMsg&=%EZ_ToolTip then EZ_SetToolTip "Return to Visual Designer" end if case 109 if CMsg&=%EZ_Click then EZ_MinimizeForm "TopTool" elseif CMsg&=%EZ_ToolTip then EZ_SetToolTip "Minimize Toolbar" end if case else End Select case "GENPROPS" Select Case CID& case %EZ_Window if CMsg&=%EZ_Close then EZ_ShowForm "Float1" EZ_Enable "Main" end if case 200 if CMsg&=%EZ_Click then EZ_SetSelect "GenProps", 100, -1, 1 case 210 if CMsg&=%EZ_Click then EZ_SetSelect "GenProps", 100, -1, 0 case 400 ' Generate if CMsg&=%EZ_Click then FlagControls 0 GenCode 1, 1 EZ_UnloadForm "GenProps" DoToolBar end if case 410 ' Cancel if CMsg&=%EZ_Click then EZ_UnloadForm "GenProps" end if case else End Select case "ALIGNDLG" Select Case CID& case %EZ_Window if CMsg&=%EZ_Close then EZ_ShowForm "Float1" EZ_Enable "Main" end if case 1 if CMsg&=%EZ_Click then ' ------------------------------------------------ ' If I add the following sub call it causes the above ' sub call (NewForm) to lock up: ' DoDummyProc ' but if I don't use the call everything is OK EZ_UnloadForm "AlignDlg" ' ------------------------------------------------ end if case 2 if CMsg&=%EZ_Click then EZ_UnloadForm "AlignDlg" end if case 200 if CMsg&=%EZ_Click then EZ_SetSelect "AlignDlg", 100, -1, 1 case 210 if CMsg&=%EZ_Click then EZ_SetSelect "AlignDlg", 100, -1, 0 case else End Select case else End Select End Sub
My Procedure has a very complex Select Case structure (and lots of If Blocks). Near the end of the Select case structure (noted in code) if I add another sub call (even if it is a dummy with no code in it), I then have problems with a sub call near the top quarter of the Select case structure.
The NewForm sub call does get executed but when some code in it accesses a:
Global Array
The program now locks up. I used the msgbox command in different places until I found where the program locked up. I was able to even have the program lick up when I used the varptr command with that global array.
Here is what I think is happening.
In certain circumstances when there are many procedure calls and the Select case/If Then blocks get nested a bit deep, the compiler somehow "loses" some tracking information about some Global variables, so when some code later in the program uses those variables, the compiler puts erronneous addresses for the variables and memory is probably overwritten.
I know "absolutely" this is a BUG in the Compiler, since if I simply add a single line of code (which is a call to a dummy procedure that does nothing), then the program locks up at a previously written section that has worked flawlessly. When I remove the single line of code, then everything works just fine.
There is absolutely NO way that adding a single line of code that is a sub call to a dummy procedure (no code in the sub), can cause a bug in my software. This is impossible !
I am still not sure "exactly" the mechanism of the problem yet, since it will not likely show up on a small sized program that has less structure in it. This makes it hard to document expect in a very large program (which some programmers cannot give out the code).
Comment