CXX and Decwindows on X86 : Runtime crash in DisplayOfScreen(screen)

Post Reply

Topic author
joukj
Master
Posts: 247
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

CXX and Decwindows on X86 : Runtime crash in DisplayOfScreen(screen)

Post by joukj » Wed Jun 28, 2023 10:11 am

Hi all,

If you compile with CXX and call the Decwindows DisplayOfScreen(screen) the program crashes at run time. (if compiled wit CC it works fine.

The reproducer:

Code: Select all

rumba-jj) cxx/vers
clang version 10.0.1 (git@bitbucket.org:vms_software/llvm-10.0.1.git d469fd71c59
f33c7d998debe420a69abb31f1f57)
Build date: 06-16-2023
Target: x86_64-OpenVMS
Thread model: posix
InstalledDir: RUMBA$DKA100:[SYS0.SYSCOMMON.][SYSEXE]
rumba-jj) cc/vers
VSI C X7.4-785 (GEM 50X65) on OpenVMS x86_64 V9.2-1
rumba-jj) ty test.cxx
/*
 *  This is a sample X11 program that uses Xlib calls only (no toolkit!).
 *  It just writes to the console the events that the window receives.
 */

#include <stdio.h>

#include <X11/Xlib.h>

int main()
{
    Display* display = XOpenDisplay(NULL);

   printf( "Displays %d %d\n" , display , DefaultScreenOfDisplay(display) );
   Screen* screen=DefaultScreenOfDisplay(display);
   printf( "Displays %d %d\n" , display , screen);

   // when compiled with Clang it crashes on next line
   Display* display0 = DisplayOfScreen(screen);
   printf( "Displays %d %d\n" , display0 , screen);


    return 0;
}
rumba-jj) cxx test.cxx
$DISK6:[JOUKJ.test]test.cxx;81:14:33: warning: format specifies type 'int' but t
he argument has type 'Display *' (aka '_XDisplay *') [-Wformat]
   printf( "Displays %d %d\n" , display , DefaultScreenOfDisplay(display) );
                     ~~         ^~~~~~~
$DISK6:[JOUKJ.test]test.cxx;81:14:43: warning: format specifies type 'int' but t
he argument has type 'Screen *' [-Wformat]
   printf( "Displays %d %d\n" , display , DefaultScreenOfDisplay(display) );
                        ~~                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/X11/Xlib.h:160:37: note: expanded from macro 'DefaultScreenOfDisplay'
#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/X11/Xlib.h:159:34: note: expanded from macro 'ScreenOfDisplay'
#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$DISK6:[JOUKJ.test]test.cxx;81:16:33: warning: format specifies type 'int' but t
he argument has type 'Display *' (aka '_XDisplay *') [-Wformat]
   printf( "Displays %d %d\n" , display , screen);
                     ~~         ^~~~~~~
$DISK6:[JOUKJ.test]test.cxx;81:16:43: warning: format specifies type 'int' but t
he argument has type 'Screen *' [-Wformat]
   printf( "Displays %d %d\n" , display , screen);
                        ~~                ^~~~~~
$DISK6:[JOUKJ.test]test.cxx;81:20:33: warning: format specifies type 'int' but t
he argument has type 'Display *' (aka '_XDisplay *') [-Wformat]
   printf( "Displays %d %d\n" , display0 , screen);
                     ~~         ^~~~~~~~
$DISK6:[JOUKJ.test]test.cxx;81:20:44: warning: format specifies type 'int' but t
he argument has type 'Screen *' [-Wformat]
   printf( "Displays %d %d\n" , display0 , screen);
                        ~~                 ^~~~~~
6 warnings generated.
rumba-jj) link test,[-.rtl]xlib/opt
rumba-jj) run test
Displays 179424 32415904
Displays 179424 32415904
%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=800000000000
0000, PC=000000008000009B, PS=0000001B
%TRACE-F-TRACEBACK, symbolic stack dump follows
image     module    routine               line      rel PC           abs PC
TEST  $DISK6:[JOUKJ.test]test.cxx;81       #19 000000000000009B 000000008000009B
TEST                                         0 0000000080000103 0000000080000103
PTHREAD$RTL                                  0 000000008004122C FFFF83000A10322C
PTHREAD$RTL                                  0 0000000080002316 FFFF83000A0C4316
                                             0 FFFF8300085FC0A6 FFFF8300085FC0A6
DCL                                          0 000000008006778B 000000007ADFF78B
%TRACE-I-LINENUMBER, Leading '#' specifies a source file record number.
%TRACE-I-END, end of TRACE stack dump
rumba-jj) cc test.cxx
rumba-jj) link test,[-.rtl]xlib/opt
rumba-jj) run test
Displays 28128 46432
Displays 28128 46432
Displays 28128 46432
rumba-jj)


jreagan
VSI Expert
Master
Posts: 218
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: CXX and Decwindows on X86 : Runtime crash in DisplayOfScreen(screen)

Post by jreagan » Wed Jun 28, 2023 2:13 pm

I'll pass it along


Topic author
joukj
Master
Posts: 247
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: CXX and Decwindows on X86 : Runtime crash in DisplayOfScreen(screen)

Post by joukj » Fri Nov 29, 2024 5:39 am

Wow!!! with DecWindows V1.8-2 this seems to be solved. I did only limited testing but that worked!!!

Thanks
Jouk

Post Reply