CreateWindow(W4GLEditClass) failed with error 1158

410 views
Skip to first unread message

Paul White

unread,
May 23, 2018, 5:11:53 AM5/23/18
to openroa...@googlegroups.com
For one or two PCs, we are observing frequent instability in OpenROAD.

The frame becomes unusable.
Sometimes OpenROAD process disappears without warning.

Win7 Pro SP1 64bi 8GB RAM
OpenROAD OR R 6.2.0 (int.w32/00) BLD: 6.2.0/15201 p15278

Trace log shows repeated entries like this...
CreateWindow(W4GLEditClass) failed with error 1158
CreateWindow(W4GLEditClass) failed with error 1158
CreateWindow(W4GLEditClass) failed with error 1158


Any ideas?

Paul


Xavier Magnan

unread,
May 23, 2018, 5:51:26 AM5/23/18
to openroa...@googlegroups.com

Hello Paul,


Error 1158 indicates the following

ERROR_NO_MORE_USER_HANDLES
1158 (0x486)
The current process has used all of its system allowance of handles for Window Manager objects.

The runtime default in OR62 (after p14746) now has RequireRealFields set to TRUE. A new command line flag -fakefields was added for backward compatibility. Please set this on the command line when runnning your applications.

So flag -fakefields  can help to solve the problem because it’s allow you to use less handles

However in some case you’ll need to redesigned your frame to not have so many objects allocated at the same time.

Window Handle :
The limit is 10000, this is a Windows default setting.

 

I hope this help

With regards.

 

Xavier

Actian Support Team.

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at https://groups.google.com/group/openroad-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/5b053057.1c69f...@mx.google.com.
For more options, visit https://groups.google.com/d/optout.

Paul White

unread,
May 23, 2018, 6:25:06 AM5/23/18
to openroa...@googlegroups.com

Thank you Xavier.

 

Most likely there is one frame which is causing the problem.

The error just affects the one user on two different PCs

I have been looking at taskmgr GDI handles to see if I can capture the faulty frame.

 

Paul

Bodo Bergmann

unread,
May 23, 2018, 7:11:01 AM5/23/18
to openroa...@googlegroups.com

If it’s only happening for one user, the user might also have some other program running which is exhausting the handles.

Windows USER handles have also a 32K system limit (shared by all programs).

 

BTW: There are GDI handles and USER handles (the latter one is the one involved in the error encountered).

 

Bodo.

 

Bodo Bergmann

Principal Software Engineer

Actian | Engineering

www.actian.com

GESELLSCHAFTSANGABEN: Actian Germany GmbH | Geschäftsführer: Stephen Mark Padgett, Suzanne Gisborn, Gregory S. Hampton

Sitz der Gesellschaft: Hamburg| Handelsregister: Amtsgericht Hamburg | HRB 135991| USt-IdNr: DE252449897

pwhite peercore

unread,
May 23, 2018, 8:09:15 AM5/23/18
to openroa...@googlegroups.com

Thanks Bodo and Xavier

 

I have been able to reproduce the problem.

It is a power user running a complex frame which opens a second, bigger frame with callframe.

Just open the second frame 6 times to see screen painting problems and error 1158 in the trace.

Taskmgr shows “USER Objects” = 9998

 

If I close some frames, then the stat comes down and OpenROAD can keep running normally.

I suspect there is some corruption happening because occasionally w4glrun disappears without a trace (pun intended)

 

Is it possible to capture this event within the 4GL and close elegantly?

I guess we can limit the frame opens, and I will try out the fakefields switch.

 

Paul

 

image002.jpg

Paul White

unread,
May 23, 2018, 8:24:27 AM5/23/18
to openroa...@googlegroups.com

With -fakefields I am able to open the second frame about 30 times before running into problems.

 

 

 

 

From: pwhite

Sent: Wednesday, 23 May 2018 10:09 PM


To: 'openroa...@googlegroups.com'
Subject: RE: [openroad-users] CreateWindow(W4GLEditClass) failed with error 1158

 

Thanks Bodo and Xavier

Bodo Bergmann

unread,
May 24, 2018, 5:47:18 AM5/24/18
to openroa...@googlegroups.com

Paul,

 

For your question “Is it possible to capture this event within the 4GL and close elegantly?” the answer is:

There is no way to catch the event in the 4GL.

And as the USER resources are exhausted, you wouldn’t even be able to create an error message window (requiring a USER handle).

 

What you should do is: Check available resources BEFORE you call (or open) a frame that requires a lot of them.

This can be done using the two Win32 API functions GetCurrentProcess (from user32.dll) and GetGuiResources (from kernel32.dll).

