Announcement

Collapse
No announcement yet.

Program Terminates

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

  • Program Terminates

    I've been having a problem with my program where it just stops without any error message of GPF

    I've found the statement that causes the problm.

    REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 13 ) AS GLOBAL STRING

    Is there any reason why this could cause this. The value if PluSearchResultsQty is only 154

  • #2
    >I've found the statement that causes the problm.

    Maybe, maybe not. Perhaps that is the statement where you actually pay for some sin you comitted earlier.

    You should really rn with TRACE as described in the FAQ Forum on "memory corruption"

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Hi Steve;

      It would be helpful if you could post a snippet of code showing how the array is used and why it is being REDIM'd. Better yet would be to, if possible, post the compilable code.

      I did notice this:

      "REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 13 ) AS GLOBAL STRING

      Is there any reason why this could cause this. The value if PluSearchResultsQty is only 154 "

      Comment


      • #4
        Am I overlooking the obvious here?


        Global Plu_Search_Results_Array_GL() AS STRING



        REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 13 ) AS STRING
        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


        • #5
          PluSearchResultsQty should read PluSearchResultsQty_GL

          The program is massive around 40,000 lines.

          I'll try to run it in debug and see what I can find.

          Comment


          • #6
            That's not REDIM PRESERVE in Real Life, is it? That would make it invalid to try to change the first dimension's number of elements.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Works for me. Must be something else you wrote!


              Code:
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "WIN32API.INC"
              GLOBAL Plu_Search_Results_Array_GL() AS STRING
              
              FUNCTION PBMAIN () AS LONG
                  LOCAL PluSearchResultsQty_GL AS LONG
                  PluSearchResultsQty_GL = 154
                  REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 13 ) AS GLOBAL STRING
                  ?"done it!",%MB_TASKMODAL,"debug"
              
              END FUNCTION

              Comment


              • #8
                Thinking the same thing...something prior is the cause...not where you find the cause




                Try the one thing that always helps (even when its a pain) and post a simple example showing the same problem
                Engineer's Motto: If it aint broke take it apart and fix it

                "If at 1st you don't succeed... call it version 1.0"

                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                Comment


                • #9
                  Going to be impossible to post code.

                  If this is a memory corruption? Then what statements can cause this?

                  If I run the program in dubug, what am I looking out for?

                  Thanks everyone for your answers here.

                  Comment


                  • #10
                    Originally posted by Steve Bouffe View Post
                    Going to be impossible...
                    ...I doubt it, unless the rules in the top-secret military establishment which employs you prevent it.

                    One approach to debugging: try commenting out blocks of code until the problem goes away. If that doesn't work, build a tiny application which does the same thing but without the detail. Copy in the detail from the old app chunk by chunk until the problem reappears.

                    Comment


                    • #11
                      Or, if array was previously [RE]DIM'd with a different number of subcripts... that, too, would be invalid.

                      But in either scenario I suggest (this and 'Real Life' included the PRESERVE option) , you'd get an ERR=9 following the REDIM, an ERR which could be tested.

                      However, either one of these scenarios should not result in a protection fault at that point so my money is on an untrapped error elsewhere in the program.

                      MCM
                      Last edited by Michael Mattias; 11 Jul 2008, 08:43 AM.
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Michael Mattias View Post
                        Or, if array was previously [RE]DIM'd with a different number of subcripts... that, too, would be invalid.
                        Another good reason to use a single dimension and just multiply out the subscripts.

                        Comment


                        • #13
                          Originally posted by Michael Mattias View Post
                          Or, if array was previously [RE]DIM'd with a different number of subcripts... that, too, would be invalid.
                          MCM
                          Sorry Michael I'm confused. This is valid, right?

                          Code:
                          FUNCTION PBMAIN () AS LONG
                              LOCAL PluSearchResultsQty_GL AS LONG
                              PluSearchResultsQty_GL = 154
                              REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 13 ) AS GLOBAL STRING
                              REDIM Plu_Search_Results_Array_GL( 1 TO PluSearchResultsQty_GL, 1 TO 10 ) AS GLOBAL STRING
                          END FUNCTION

                          Comment


                          • #14
                            Also I ran the exact code on my Vista laptop and no crashes.

                            Comment


                            • #15
                              As long as a REDIM does not use the PRESERVE keyword AND the REDIM does not attempt to change the number of dimensions it's legal.

                              >Also I ran the exact code on my Vista laptop and no crashes

                              That kind of proves it's an error somewhere else, since different operating systems will react differently. Personally I would have guessed that when you ran on a different operating system you'd still get a protection fault but it would have exhibited itself at a different point in your program.


                              As I said before run it with TRACE as described in this FAQ: FAQ: Finding memory corruption using TRACE

                              MCM
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                Steve, Just a thought. I see you are using a variable to DIM the array. In all places where the array bounds are referenced are you using LBOUND & UBOUND? Or are you using variables? Accessing an array that is out of bounds can (will) cause erratic errors, even far away from where the erroneous access occurs.

                                ============================
                                Faith is,
                                at one and the same time,
                                absolutely necessary
                                and altogether impossible.
                                Stanislaw Lem (1921 - 2006)
                                ============================
                                It's a pretty day. I hope you enjoy it.

                                Gösta

                                JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                Comment


                                • #17
                                  if you have a global statement before the program functions the as clause should not be necessary in the redim

                                  Global MyArray() as String

                                  Function PBMAIN() as LONG
                                  dim MyArray(0,0)
                                  k%=154
                                  REDIM Myarray(1 to k%,1 to 13) 'comment string array
                                  Client Writeup for the CPA

                                  buffs.proboards2.com

                                  Links Page

                                  Comment


                                  • #18
                                    Thanks Michael for the trace tip.

                                    I did this and the program still closes itself. When I opend the trace file, I have no reference to an Error as shown in the help file.


                                    I hardly ever use the LBOUD or UBOUND instead using variables to keep track of the array dimensions.

                                    This is a difficult one but it's important to sort it out now I think.

                                    Comment


                                    • #19
                                      I found that if I REM out this statement

                                      Code:
                                      THREAD CREATE Display_PLA_Product_Images_Thread( 0 ) TO PLA_Image_Display_Handle_GL
                                      So the following fuction is not active then no crashes.

                                      Code:
                                      FUNCTION Display_PLA_Product_Images_Thread( BYVAL D AS DWORD ) AS LONG
                                        '
                                        LOCAL hBmp_T AS DWORD
                                        LOCAL hBmpOld_T AS DWORD
                                        LOCAL hBmp_L AS DWORD
                                        LOCAL hBmpOld_L AS DWORD
                                        LOCAL TS1 AS STRING
                                        LOCAL TS2 AS STRING
                                        LOCAL XX AS LONG
                                        LOCAL YY AS LONG
                                        LOCAL Scaling AS SINGLE
                                        LOCAL JPGX AS LONG
                                        LOCAL JPGY AS LONG
                                        LOCAL Current_PLU_Code_Image_Displayed AS STRING
                                        LOCAL Current_PPLU_Code_Image_Displayed AS STRING
                                        '
                                        DO
                                          '
                                          SLEEP 250
                                          '
                                          IF Screen_Number_GL = %ScreenNumber_PLA_PLU_FullView THEN
                                            '
                                            IF Current_PLU_Code_Image_Displayed <> PLA_PLU_Image_Display_Product_Code_GL THEN
                                              '
                                              Current_PLU_Code_Image_Displayed = PLA_PLU_Image_Display_Product_Code_GL
                                              '
                                              CONTROL SET IMAGE EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImage, "#" + FORMAT$( %PLA_PLU_Or_PPLU_Blank_White_ResourceImage )
                                              CONTROL SET IMAGE EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImage, "#" + FORMAT$( %PLA_PLU_Or_PPLU_Blank_White_ResourceImage )
                                              CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImageButton, "Thumb"
                                              CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImageButton, "Large"
                                              CONTROL DISABLE EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImageButton
                                              CONTROL DISABLE EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImageButton
                                              '
                                              IF Current_PLU_Code_Image_Displayed <> "*" THEN
                                                '
                                                TS1 = $ServerPowerbasDirectory + "web\wwwroot\pimages\t" + Current_PLU_Code_Image_Displayed + ".jpg"
                                                '
                                                IF DIR$( TS1 ) <> "" THEN
                                                  ' Set The Image
                                                  TS2 = JPEG_Dimensions( TS1 )
                                                  JPGX = VAL( TS2 )
                                                  JPGY = VAL( PARSE$( TS2, 2 ))
                                                  CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImageButton, "Thumb ( " + FORMAT$( JPGX ) + " x " + FORMAT$( JPGY ) + " )"
                                                  CONTROL ENABLE EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImageButton
                                                  CALL Convert_Image_To_Bmp( TS1, "PLA_PLU_Image_T.bmp" )
                                                  DIALOG UNITS EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImage_Width, %PLA_Display_PLU_FullView_ThumbNailImage_Height TO PIXELS XX, YY
                                                  '
                                                  IF JPGX > JPGY THEN
                                                    Scaling = XX / JPGX
                                                  ELSE
                                                    Scaling = YY / JPGY
                                                  END IF
                                                  IF Scaling > 1 THEN Scaling = 1
                                                  '
                                                  hBmp_T = LOADIMAGE( BYVAL %NULL, "PLA_PLU_Image_T.bmp", %IMAGE_BITMAP, JPGX * Scaling * 0.95, JPGY * Scaling * 0.95, %LR_LOADFROMFILE )
                                                  '
                                                  CONTROL SEND EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImage, %STM_SETIMAGE, %IMAGE_BITMAP, hBmp_T TO hBmpOld_T
                                                  CONTROL REDRAW EposDlgHan_GL, %PLA_Display_PLU_FullView_ThumbNailImage
                                                END IF
                                                '
                                                TS1 = $ServerPowerbasDirectory + "web\wwwroot\pimages\" + Current_PLU_Code_Image_Displayed + ".jpg"
                                                '
                                                IF DIR$( TS1 ) <> "" THEN
                                                  ' Set The Image
                                                  TS2 = JPEG_Dimensions( TS1 )
                                                  JPGX = VAL( TS2 )
                                                  JPGY = VAL( PARSE$( TS2, 2 ))
                                                  CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImageButton, "Large ( " + FORMAT$( JPGX ) + " x " + FORMAT$( JPGY ) + " )"
                                                  CONTROL ENABLE EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImageButton
                                                  CALL Convert_Image_To_Bmp( TS1, "PLA_PLU_Image_L.bmp" )
                                                  DIALOG UNITS EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImage_Width, %PLA_Display_PLU_FullView_LargeImage_Height TO PIXELS XX, YY
                                                  '
                                                  IF JPGX > JPGY THEN
                                                    Scaling = XX / JPGX
                                                  ELSE
                                                    Scaling = YY / JPGY
                                                  END IF
                                                  IF Scaling > 1 THEN Scaling = 1
                                                  '
                                                  hBmp_L = LOADIMAGE( BYVAL %NULL, "PLA_PLU_Image_L.bmp", %IMAGE_BITMAP, JPGX * Scaling * 0.95, JPGY * Scaling * 0.95, %LR_LOADFROMFILE )
                                                  CONTROL SEND EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImage, %STM_SETIMAGE, %IMAGE_BITMAP, hBmp_L TO hBmpOld_L
                                                  CONTROL REDRAW EposDlgHan_GL, %PLA_Display_PLU_FullView_LargeImage
                                                END IF
                                                '
                                                IF hBmpOld_T THEN CALL DELETEOBJECT( hBmpOld_T )
                                                IF hBmpOld_L THEN CALL DELETEOBJECT( hBmpOld_L )
                                                '
                                              END IF
                                              '
                                            END IF
                                            '
                                          END IF
                                          '
                                          IF Screen_Number_GL = %ScreenNumber_PLA_PPLU_FullView THEN
                                            '
                                            IF Current_PPLU_Code_Image_Displayed <> PLA_PPLU_Image_Display_Product_Code_GL THEN
                                              '
                                              Current_PPLU_Code_Image_Displayed = PLA_PPLU_Image_Display_Product_Code_GL
                                              '
                                              CONTROL SET IMAGE EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImage, "#" + FORMAT$( %PLA_PLU_Or_PPLU_Blank_White_ResourceImage )
                                              CONTROL SET IMAGE EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImage, "#" + FORMAT$( %PLA_PLU_Or_PPLU_Blank_White_ResourceImage )
                                              CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImageButton, "Thumb"
                                              CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImageButton, "Large"
                                              CONTROL DISABLE EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImageButton
                                              CONTROL DISABLE EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImageButton
                                              '
                                              IF Current_PPLU_Code_Image_Displayed <> "*" THEN
                                                '
                                                TS1 = $ServerPowerbasDirectory + "web\wwwroot\pimages\t" + Current_PPLU_Code_Image_Displayed + ".jpg"
                                                '
                                                IF DIR$( TS1 ) <> "" THEN
                                                  ' Set The Image
                                                  TS2 = JPEG_Dimensions( TS1 )
                                                  JPGX = VAL( TS2 )
                                                  JPGY = VAL( PARSE$( TS2, 2 ))
                                                  CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImageButton, "Thumb ( " + FORMAT$( JPGX ) + " x " + FORMAT$( JPGY ) + " )"
                                                  CONTROL ENABLE EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImageButton
                                                  CALL Convert_Image_To_Bmp( TS1, "PLA_PPLU_Image_T.bmp" )
                                                  DIALOG UNITS EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImage_Width, %PLA_Display_PPLU_FullView_ThumbNailImage_Height TO PIXELS XX, YY
                                                  '
                                                  IF JPGX > JPGY THEN
                                                    Scaling = XX / JPGX
                                                  ELSE
                                                    Scaling = YY / JPGY
                                                  END IF
                                                  IF Scaling > 1 THEN Scaling = 1
                                                  '
                                                  hBmp_T = LOADIMAGE( BYVAL %NULL, "PLA_PPLU_Image_T.bmp", %IMAGE_BITMAP, JPGX * Scaling * 0.95, JPGY * Scaling * 0.95, %LR_LOADFROMFILE )
                                                  '
                                                  CONTROL SEND EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImage, %STM_SETIMAGE, %IMAGE_BITMAP, hBmp_T TO hBmpOld_T
                                                  CONTROL REDRAW EposDlgHan_GL, %PLA_Display_PPLU_FullView_ThumbNailImage
                                                END IF
                                                '
                                                TS1 = $ServerPowerbasDirectory + "web\wwwroot\pimages\" + Current_PPLU_Code_Image_Displayed + ".jpg"
                                                '
                                                IF DIR$( TS1 ) <> "" THEN
                                                  ' Set The Image
                                                  TS2 = JPEG_Dimensions( TS1 )
                                                  JPGX = VAL( TS2 )
                                                  JPGY = VAL( PARSE$( TS2, 2 ))
                                                  CONTROL SET TEXT EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImageButton, "Large ( " + FORMAT$( JPGX ) + " x " + FORMAT$( JPGY ) + " )"
                                                  CONTROL ENABLE EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImageButton
                                                  CALL Convert_Image_To_Bmp( TS1, "PLA_PPLU_Image_L.bmp" )
                                                  DIALOG UNITS EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImage_Width, %PLA_Display_PPLU_FullView_LargeImage_Height TO PIXELS XX, YY
                                                  '
                                                  IF JPGX > JPGY THEN
                                                    Scaling = XX / JPGX
                                                  ELSE
                                                    Scaling = YY / JPGY
                                                  END IF
                                                  IF Scaling > 1 THEN Scaling = 1
                                                  '
                                                  hBmp_L = LOADIMAGE( BYVAL %NULL, "PLA_PPLU_Image_L.bmp", %IMAGE_BITMAP, JPGX * Scaling * 0.95, JPGY * Scaling * 0.95, %LR_LOADFROMFILE )
                                                  CONTROL SEND EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImage, %STM_SETIMAGE, %IMAGE_BITMAP, hBmp_L TO hBmpOld_L
                                                  CONTROL REDRAW EposDlgHan_GL, %PLA_Display_PPLU_FullView_LargeImage
                                                END IF
                                                '
                                                IF hBmpOld_T THEN CALL DELETEOBJECT( hBmpOld_T )
                                                IF hBmpOld_L THEN CALL DELETEOBJECT( hBmpOld_L )
                                                '
                                              END IF
                                              '
                                            END IF
                                            '
                                          END IF
                                          '
                                        LOOP
                                        '
                                      END FUNCTION

                                      Comment


                                      • #20
                                        That a separate thread of execution is running should not in and of itself cause your program to terminate; however....

                                        You may be dealing with some timing issues here because you are updating the screen in an asynchronous fashion, issues resulting in inadvertent data corruption because you are using so many GLOBAL variables.

                                        Better I think to do this synchronously by simply calling the Display_PLA_Product_Images_Thread function on a WM_TIMER notification in the dialog procedure ("CALLBACK FUNCTION") for EposDlgHan_GL.

                                        Give that it try.

                                        MCM
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X