This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

compiling X programmes and run-time crash


I am trying to get a simple X programme running on cygwin B20.1, but
can't even create a window.

I have STATUS_ACCESS_VIOLATION crashes when trying to get the
DefaultRootWindow for the display. Presumably I do something stupid wrong,
but can't figure it out. (My X knowledge is rather old...).

Here is the simplest code I could come up with:

#include <X11/Xlib.h>

int main()
  Display *SCX_display;
  Screen * defscr;
  Window rootwindow;

  /* Note: explicit use of $DISPLAY does not help */
  /* SCX_display = XOpenDisplay ("localhost:0.0");*/
  SCX_display = XOpenDisplay (NULL);

  if (!SCX_display)
      return 1;

  /* next is the equivalent of
   rootwindow = DefaultRootWindow(SCX_display);
  defscr =  ScreenOfDisplay(SCX_display,DefaultScreen(SCX_display));
  /* ACCESS VIOLATION in next line: defscr points to nonsense */
  rootwindow = defscr->root;

  XCloseDisplay (SCX_display);
  return 0;

When I run gdb and examine *SCX_display, I see that nscreens=0
(SCX_display->nscreens = 'number of screens on this server'
 = ScreenCount(SCX_display))

I guess this 'explains' why the default screen is nonsense. But why
is ScreenCount(SCX_display) == 0 ?

Thanks for any help,


PS: More details

I have NT4.0 sp6, cygwin B20.1, gcc 2.95.2,
X11R6.4 (don't recall from where, sorry. I think it was Andy's (?)
distribution, called x11-b20_tar.gz),
and run Exceed 6.1 as X server.

Note that
- I can run precompiled X programmes without problems (xterm, xclock...)
(ok, I tested only those included in the X distribution)
- the (full) programme works fine on a few Unix systems
 (even with a remote display to my NT system).

screenshot: running gdb
(gdb) p *SCX_display
$1 = {ext_data = 0x0, free_funcs = 0xa032478, fd = 3, conn_checker = 0,
  proto_major_version = 11, proto_minor_version = 0,
  vendor = 0xa032570 "Hummingbird Communications Ltd.",
  resource_base = 4194304, resource_mask = 4194303, resource_id = 1,
  resource_shift = 0,
  resource_alloc = 0x670b12a0 <_size_of_stack_reserve__+1695224480>,
  byte_order = 1, bitmap_unit = 8, bitmap_pad = 32, bitmap_bit_order = 1,
  nformats = 3, pixmap_format = 0xa032598, vnumber = 11, release = 6100,
  head = 0x0, tail = 0x0, qlen = 0, request = 5,
  last_req = 0x5 <Address 0x5 out of bounds>, buffer = 0x671070ac "",
  bufptr = 0xa031c70 "b", bufmax = 0xa031c70 "b",
  max_request_size = 167978096, db = 0xffff, synchandler = 0,
  display_name = 0x0, default_screen = 167976000, nscreens = 0, screens =
  motion_buffer = 167978448, flags = 1, min_keycode = 4, max_keycode = 8,
  keysyms = 0xfe, modifiermap = 0x0, keysyms_per_keycode = 0, xdefaults =
  scratch_buffer = 0x0, scratch_length = 0, ext_number = 0, ext_procs = 0x0,
  event_vec = {0, 0x670b1dc8 <_size_of_stack_reserve__+1695227336>,
    0x670b1dc8 <_size_of_stack_reserve__+1695227336>,
    0x670b1de0 <_size_of_stack_reserve__+1695227360> <repeats 33 times>,
    0x670b1dc8 <_size_of_stack_reserve__+1695227336> <repeats 92 times>},

screenshot: running gcc
bash-2.02$ gcc -g -v testit.c -lX11

Reading specs from
gcc version 2.95.2 19991024 (release)

ang-c -v -iprefix
2.95.2/ -D__GNUC__=2 -D__GNUC_MINOR__=95 -Di386 -D_WIN32 -DWINNT -D_X86_=1 -
TDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__
l__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D_WIN32 -D__WINNT__ -D_
=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribu
((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386 -D__WINNT -Asystem
nt) -Acpu(i386) -Amachine(i386) -g -remap -Acpu(i386) -Amachine(i386) -Di386
_i386 -D__i386__ -Di586 -Dpentium -D__i586 -D__i586__ -D__pentium -D__pentiu
-D__CYGWIN32__ -D__CYGWIN__ testit.c c:\tmp/cc41L4EW.i
GNU CPP version 2.95.2 19991024 (release) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:



End of search list.
The following default directories have been omitted from the search path:

End of omitted list.

\tmp/cc41L4EW.i -quiet -dumpbase testit.c -g -version -o c:\tmp/ccJOfNLn.s
GNU C version 2.95.2 19991024 (release) (i586-cygwin32) compiled by GNU C
n 2.95.2 19991024 (release).

./i586-cygwin32/bin/as.exe -o c:\tmp/ccSiQ1Qg.o c:\tmp/ccJOfNLn.s

/../i586-cygwin32/lib/crt0.o -L//e/cygnus/CYGWIN~1/H-I586~1/bin/../lib/gcc-l
586-cygwin32/2.95.2 -L//e/cygnus/CYGWIN~1/H-I586~1/bin/../lib/gcc-lib -L/usr
R6.4/lib -L. -L/usr/local/lib -L//e/cygnus/CYGWIN~1/H-I586~1/bin/../lib/gcc-
i586-cygwin32/2.95.2/../../../../i586-cygwin32/lib -L//e/cygnus/CYGWIN~1/H-I
c:\tmp/ccSiQ1Qg.o -lX11 -lgcc
 -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc

Kris Thielemans
MRC Cyclotron Unit,
Hammersmith Hospital,
DuCane Rd,London W12 0NN, United Kingdom

Phone on :   +44 (020)8383 3731
FAX on :     +44 (020)8383 2029

Want to unsubscribe from this list?
Send a message to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]