1. Julian I.
  2. PowerBuilder
  3. Monday, 7 October 2019 12:10 PM UTC
Hello,

We have migrated our application from PB7 to PB19 (Build 2082). We have pcs in W7 and W10. 
The application seemed to be working fine, but for some weeks some users reports random
Windows errors "App.exe stopped working." This is the report on Windows Application events:

Nombre de la aplicación con errores: planning.exe, versión: 11.0.0.0, marca de tiempo: 0x5ce82bed

Nombre del módulo con errores: unknown, versión: 0.0.0.0, marca de tiempo: 0x00000000

Código de excepción: 0xc0000005

Desplazamiento de errores: 0x1daaf9e0

Id. del proceso con errores: 0x11f8

Hora de inicio de la aplicación con errores: 0x01d57ce545c8e526

Ruta de acceso de la aplicación con errores: C:\Planning\planning.exe

Ruta de acceso del módulo con errores: unknown

Id. del informe: 539791cf-e8db-11e9-8d82-4ccc6aa14b4b

 

 

- http://schemas.microsoft.com/win/2004/08/events/event">

-

 

  1000

 2

 100

 0x80000000000000

 

 75449

 Application

 xxxx

 

 

-

 planning.exe

 11.0.0.0

 5ce82bed

 unknown

 0.0.0.0

 00000000

 c0000005

 1daaf9e0

 11f8

 01d57ce545c8e526

 C:\Planning\planning.exe

 unknown

 539791cf-e8db-11e9-8d82-4ccc6aa14b4b

 

 

 

We have optimized and full build libraries, but random errors continue

Any Idea?

Thanks.

 

Julian I. Accepted Answer Pending Moderation
  1. Friday, 6 December 2019 08:13 AM UTC
  2. PowerBuilder
  3. # 1
Do you know if there is any problem with PB and the windows user profile?

We use API windows functions a OleOjects...

When the crash happens, if we access in the same PC with another user and do the same operation
in the application, it works.

It seems that the crash happens more often to users who keep the windows session open several days.
We have included a GarbageCollect() instruction when the user closes the application in case 
the problem was due to memory leaks. But the problem continues to occur from time to time.

Regards.


 
 
Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 27 October 2019 23:35 PM UTC
  2. PowerBuilder
  3. # 2

I just realized that we ourselves declare the function like this too:

Function long ShellExecute( long hwnd,  string lpOperation, string lpFile, string lpParameters,  string lpDirectory,  integer nShowCmd) Library "shell32.dll" alias for "ShellExecuteW" 

but ... 

shouldn't that be:

Function long ShellExecute( long hwnd,  ref string lpOperation,  ref string lpFile, ref string lpParameters,  ref string lpDirectory,  integer nShowCmd) Library "shell32.dll" alias for "ShellExecuteW"

 

At least that's what msdn suggests: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew


I'm not sure if this might be a problem, as it seems to work for us without the "ref" but maybe it's a good idea to change the calls also to include the "ref" word when calling the function from Powerscript.
I'll give it a try tomorrow.

C++
HINSTANCE ShellExecuteW(
  HWND    hwnd,
  LPCWSTR lpOperation,
  LPCWSTR lpFile,
  LPCWSTR lpParameters,
  LPCWSTR lpDirectory,
  INT     nShowCmd
);

Comment
  1. Miguel Leeuwe
  2. Monday, 28 October 2019 07:48 AM UTC
Thanks for explaining that. I always assumed that the "P" meant pointer and therefore it needed to be by ref.
  1. Helpful
  1. John Fauss
  2. Monday, 28 October 2019 14:58 PM UTC
A "P" in a typedef'd WinAPI datatype name typically does indeed mean "pointer", Miguel, as Roland's comment above indicates. However, strings in C are implemented as a one-dimensional array of characters, and array arguments are always passed by supplying the address of the start of the array...thus, all strings are always passed via a pointer, even constant strings.

The REF keyword in PB tells PB to pass the memory address of the argument value so that the called method can modify the data at that address. When the argument is a Long, for example, it's easier to understand the difference. Since string arguments are always passed as an address, technically there's no difference - so that's probably why Microsoft makes the distinction between the LPCWSTR and LPWSTR datatypes...to help the programmer understand how the argument is to be used and to let the compiler know the called method can't make changes to the value.
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 28 October 2019 15:27 PM UTC
Thank you John, yes, so indeed I CAN use "ref" since they ARE by ref, but it's not NECESSARY for this case. Very informative.

Indeed, I remember that before PB introduced the ref keyword, the only parameters that you could use with API's needing a ref variable, were string variables only.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Saturday, 26 October 2019 14:41 PM UTC
  2. PowerBuilder
  3. # 3

From your debug log, I'm wondering what you are doing in the itemchanged() event as I also see an AcceptText().

Could you post the itemchanged() code?

 

Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Friday, 25 October 2019 19:16 PM UTC
  2. PowerBuilder
  3. # 4
Thanks Roland, I am very grateful to receive the help of a master like you.
Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 25 October 2019 12:31 PM UTC
  2. PowerBuilder
  3. # 5

I have an example of how to use that function:

http://www.topwizprogramming.com/freecode_runandwait.html

 

Comment
  1. Roland Smith
  2. Friday, 25 October 2019 12:54 PM UTC
Actually I'm using ShellExecuteEx but it will do the same thing.
  1. Helpful
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Friday, 25 October 2019 07:38 AM UTC
  2. PowerBuilder
  3. # 6

Hi,

The random problem continues, could it be a problem with ShellExecute function and KERNELBASE.DLL?

I have found several entries on the web related to this ...

Or there may be some error in the code:
We have defined a user object to include the api call (Local External Functions) and we are using a global function that we call to open the file indicated 
by parameter.

 

forward

global type n_cst_api_windows from nonvisualobject
end type
end forward

global type n_cst_api_windows from nonvisualobject autoinstantiate
end type

type prototypes
/* JIR (10/10/2019) EV119097: Pasamos a utilizar la versión UNICODE de las funciones del API de Windows */
FUNCTION long ShellExecute &
    (ulong ihwnd ,string lpszOp, &
     string lpszFile, string lpszParams, &
     string lpszDir, int wShowCmd) &
LIBRARY "shell32.dll" ALIAS FOR "ShellExecuteW"
end prototypes

on n_cst_api_windows.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_cst_api_windows.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

 

global type f_abrir_documento from function_object
end type

forward prototypes
global function integer f_abrir_documento (string as_fichero)
end prototypes

global function integer f_abrir_documento (string as_fichero);/*************************************************************************************
* Funcion        : f_abrir_documento
* Descripción    : Muestra el contenido del fichero que se pasa como parametro. Abriendolo
*                      a partir del programa que tenga asociado la extension. Si no encuentra una
*                      asociación se ejecuta el "Abrir con ..." de Windows
*
*                      El último argumento es el estilo de la ventana:
*
*                        SW_HIDE 0                            SW_SHOWNORMAL 1                     SW_SHOWMINIMIZED 2            
*                        SW_SHOWMAXIMIZED 3            SW_SHOWNOACTIVATE 4                SW_SHOW 5                    
*                        SW_MINIMIZE 6                    SW_SHOWMINNOACTIVATE 7            SW_SHOWNA 8                    
*                        SW_RESTORE 9                    SW_SHOWDEFAULT 10            
*
* Argumentos    :    as_fichero
*
* Devuelve        :     -1 Error
                        -2 No existe el fichero
                         1 Ok
*
**************************************************************************************
*        Fecha              Autor                    Comentarios
*    --------------        ----------        -------------------------------------
*    11/10/2019            JIR            EV119097: Versión Inicial        
************************************************************************************/
string ls_Null, ls_msg
long   ll_rc

if f_es_vacio(as_fichero) then Return -1
If Not FileExists(as_fichero) then Return -2

SetNull(ls_Null)

TRY    
    ll_rc = gnv_API.ShellExecute (handle( this ), "open", as_fichero, ls_Null, ls_Null, 1)
CATCH (runtimeerror er1)
    messageBox("Atención", "Se produjo un error de ejecución (ShellExecute) al abrir el fichero " + as_fichero)
    RETURN -1
END TRY

if ll_rc = 27 OR ll_rc = 31 then

    TRY    
        Run ('rundll32 shell32,OpenAs_RunDLL ' + as_fichero)
    CATCH (runtimeerror er2)
        messageBox("Atención", "Se produjo un error de ejecución (rundll32) al abrir el fichero " + as_fichero)
        RETURN -1
    END TRY