See https://msdn.microsoft.com/de-de/library/windows/desktop/ms683179(v=vs.85).aspx
and https://msdn.microsoft.com/en-us/library/windows/desktop/ms683192(v=vs.85).aspx

You declare them in OpenROAD as 3GL Procedures (returning INTEGER, GetCurrentProcess might return an INTEGER8 in a 64-bit OpenROAD version – not tested).

 

Example:

 

declare

      cnt_userobj = INTEGER NOT NULL;

enddeclare

{

      cnt_userobj = GetGuiResources(GetCurrentProcess(), 1); // 1 = GR_USEROBJECTS

 

      // Only start the frame if we have at least 2000 USER objects remaining

      IF cnt_userobj>8000 THEN

            MESSAGE 'Not enough USER resources to open the window!' + HC_NEWLINE +

'Please close other windows before trying again!';

      ELSE

            CALLFRAME mybigframe();

      ENDIF;

}

 

HTH.

 

Regards,
Bodo.

Paul White

unread,
May 24, 2018, 8:02:07 AM5/24/18
to openroa...@googlegroups.com

Thank you Bodo,

Pretty clever.

The good news is my power user experienced no crashes and no recurrence of error 1158 today after adding fakefields switch.

 

 

I do prefer your approach in avoiding the situation in the first place.

Interesting problem trying to recover from low level resource problems without total crash.

 

Seeing the error 1158 in the trace window makes me think there may be a way to expose this type of low level error to the business logic.

Perhaps with a user event?  Or perhaps a callable routine similar to inquire_sql?

 

Is it worthy of an enhancement request or just not ever remotely possible?

 

I think it is worthy if we can make OpenROAD more robust without coding low level O/S specific calls.

 

My suggestion..

If a frame cannot build clean, then CALLFRAME needs to fail with a useful return code.

Automatic memory / handle clean up  and can we avoid throwing and catching exception objects too?

 

Lstatus = CALLFRAME mybigframe();

IF Lstatus <> 0 THEN                       /* 1558 returned? */

                Record error from curproc.LastError()

                Allow user to exit elegantly

 

Dynamic frame build should be able to capture errors

 

for x = 1 to 100 do

fld[x] = EntryField.Create();
IF fld[x] IS NULL THEN

                                Record error from EntryField.LastError()               /* how to capture the real error code? */

Return fail

 

Paul

 

 

From: openroa...@googlegroups.com [mailto:openroa...@googlegroups.com] On Behalf Of Bodo Bergmann
Sent: Thursday, 24 May 2018 7:47 PM
To: openroa...@googlegroups.com
Subject: RE: [openroad-users] CreateWindow(W4GLEditClass) failed with error 1158

 

Paul,

--

You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at https://groups.google.com/group/openroad-users.

Bodo Bergmann

unread,
May 24, 2018, 9:53:26 AM5/24/18
to openroa...@googlegroups.com

Paul,

 

The return status wouldn’t work as a CALLFRAME returns data according to the Datatype defined for the frame.

 

Sending a UserEvent  – similar to the errorevent in the SendUserEvent() method – is probably not a good idea,
as this requires the caller to be a frame (which can process events), so it wouldn’t work when the frame is started from a 4GL procedure or method,
and in case of a CALLFRAME we get a conflict with the current event block still being executed.

 

A possibility would be the setting of a SessionObject attribute, e.g. the existing ExternalError attribute, or a new one to be added.

 

Perhaps using an exit trap would also be a way to go.
If OpenROAD would produce a behaviour like an EXIT statement if such an error occurs, this could be trapped using the ProcExec.SetExitTrap() method.

 

It would be good if you could open an “Idea” in the support portal for this.

 

Bodo.

Adrian Williamson

unread,
May 29, 2018, 4:16:25 AM5/29/18
to openroa...@googlegroups.com

Hi,

 

I opened a request for OpenROAD to have proper exception/error handling some time ago – vote it up.

 

Cheers

 

Adrian

 

image001.png

Allan Biggs

unread,
Oct 16, 2018, 6:39:50 AM10/16/18
to openroa...@googlegroups.com
Is there a way on forcing an on childexit event when clicking a button on the current form

I am sure I have done this in the past - but age is catching up with me :-)  and I cannot remember the frame I did it in !!!

Thanks
Allan


This communication is for use by the intended recipient and contains
information that may be Privileged, confidential or copyrighted under
applicable law. If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited. Please notify the sender by
return e-mail and delete this e-mail from your system. Unless explicitly
and conspicuously designated as "E-Contract Intended", this e-mail does
not constitute a contract offer, a contract amendment, or an acceptance
of a contract offer. This e-mail does not constitute a consent to the
use of sender's contact information for direct marketing purposes or for
transfers of data to third parties.

Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

          http://www.DuPont.com/corp/email_disclaimer.html

