cancel
Showing results for 
Search instead for 
Did you mean: 

Why is application crashing after doing a build?

Former Member
0 Kudos

PB 12.5.1 (build 4015), Window 7.

 

I have a very, very small application that I needed to modify.  It is not set up like many I have designed with an application manager, frame, menu, and such (pfc).  The application opens a main! window with no menu.  I changed the application object open event adding script and added an user event for database connection.  I removed a login window that was not needed.  I execute/run in development mode and all works “fine”.  Then I created a project and did a build, full for speed as an executable with dlls.  When I run the exe the window of type main! opens but the application immediately crashes (last line in application open event is “open (w_window_main)”.  When I debug the program using the windows debugger I receive a message “Unhandled exception at 0x0061227f in fbds.exe 0xC0000005: Access violation writing location 0x0000003c.”.  Then I break and the call stack location is PBSHR125.DLL!0061227f().  The "main" window does open and is visible with the windows stop working window displayed too.

Any ideas or thoughts appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Da;

1) I have always compiled my PB applications to machine code since PB 6.5! I can tell you that since PB 8, if you have good clean PowerScipt code - with no warnings - the C++ version should run just great. In fact in all my frameworks (one being over 1/4M lines of code) - they all compile to machine code and run perfectly ... even using the latest PB versions 12.1 or 12.5.2.

2) Try running your EXE using the tracing option ( ie: EXEFILE /pbdebug  )?

3) In regards to Neil's question .. is the EXE running on the same PC as the PB IDE or a different machine?

Regards ... Chris

Former Member
0 Kudos

Hi Chris and company with thanks to all,

1. I too have been compiling exes for around a dozen applications (most pfc) since 1997 with very little issues since PB 5.#.  PBD build performed the same way crashing.

2. The exe is being run on a developer machine so every runtime file that is installed with PB is available.

3. LOL, probably amazing that I think this is the first time that I every used the trace option or had an issue I just couldn't figure out or this forum couldn't answer (like trying to load 34.393 into an integer (LOLA)).

4. This application script/data files are awful and it doesn't surprise me that some bad practice is causing this.  Maybe I did something stupid again though (I did add a global external function GetUserNameA but that seems to execute fine).  In the trace file I noticed some constructor event script running in a main window dw control (constructor event script in another application I inherited is causing an issue).  I think I will reorg that a bit.  Below is the trace output.  I can't quite figure out what/where line 34 is.

Executing event script CREATE for class FBDS, lib entry FBDS

  Executing instruction at line 2

  Executing instruction at line 3

  Executing instruction at line 4

  Executing instruction at line 5

  Executing instruction at line 6

  Executing instruction at line 7

  Executing instruction at line 8

End event script CREATE for class FBDS, lib entry FBDS

Executing event script OPEN for class FBDS, lib entry FBDS

  Executing instruction at line 7

  Executing instruction at line 8

  Executing event script GETUSERNAMEA for class FBDS, lib entry FBDS

  End event script GETUSERNAMEA for class FBDS, lib entry FBDS

  Executing instruction at line 9

  Executing instruction at line 11

  Executing instruction at line 17

  Executing event script UE_SECURITY for class FBDS, lib entry FBDS

    Executing instruction at line 5

    Executing instruction at line 7

    Executing instruction at line 17

    Executing instruction at line 18

    Executing instruction at line 19

    Executing instruction at line 20

    Executing instruction at line 21

    Executing instruction at line 22

    Executing instruction at line 28

    Executing instruction at line 29

    Executing instruction at line 39

    Executing instruction at line 40

    Executing instruction at line 41

    Executing instruction at line 42

    Executing instruction at line 43

    Executing instruction at line 49

    Executing instruction at line 51

    Executing instruction at line 52

    Executing instruction at line 53

    Executing instruction at line 54

    Executing instruction at line 55

    Executing instruction at line 57

    Executing instruction at line 58

    Executing instruction at line 63

    Executing instruction at line 66

    Executing instruction at line 67

    Executing instruction at line 68

    Executing instruction at line 70

    Executing instruction at line 72

    Executing instruction at line 76

    Executing instruction at line 81

    Executing instruction at line 82

  End event script UE_SECURITY for class FBDS, lib entry FBDS

  Executing instruction at line 19

  Executing instruction at line 24

  Executing instruction at line 25

  Executing instruction at line 30

  Executing event script CREATE for class W_RETRIEVE_OUTBREAK, lib entry W_RETRIEVE_OUTBREAK

    Executing instruction at line 2

    Executing instruction at line 3

    Executing instruction at line 4

    Executing instruction at line 5

    Executing instruction at line 6

    Executing instruction at line 7

    Executing instruction at line 8

    Executing instruction at line 9

    Executing instruction at line 10

    Executing instruction at line 11

    Executing instruction at line 12

    Executing instruction at line 13

    Executing instruction at line 14

    Executing instruction at line 15

    Executing instruction at line 16

    Executing instruction at line 17

    Executing instruction at line 18

    Executing instruction at line 19

    Executing instruction at line 20

    Executing instruction at line 21

    Executing instruction at line 40

  End event script CREATE for class W_RETRIEVE_OUTBREAK, lib entry W_RETRIEVE_OUTBREAK

  Executing event script CONSTRUCTOR for class DW_COUNTY, lib entry W_RETRIEVE_OUTBREAK

    Executing instruction at line 1

    Executing instruction at line 4

    Executing instruction at line 5

    Executing instruction at line 6

    Executing instruction at line 9

    Executing event script ROWFOCUSCHANGED for class DW_COUNTY, lib entry W_RETRIEVE_OUTBREAK

      Executing instruction at line 3

      Executing instruction at line 4

      Executing instruction at line 5

      Executing instruction at line 6

      Executing instruction at line 7

      Executing instruction at line 8

    End event script ROWFOCUSCHANGED for class DW_COUNTY, lib entry W_RETRIEVE_OUTBREAK

    Executing instruction at line 10

  End event script CONSTRUCTOR for class DW_COUNTY, lib entry W_RETRIEVE_OUTBREAK

  Executing event script OPEN for class W_RETRIEVE_OUTBREAK, lib entry W_RETRIEVE_OUTBREAK

    Executing instruction at line 1

    Executing instruction at line 2

  End event script OPEN for class W_RETRIEVE_OUTBREAK, lib entry W_RETRIEVE_OUTBREAK

  Executing instruction at line 32

  Executing instruction at line 34