elseif ll_rc <= 32 Then

    Choose Case ll_rc
        Case 0
            ls_msg = "The operating system is out of memory or resources"
        Case 2
             ls_msg = "El fichero no existe"
        Case 3
             ls_msg = "Ruta no encontrada"
        Case 5
             ls_msg = "El sistema operantivo no permite el acceso al fichero indicado"
        Case 8
             ls_msg = "No hay suficiente memoria para completar la operación"
        Case 10
             ls_msg = "Versión incorrecta de Windows"
        Case 11
             ls_msg = "Invalid EXE file or error in EXE image"
        Case 12
            ls_msg = "Application was designed for a different operating system"
        Case 13
            ls_msg = "Application was designed for MS-DOS 4.0"
        Case 15
            ls_msg = "Attempt to load a real-mode program"
        Case 16
            ls_msg = "Attempt to load a second instance of an application with non-readonly data segments"
        Case 19
            ls_msg = "Attempt to load a compressed application file"
        Case 20
            ls_msg = "Dynamic-link library (DLL) file failure"
        Case 26
            ls_msg = "A sharing violation occurred"
        Case 27
             ls_msg = "Asociación a fichero no válida o incompleta"
        Case 28
             ls_msg = "The DDE transaction could not be completed because the request timed out"
        Case 29
             ls_msg = "DDE transaction failed"
        Case 30
             ls_msg = "The DDE transaction could not be completed because other DDE transactions were being processed"
        Case 31
             ls_msg = "No existe ninguna asociación con la extensión del fichero"
        Case 32
             ls_msg = "DLL not found"
        Case Else
             ls_msg = "Unknown error"
    End Choose
    
    MessageBox("Error", ls_msg)
    return -1
    
end if

Return 1
end function

Thanks for your help.

 

 

Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Monday, 21 October 2019 15:36 PM UTC
  2. PowerBuilder
  3. # 7

Hi Roland,


Sorry, we changed all calls to the windows API to use the unicode version as recommended,
but this has not solved the problem. At the point where it fails we are not launching any API calls.

We have restart the user session on windows and it stops crashing.
The user has told us that he had not turned off the computer for several days.

We will continue investigating...

Regards
 
Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 21 October 2019 14:54 PM UTC
  2. PowerBuilder
  3. # 8

If you can narrow it down to a particular Win API function, post it here. There is a good chance the declaration is wrong.

Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Monday, 21 October 2019 14:47 PM UTC
  2. PowerBuilder
  3. # 9

Hello,

We have changed calls to the Windows API and on some computers it continues to fail.
We have detected that it happens when the user's Windows session has been open for several days, 
because when the user restarts the session on Windows it seems to stops crashing.


-
-
 
  1000
  2
  100
  0x80000000000000
 
  70848
  Application
  PCE0236.anecval.local
 
 

-
  planning.exe
  11.0.0.0
  5ce82bed
  KERNELBASE.dll
  6.1.7601.24524
  5d8045b2
  c0000005
  0000845d
  7a4
  01d5842927b6d29e
  C:\Planning\planning.exe
  C:\Windows\system32\KERNELBASE.dll
  878ab65e-f01c-11e9-8ded-6cf0492a8224
 

 


I'm not sure, but the error seems to occur when a value is autocompleted in a field with DDDW and 
the user changes to another field without accepting the value (NO AcceptText)

End event +ITEMCHANGED for class U_DW_ANE, lib entry U_DW_ANE
                    Executing object function +DESTROY for class DWOBJECT, lib entry _TYPEDEF
                      Executing instruction at line 2557
                      Executing object function __DESTROY_OBJECT for class DWOBJECT, lib entry _TYPEDEF
                        Executing system dll function
                      End class function __DESTROY_OBJECT for class DWOBJECT, lib entry _TYPEDEF
                      Executing instruction at line 2558
                    End class function +DESTROY for class DWOBJECT, lib entry _TYPEDEF
                  End class function ACCEPTTEXT for class DW_1, lib entry W_PLANNING_COMERCIAL_CONSULTA
                  Executing instruction at line 1
                  Executing instruction at line 2
                End event +LOSEFOCUS for class U_DW_ANE, lib entry U_DW_ANE
                Executing object function +DESTROY for class DWOBJECT, lib entry _TYPEDEF
                  Executing instruction at line 2557
                  Executing object function __DESTROY_OBJECT for class DWOBJECT, lib entry _TYPEDEF
                    Executing system dll function
                  End class function __DESTROY_OBJECT for class DWOBJECT, lib entry _TYPEDEF
                  Executing instruction at line 2558
                End class function +DESTROY for class DWOBJECT, lib entry _TYPEDEF


 
 
Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Wednesday, 9 October 2019 12:08 PM UTC
  2. PowerBuilder
  3. # 10
Thanks everyone for your help.
Now we have to get down to work and make the changes you suggest.

- Review "ANSI" Windows API calls
- Update PFCs
Regards.
 
Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 9 October 2019 14:13 PM UTC
Hi Julian;

Just an FYI on the PFC's. They are basically like they were back in the PB 12.0 (or even slightly older) days and have been mostly migrated forward "as is" into PB 12.6 => PB2017. Thus, you may still find lots of "ANSI" API calls, no newer alignment for W10 features and definitely no support for all the new features in PB12.6 (64 bit, Dockable Windows), PB2017Rx (lots) and PB2019 (lots). There is also no PB2019 version yet as well that I can see on the PFC website. Food for thought as you migrate.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Tuesday, 8 October 2019 15:03 PM UTC
  2. PowerBuilder
  3. # 11

Hi Roland,

I have look for ";Ansi" on project libraries and I have found same functions declarated with ";ANSI" (in our own libraries and in PFC libraries). Could this be the problem?

Regards.

Comment
  1. Roland Smith
  2. Tuesday, 8 October 2019 15:42 PM UTC
;Ansi tells the PB runtime to convert all strings from Unicode to Ansi. The Ansi string is then passed into the function. Any by reference string arguments are converted from Ansi to Unicode. Normally this should work, it is something to check. Many times external functions abort because a by reference string argument isn't pre-allocated (using the Space function). If the pre-allocation isn't big enough to hold the result, an abort can occur.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 8 October 2019 15:45 PM UTC
The thing with using Ansi external functions is that the PB runtime converts the string from Unicode to Ansi, then the 'A' version of the function converts the string from Ansi to Unicode and passes it to the 'W' version. Then if you have a by ref string, the 'W" version passes that to the 'A' version which converts it from Unicode to Ansi. The Ansi string is then converted to Unicode by the PB runtime. As you can see, using the Ansi version of a function causes a bunch of unnecessary work.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 8 October 2019 15:50 PM UTC
Hi Julian;

Looks like your App is using the PFC. Did you download the latest PFC that matches your PB IDE version?

FYI: https://github.com/OpenSourcePFCLibraries

Regards ... Chris
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 8 October 2019 13:27 PM UTC
  2. PowerBuilder
  3. # 12

PB7 uses ANSI (single byte) strings while PB10 and higher use Unicode (double byte) strings.

I would check for Windows API functions that might be causing it to abort.

Some functions that take a string also have a length argument. Some are character length and some are byte length so you have to review the documentation for the function to make sure it is correct. Also, make sure you are using the W version of functions instead of the A version. The conversion process adds ";ANSI" to the end of external function declarations. That won't be needed if you use the W version.

 

Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Tuesday, 8 October 2019 07:16 AM UTC
  2. PowerBuilder
  3. # 13

Thanks for the answers.

We are going to test executing the application in the compatibility mode proposed by windows.


I keep you informed.
Regards.
 

 

Comment
  1. David Peace (Powersoft)
  2. Tuesday, 8 October 2019 09:13 AM UTC
Glad we could help.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 7 October 2019 15:59 PM UTC
  2. PowerBuilder
  3. # 14

Hi Julian;

  FYI: https://social.technet.microsoft.com/Forums/windows/en-US/9e83c5fc-caa4-4d64-82a2-342bda0b8673/exception-code-0xc0000005?forum=w7itproappcompat

  FWIW: Try using the RHMB on your PB App's EXE and using W10's "Troubleshoot compatibility" option.

Regards ... Chris

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 7 October 2019 14:49 PM UTC
  2. PowerBuilder
  3. # 15

Hi Julian;

   I wonder if the cause of these random "not responding" errors are due to either a network or more likely DB resource issue. For example, a long table / area lock that is not getting released? Anything suspicious in the O/S event and/or DB logs around the time this happens?

Regards ... Chris

Comment
  1. David Peace (Powersoft)
  2. Monday, 7 October 2019 15:47 PM UTC
I'm not sure he said "not responding", but "Stopped Working", I found this...



“Application.exe has stopped working” is a Windows error that shows up when a particular program crashes. This issue might occur on any versions of the operating system. However, recently we received a bunch of questions from Windows 10 users. So, it seems that the latest version of the OS is most affected by this error.



Typically, the pop-up warning shows up when a program stops running and needs to shut down by force. Numerous reasons can cause “Application.exe has stopped working” error. It might be related to:



malware attack,[1]

problems with compatibility settings,

issues with temporary files,

corrupted Windows registry[2] entries,

damaged system files.



As Chris said, it sounds like it's more environmental.

Cheers

David
  1. Helpful
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Monday, 7 October 2019 14:34 PM UTC
  2. PowerBuilder
  3. # 16

Hello David:

We run Powerbuilder Runtime Packager, export the dlls in a new folder and copy it to pc user in the app directory.

 

Comment
  1. David Peace (Powersoft)
  2. Monday, 7 October 2019 15:43 PM UTC
It was worth checking.

Next question, what is the application trying to do when it stopped / crashes.
  1. Helpful
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Monday, 7 October 2019 13:06 PM UTC
  2. PowerBuilder
  3. # 17

How are you building your exe?

Do you have the same version of PB runtime DLLs deployed as used on the build machine?

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.