Announcement

Collapse
No announcement yet.

Possible bug in PB5 compiler

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible bug in PB5 compiler

    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:

    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
    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).


    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

  • #2
    Chris --

    > 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'm not making any judgements about whether or not there is a bug in the compiler, but your statement simply isn't true. There is a very well documented mechanism throught which a program can corrupt memory, but do it in such a way that Windows does not detect it. Then, when something small and unrelated in the program is changed, the location of the corruption is moved to a place where Windows can detect it, and you get a GPF.

    I have experienced this effect with PB/DOS, PB/CC, and PB/DLL, and the cause was never a compiler bug.

    -- Eric


    -------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    "Not my circus, not my monkeys."

    Comment


    • #3
      Eric;

      Could you explain this more in depth ?

      If I understand you correctly, an error must have already occured which does not seem to cause an obvious problem and then by adding a simple procedure call (even if a dummy), then the error now manifests itself.

      At first glance, my assumption would be very reasonable, but I do see what you mean.

      How in the world would you track down such an error ?

      What kind of things did you do wrong in your programs that caused such an error ?

      While this does NOT convince me that there isn't a bug in the compiler (it is naive to think that the PB compiler is 100% bug free), all in all the PB compiler has shown itself to be very stable and I am willing to give it the benefit of the doubt.

      Do you think the problem is with somehow overwriting memory in the DGroup area and when a new line of code is added, memory locations shift and now the memory overwrite causes a problem ?

      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        Chris,

        I really don't appreciate your telling the world that there is a serious bug in PB/DLL without first contacting us privately to verify if it's true.

        We have received absolutely zero/none/nada messages from you on this topic and no code to prove your claim.

        It is possible that what you claim is true, but it is not your place to scare the living daylights out of everyone based on an assumption and without positive proof.

        Next time, I'll simply delete your message and restrict your access to post messages on the Web BBS. I would appreciate it if you would act more responsibly in the future.

        In the meantime, please email your source code to [email protected] so that we can verify your claim and see if we can help you out with your problem.

        --Dave

        ps. I changed the topic of this message.

        -------------
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Home of the BASIC Gurus
        www.basicguru.com

        Comment


        • #5
          Sorry dave;

          I should have been more careful in the "title" of my thread.

          While it seems "very likely" there is a real problem here and I was following up on a discussion started by Tim Wisseman (while his thread title doesn't sound so bad, the context of his thread is just as "serious" as mine).

          If you prefer please change my thread Title to something more acceptable like "Bug or not a Bug" or something. I have no problem with that.

          Since my problem seems VERY similiar to Tim Wisseman's, I didn't think of emailing support first (probably should have), since Tim already made an effort to get this problem "verified".

          Eric Pearsons comments have some validity (i am examining it now) and I may be wrong.

          I "APOLOGIZE" for any poor judgement !

          Chris Boss
          Computer Workshop
          Developer of "EZGUI"
          http://cwsof.com
          http://twitter.com/EZGUIProGuy

          Comment


          • #6
            Thanks for the apology Chris.

            The thing you have to remember is that only about 10% of the people who read the messages in these forums actually participate. And lots of "potential" customers read the messages.

            When they see something like "Serious bug in PowerBASIC", it scares them away. Many will not even bother to read the message to see precisely what the problem is or if a solution was found. They simply see the subject and go away.

            We certainly want to fix any problems in our product. But we need your help in order to do that. We can't fix anything simply based on a description and a small code snippet.

            You can't expect a mechanic to fix your car over the telephone based on just a description of the problem, can you? Our mechanics need to take your code out for a test drive before we can fix the problem.

            Thanks for any help you can provide.

            --Dave


            -------------
            PowerBASIC Support
            mailto:[email protected][email protected]</A>

            Home of the BASIC Gurus
            www.basicguru.com

            Comment


            • #7
              Now back to my problem.

              First, Dave, you have to realize that sometimes your customers have code they cannot release in complete detail since it is a commercial product. I DID post a HUGE chunk of my code (that I thought pertained to my problem), but obviously it is NOT enough for anyone to recompile an test.

              The problems that both Tim and I have experienced seem difficult to reproduce in a small chucnk of code.

              I posted the above code because I thought "maybe" the problem is associated with the "structure" of my Select case (many layers).

              Erics comments have encouraged me to look at other possibilities.

              Here is what I have found so far:

              The lock up occurs somewhere after the following code in my NewForm procedure:

              ' this code is in the procedure that locks up
              for N&=1 to %App_Max_Menu
              App_F.FMenuItems(N&)=string$(32," ")
              next N&
              ' The UDT is again access after the above code and locks up


              You will notice that it is putting data into a fix string array within a UDT.

              The UDT is below:


              Type FormData
              FVersion as Long
              FName as string*16
              FTitle as string*128
              FColor as long
              FProps as string*16
              FWidth as Single
              FHeight as Single
              FNumCtrls as Long
              FMenu as long
              FMenuItems(1 to 100) as string*32
              End Type


              Global App_F as FormData


              Now if I change the code in the for next loop to either:

              for N&=1 to %App_Max_Menu
              App_F.FMenuItems(N&)=""
              next N&

              or

              for N&=1 to %App_Max_Menu
              App_F.FMenuItems(N&)=string$(32," ")+""
              next N&


              The lockup disappears and the program works fine (even though this does not guarantee it won't come back after I add more code).

              If what Eric says is true, then the slight changes I tried may just be moving the code a few bytes in memory and the problem is still there or it actually fixes the problem.

              I don't do anything out of the ordinary with putting data into the UDT. The above code is the first time the UDT is even acessed in the program, so there isn't some other routine that is trashing the memory.


              Chris Boss
              Computer Workshop
              Developer of "EZGUI"
              http://cwsof.com
              http://twitter.com/EZGUIProGuy

              Comment


              • #8
                Dave --
                PB/CC' files (which I received on diskette in August) are dated June, 1; PB/DLL (downloaded Dec, 3) - July, 2.
                It's real dates ?
                Microsoft makes first patches after three-four monthes.
                Which plans do you have for PB CC 2.0 & DLL 6.0 ?

                Comment


                • #9
                  The same problem as before applies...

                  If I can't take my car to my mechanic because I don't want him to see the modifications I've made, I can't expect him to fix my car.

                  You can describe things and make all the assumptions that you want but until we can run the compiler itself through a debugger while it compiles code that causes the problem, there is nothing we can do about it.

                  Put together a non-disclosure agreement and email it to me. I'll have our lawyers take a look at it and if they have no problems with it, we'll sign it so that you can send us your code.

                  We've done the same thing with many government agencies and Fortune 100 companies in the past.

                  --Dave


                  -------------
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>

                  Home of the BASIC Gurus
                  www.basicguru.com

                  Comment


                  • #10
                    Chris,

                    I think Eric is right. I have experienced that kind of problem very often in PDE. That's what I *wanted* to tell in my last thread (extended debugging...). I actually managed to identify the code lines which "seemed" to cause the bug. They were completely "harmless"! If you want to find the bug, try to deactivate as many modules as possible and check EZGUI extensively if the bug persists. It's hard, but it's possible. I know I'm annoying everyone with it, but MemCheck! is a very good tool and you can download it - especially in cases like yours it's very, very helpful!

                    Regards



                    -------------
                    Daniel
                    [email protected]

                    Comment


                    • #11
                      Thanks for the offer and I'll take it into consideration (I have other parties that would have to give Ok on this, since I licensed to software already to another company).

                      I want to see if I can find the answers myself first and if possible to create a test program for verification. I am also looking into what Eric suggested, to see if it is possible that his comments apply to my problem.

                      I will try to give you as much info as is possible and practical. Hopefully, in what source code I do post and the comments I make, someone may notice something I have overlooked. If all else fails, I may have no choice but to send you my source code.

                      Chris Boss
                      Computer Workshop
                      Developer of "EZGUI"
                      http://cwsof.com
                      http://twitter.com/EZGUIProGuy

                      Comment


                      • #12
                        Daniel;

                        Give me an example of a "harmless" peice of code, that still caused problems in PDE.

                        I need to "define" the problem more accurately at this point.

                        If I understand Eric correctly, the only possible reason a program could lockup by the addition of some "dummy" code, is if the error was alwas there and it was overwriting memory in Dgroup (where variables are stored), but the error did not manifest itself until the code segment somehow gets shifted by the addition of new lines of code.

                        Its time to play "Sherlock Holmes" !

                        Lets assume this is correct.

                        The only two culprits would be either an error was written in the Basic Language which did something with a variables memory location or an API function was given bad data and it caused the problem.

                        My program is an EXE (EZGUI Visual Designer) which makes absolutely NO API calls. The EXE does make dozens of calls into my EZGUI DLL, which does make API calls.

                        I use NO assembler at all in either the EXE or the DLL and only Basic commands. No pointers are used in the DLL except a few needed by the WM_NOTIFY message.

                        I suspect the EXE is the problem since, it has its own data segment which is isolated from the EZGUI DLLs data segment (it has its own).

                        If the EXE is the problem then since I use NO assembler or API calls, it would have to be an error with just Basic statements. The offending Global array is NOT accessed beyond its bounds, so I don't see how its memory gets trashed in anyway. It almost seems as if the array can be accessed in a few lines of code and then a few lines later the same array is accessed and the pointer may be bad to it. There are NO EZGUI calls in the immediate area of the offending code.

                        Chris Boss
                        Computer Workshop
                        Developer of "EZGUI"
                        http://cwsof.com
                        http://twitter.com/EZGUIProGuy

                        Comment


                        • #13
                          Chris --

                          (You made an additional post while I was writing this off line, and it is clear now that you understand what I was saying. But I'll leave this message on the board for the benefit of lurkers.)

                          > Could you explain this more in depth ?

                          Sure. Let's assume that your program uses a certain amount of numeric and string data, and that a corresponding amount of memory has been allocated to it (by Windows) for code and data storage. If your program accesses that memory in any way -- on purpose or accidentally -- Windows will not complain. It has no way of knowing whether or not the technique you are using to modify the memory is intentional or not. But if your program accesses memory that has not been allocated to it, you'll see a GPF error message. (Microsoft uses the term "Application Error" now, but the old term "General Protection Fault" is more descriptive of the error so many programmers still use it. It means that a program violated the Windows memory protection scheme that keeps apps from interfering with each other.)

                          Let's say that somewhere in your program you are saving a value in a numeric array, and that you are using a subscript that is too large. If you are using $DEBUG ERROR OFF, then PowerBASIC will not check your subscript, it will simply calculate the memory location that would be used if that array element really did exist, and store a value there. If that location corresponded to a block of memory that was legal for your program to use, nothing would happen (except that the value that your program intended to store in that location would be corrupted). No GPF would be tripped.

                          If your program was changed in a very subtle way -- maybe it got 16 bytes larger when you added some code -- then the location of the corruption might be moved. And if it got moved to a memory location that was not allocated to your program, an Application Error would be generated at runtime.

                          Here's how you can be fooled into thinking that one part of a program is failing when the problem is really elsewhere...

                          Imagine that the memory location that is being corrupted is not really "data", but a pointer to data, like a string pointer. (A string pointer tells PowerBASIC where a particular string is located.) Windows would not complain at all when your program corrupted the value, because your program can legally change that block of memory. But much later on, when your program went to use that string, it might generate a GPF because the pointer pointed to a memory location that was not legal for your program to access. Or it might point to a location that was legal, and you might get garbage data. Or it might point to a midpoint of the string, or... or... or...

                          Those are just a few generic and probably over-simplified examples. Many different things can cause memory to be corrupted, and many different things can be corrupted.

                          Back in the days when PB/DOS was my primary tool, I made an error that corrupted memory and the resulting error message said "the modem is out of paper". It took me hours and hours to find the problem, and it had nothing to do with the modem or the printer. As I recall, I was loading a file into an array, and because the user had used the DOS COPY command to copy the file, CHR$(26) had been appened to the file, making it one byte too big. I was absolutely 100% certain that PowerBASIC was at fault -- after all, how could a line of code that was using the serial port trip an "out of paper" error, but it was a simple programming error.

                          > it is naive to think that the PB compiler is 100% bug free

                          I agree, and I feel certain that everybody on this forum, including the PowerBASIC staff, agrees. After all, we are (relatively) sane, rational people. {G} But IMO it is also naive to assume that your code is 100% bug free and that it could not possibly be at fault.

                          -- Eric

                          -------------
                          Perfect Sync: Perfect Sync Development Tools
                          Email: mailto:[email protected][email protected]</A>



                          [This message has been edited by Eric Pearson (edited January 03, 2000).]
                          "Not my circus, not my monkeys."

                          Comment


                          • #14
                            > If I understand Eric correctly, the only possible reason
                            > a program could lockup by the addition of some "dummy"
                            > code, is if the error was alwas there and it was
                            > overwriting memory in Dgroup (where variables are
                            > stored), but the error did not manifest itself until
                            > the code segment somehow gets shifted by the addition
                            > of new lines of code.

                            The only possible reason? No, it could also be a compiler bug. {GGG} All I was trying to say was that it is possible for it to be something other than a compiler bug, and I described one possible scenario.

                            The most difficult GPF that I ever tracked down turned out to be a Windows bug. It had nothing to do with my code or PowerBASIC. Lots of things are possible...

                            -- Eric

                            -------------
                            Perfect Sync: Perfect Sync Development Tools
                            Email: mailto:[email protected][email protected]</A>

                            "Not my circus, not my monkeys."

                            Comment


                            • #15
                              Tim emailed me a copy of his "BIG" test program (or at least the code that generates the BIG program).

                              I cut the generated code down to size (source 50 KB, compiles to 28 KB), made some modifications and I believe it possibly demonstrates a bug when working with UDTs. The source is small enough for others to examine it and test it out.

                              You can download the test program at:

                              http://ezgui.com/pbbug.zip

                              The code was compiled on a Win 95 machine using PB 5.0.

                              In the zip file you will find the following:

                              test1.bas ' test program source code
                              compile.bat ' batch file to compile outside of IDE
                              test1.exe ' program compiled with bug
                              test1NG.exe ' program compiled with bug
                              test1OK.exe ' program compiled without bug

                              In the beginning of the bas file you will see these two lines of code:


                              %UseMsg = 1 ' Set to 1 to display messageboxs for Checks
                              %AddUDTS = 1 ' Set to 1 to create extra UDTs


                              If %ADDUDTS is set to 1 then some extra UDTS are defined as Globals.
                              if %ADDUDTS is set to 0 then those extra UDTS are not defined

                              In the compiled version that works OK, 4 message boxes will appear at different locations in the code while executed.

                              In the compiled version that is buggy, only 2 of the message boxes will appear. The program does NOT produce a GPF either. It just never executes the last two message boxes. Also if you use CTRL-ALT-DEL and display the Task Manager, you will find that the buggy version NEVER terminates.

                              Now, I don't know what will have if you use PB 6 or PB CC and you may get a GPF.

                              The test program does demonstrate that something is amiss.

                              While it could be the code, the code was generated by another program (which incremented each line) and the code looks OK to me.

                              The only difference between buggy version and the OK version is that the buggy one defines some extra UDTs (but doesn't access them).

                              The creation of some more UDTs shouldn't cause the program to do what it does.

                              The buggy versions seems to enter an infinite loop, since it doesn't GPF or terminate. This is exactly what was happeing with my software. I didn't get a GPF at all. It just would stop execution of the program and enter "La La land" (meaning, I don't know what it was doing).

                              The test program above does indicate a "possibility" of a problem.

                              What is needed now, is "VERIFICATION" !

                              Please everyone who can (including Dave, Lance) and test it out. Tell me if there is an actual error in the code or if the compiler seems to have a problem with it.

                              It is to everyones advantage to "not point fingers" at anyone, but to work together to verify if this is a bug or not. If it is not, then Tim and I will have learned a valuable lesson. If it is a bug, then the guys at PB will fix it "lickity split" !

                              I just want to know "why" it doesn't work ?

                              Chris Boss
                              Computer Workshop
                              Developer of "EZGUI"
                              http://cwsof.com
                              http://twitter.com/EZGUIProGuy

                              Comment


                              • #16
                                Note: The test program download is only 21KB in size.
                                Chris Boss
                                Computer Workshop
                                Developer of "EZGUI"
                                http://cwsof.com
                                http://twitter.com/EZGUIProGuy

                                Comment


                                • #17
                                  I just popped into this review at the last minute.

                                  Lets say Hypothetically that there is an issue in the compiler/editor.


                                  First thing, while this BBS is a great place to ask questions, get advice, share source, I take the approach that NTBUGTRAQ takes when finding issues in company software:

                                  One should ALWAYS try to contact the manufacturer first, determine IF there is an issue, and give them a chance to correct it before going public with it.

                                  Now, being that it was a source code question, (Although the title gave it away), even sometimes it's not WHAT you say to someone, about someone, etc, it's HOW you say it..The guys (And gals if there are any) at PB are awesome and have always been a cut above everyone else for their response time in the tech support area, so give them some credit...

                                  Given all that, I ran the test1.exe on NT 4.0, SP6a and it dr watsoned on me.

                                  Access violation (0xc0000005) at address 0x00405cc
                                  Test1NG.exe did the same.

                                  Test1OK.exe ran fine in NT.


                                  I recompiled it in PB/DLL 6.0 and received a Dr Watson identical to the first test1.exe


                                  Code:
                                  function: <nosymbols>
                                          004046b5 c7458001000000   mov   dword ptr [ebp-0x80],0x1 ss:0116e8a2=????????
                                          004046bc ffc6             inc     esi
                                          004046be 8b857cffffff     mov     eax,[ebp+0xffffff7c]   ss:0012fe18=00000001
                                          004046c4 8b4d80           mov     ecx,[ebp-0x80]         ss:0116e8a2=????????
                                          004046c7 83e901           sub     ecx,0x1
                                          004046ca c1e102           shl     ecx,0x2
                                          004046cd 0381807a4000     add     eax,[ecx+0x407a80]     ds:00407a80=00000000
                                          004046d3 8b4d80           mov     ecx,[ebp-0x80]         ss:0116e8a2=????????
                                          004046d6 83e901           sub     ecx,0x1
                                          004046d9 c1e102           shl     ecx,0x2
                                  FAULT ->004046dc 8981807a4900     mov     [ecx+0x497a80],eax     ds:00497a80=00000000
                                          004046e2 ff4580           inc     dword ptr [ebp-0x80]   ss:0116e8a2=????????
                                          004046e5 837d8002         cmp   dword ptr [ebp-0x80],0x2 ss:0116e8a2=????????
                                          004046e9 7ed1             jle     004046bc
                                          004046eb c7458001000000   mov   dword ptr [ebp-0x80],0x1 ss:0116e8a2=????????
                                          004046f2 ffc6             inc     esi
                                          004046f4 8b857cffffff     mov     eax,[ebp+0xffffff7c]   ss:0012fe18=00000001
                                          004046fa 8b4d80           mov     ecx,[ebp-0x80]         ss:0116e8a2=????????
                                          004046fd 83e901           sub     ecx,0x1
                                          00404700 c1e102           shl     ecx,0x2
                                          00404703 0381887a4000     add     eax,[ecx+0x407a88]     ds:00407a88=00000000
                                          00404709 8b4d80           mov     ecx,[ebp-0x80]         ss:0116e8a2=????????

                                  -------------
                                  Scott Turchin


                                  Scott Turchin
                                  MCSE, MCP+I
                                  http://www.tngbbs.com
                                  ----------------------
                                  True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                                  Comment


                                  • #18
                                    Has anyone tried running the code in the debugger?

                                    The debugger will actually tell you what line is causing a GPF when one occurs.

                                    --Dave


                                    -------------
                                    PowerBASIC Support
                                    mailto:[email protected][email protected]</A>

                                    Home of the BASIC Gurus
                                    www.basicguru.com

                                    Comment


                                    • #19
                                      Chris, is the "example" code (hyperlinked above) a rehash of Tim's code, or is this a cut down version of your own code? If you followed the other thread you will know that R&D are already aware of Tim's report.

                                      -------------
                                      Lance
                                      PowerBASIC Support
                                      ( mailto:[email protected][email protected]</A> )
                                      Lance
                                      mailto:[email protected]

                                      Comment


                                      • #20
                                        Lance;

                                        My test program is a cut down version of Tims that I believe will be easier to work with. It only uses code up to where I found execution was stopping. All the extra code Tims version was using was useless since it wasn't being executed at all. Execution was stopping at about the first 5% of the program.

                                        I thoroughly tested Tims version and then created mine so it would demonstrate the problem in the least possible code.

                                        This should make it easier for both PBs R&D and others to test it out.

                                        I added compiler directives to allow chnaging the code easier to demonstrate the difference between the good version and the bad version.

                                        The zip file is only 21 KB so anyone can try it out. Any debugging info anyone has from different debugging tools will be helpful.

                                        Chris Boss
                                        Computer Workshop
                                        Developer of "EZGUI"
                                        http://cwsof.com
                                        http://twitter.com/EZGUIProGuy

                                        Comment

                                        Working...
                                        X