Former Member
0 Kudos

Line 34 must be in OPEN event for class FBDS (your application object).

It seems to be the second statement after open of w_retrieve_outbreak (line 30).

Can you show us the code?

Former Member
0 Kudos

I looked there but there was no line 34 (I removed a message box so now line 32) ... here it is the last lines of the new debug file and the open script that only has 31 lines (I have a return after the open statement)...

* Note that below the messagebox ("Obtain User ... is only one line in the script.

End event script OPEN for class W_RETRIEVE_OUTBREAK, lib entry W_RETRIEVE_OUTBREAK

  Executing instruction at line 32

integer li_return, ll_retrieve, ll_test
string gs_test, ls_data, ls_dbparm, ls_user, ls_dbms, ls_server, ls_return
LONG ll_rows
BOOLEAN lb_return
ULONG lul_val

lul_val   = 255
lb_return  = GetUserNameA (ls_user, lul_val)
ls_user   = TRIM (ls_user)

IF ISNULL (ls_user) OR LEN (ls_user) < 1 THEN
MESSAGEBOX ('Obtain User Issue', 'Application Initialization User Problem 1/No GetUserName - Notify Programming')
HALT CLOSE
RETURN
END IF

li_return  = this.EVENT ue_security (ls_user)

IF li_return < 0 THEN
HALT CLOSE
RETURN
END IF

IF gi_test = 1 THEN
MessageBox ("Developing/Testing with " + UPPER (ls_data) + ' Database', &
     "* You are in DEVELOPMENT/TEST Mode * on Server " + ls_server &
     + '~r~r' + gs_version)
END IF

open (w_retrieve_outbreak)

Former Member
0 Kudos

Are you shure that your compiled application is from the same source and not an older version? Maybe there is an older dll file the applications uses instead of the new one?

Former Member
0 Kudos

Hi Da;

Can you try ....

1)  Replace GetUserNameA with ...

FUNCTION Boolean GetUserName (ref string lpBuffer, ref long nSize ) Library "ADVAPI32.DLL" alias for "GetUserNameW"

2) Change the calling code to ...

LONG   ll_val

ll_val        = 255

ls_user    = Space (ll_val + 1)

lb_return  = GetUserName (ls_user, lul_val)

Regards ... Chris

Former Member
0 Kudos

Genius ... thanks as always ... (GetUserName (ls_user, ll_val)) in your script though.

I went back and checked "my" applications and have the function as a local external function below in the application manager object and have not had any issues.  Should I be concerned?

function boolean GetUserNameA(ref string  lpBuffer, ref ulong nSize) library "ADVAPI32.DLL" alias for "GetUserNameA;Ansi"

Former Member
0 Kudos

Hi DA;

  Excellent news!  

  The old ANSI SDK calls like GetUserNameA ( ) should really be replaced with the Unicode equivalents since PB 10 when PowerBuilder itself went Unicode. Some functions like FindWindowA will not work unless you use FindWindowW instead in W7 and higher.

  So you may get away with the old ANSI SDK calls for now - but, I would highly recommend not continuing that practice. For the short term, you can most likely get away with the old ANSI SDK call format though.

  I think your "machine code" GPF issue was because you did not pre-allocate the REF variable before the SDK call (that is force a MALLOC - memory allocation). P-Code may save you in that case but M-Code (aka C++ compiler) must have these things preallocated. 

Good luck with the rest of your application!

Regards ... Chris

PS: Have you hugged your DataWindow today?  

Answers (3)

Answers (3)

former_member1333806
Active Participant
0 Kudos

Sounds like you've set the machine code option in the project painter. Machine code generation is known to be " temperamental"; try turning it off.

Former Member
0 Kudos

Is the sample small enough for you to upload with instructions so I can reproduce?

Former Member
0 Kudos

What code do you have in the open event of w_window_main? Do you have all the required runtime libraries together with the executables?