Christian Birkl

unread,
Oct 16, 2018, 6:54:37 AM10/16/18
to openroa...@googlegroups.com

Is it done if the button has FocusBehavior TakeFocus?

 

Mit freundlichen Grüßen / With kind regards

Christian Birkl
Software Engineering

http://www.gamed.com/img/logo-gamed-signatur.png

GAMED Gesellschaft für Angewandte
Mathematik und EDV mbH

Address: Harter Straße 48, 8053 Graz, Austria
Phone:   +43 (0) 316  27 86 60 - 18
Fax:       +43 (0) 316  27 86 60 - 10
E-Mail:
    Christi...@gamed.com
Internet:   www.gamed.com
Register:  FN 50094v
Court:      Handelsgericht Graz
VAT_ID:   ATU28647907

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. Thank you for your cooperation.

--

You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at https://groups.google.com/group/openroad-users.

Allan Biggs

unread,
Oct 16, 2018, 7:03:56 AM10/16/18
to openroa...@googlegroups.com
Christian ,

That works


thanks very much
Allan

.
To view this discussion on the web visit
https://groups.google.com/d/msgid/openroad-users/DB6PR0701MB2695D9C787B5AC46A41B8CFCFEFE0%40DB6PR0701MB2695.eurprd07.prod.outlook.com.
For more options, visit
https://groups.google.com/d/optout.


Christian Birkl

unread,
Oct 16, 2018, 7:07:15 AM10/16/18
to openroa...@googlegroups.com

Allan Biggs

unread,
Oct 18, 2018, 9:21:25 AM10/18/18
to openroa...@googlegroups.com
Hi,

Is it possible to open or move the trace window in/to (say) bottom LH corner of the screen?

Bodo Bergmann

unread,
Oct 18, 2018, 10:24:05 AM10/18/18
to openroa...@googlegroups.com

Hi Allan,

 

You cannot define the original opening position of the OpenROAD Trace Window,
but it is possible to move (and resize) it by using a few Win32 API functions as 3GL procedures:

 

  • Define the following 3GL procedures in your application,
    all with a “Return Value” of “integer” and “Library Name” of “user32.dll”:
    • FindWindowExA
    • GetWindowThreadProcessId
    • SetWindowPos
  • Define a Global Variable (type: integer not null): hwndTrace
  • In your starting component of your application use the following script:

 

declare

    rv = INTEGER NOT NULL;

    pid = INTEGER NOT NULL;

    pid_tw = INTEGER NOT NULL;

    threadid = INTEGER NOT NULL;

enddeclare

{

    pid = GetCurrentProcessId();

    hwndTrace = FindWindowExA(0, 0, 'IITRACE', 'OpenROAD Trace Window ');

    WHILE (hwndTrace > 0)

    DO

        // Check that it is the trace window belonging to this process

        threadid = GetWindowThreadProcessId(hwndTrace, BYREF(pid_tw));

        IF (pid_tw = pid)

        THEN

            ENDLOOP;

        ENDIF;

        // Find the next OpenROAD Trace Window (in case there are more than one OpenROAD apps running)

        hwndTrace = FindWindowExA(0, hwndTrace, 'IITRACE', 'OpenROAD Trace Window ');

    ENDWHILE;

    IF (hwndTrace=0)

    THEN

        MESSAGE 'No Trace Window found for this process!';

    ENDIF;

}

 

Whenever you want to position and/or resize the Trace Window you use this script
(where x and y define the window position and width and height the dimensions (all values in pixel):

IF (hwndTrace > 0) THEN

      CALLPROC SetWindowPos(hwndTrace, 0,  x, y, width, height, 0);

ENDIF

 

HTH.

 

Regards,

Bodo.

 

Bodo Bergmann

Principal Software Engineer

Actian | Engineering

www.actian.com

GESELLSCHAFTSANGABEN: Actian Germany GmbH | Geschäftsführer: Stephen Mark Padgett, Suzanne Gisborn, Gregory S. Hampton

Sitz der Gesellschaft: Hamburg| Handelsregister: Amtsgericht Hamburg | HRB 135991| USt-IdNr: DE252449897

 

--

You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at https://groups.google.com/group/openroad-users.

Andy

unread,
Oct 18, 2018, 6:35:54 PM10/18/18
to openroa...@googlegroups.com
Hi Allan,

I use this program from time to time to manipulate windows.

https://github.com/ritchielawrence/cmdow

Hope it helps.

Kind Regards,
Andy
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at https://groups.google.com/group/openroad-users.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages