dswp.de
http://www.dswp.de/old/

C+GCC+X11+OpenGL=WTF
http://www.dswp.de/old/yaste-ward-f32/c-gcc-x11-opengl-wtf-t5687.html
Page 1 of 1

Author:  natirips [ 08.08.12 ]
Post subject:  C+GCC+X11+OpenGL=WTF

The only difference between wtf1.c and wtf2.c is the line 141.

From wtf1.c:
Code:
 int i;

From wtf2.c:
Code:
 int i,j;

Look what difference it makes:
Code:
$ ./wtf1
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
Unhandled X event type: 28.
.
.
Unhandled X event type: 7.
.
.
<<<I close the window here>>>(this line added by hand)
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":1.0"
      after 40 requests (40 known processed) with 0 events remaining.

$ ./wtf2
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  1 (X_CreateWindow)
  Value in failed request:  0xed5e1c98
  Serial number of failed request:  20
  Current serial number in output stream:  22
 
And then it (wtf2) crashes.

Attachments:
wtf2.c [7.25 KiB]
Downloaded 698 times
wtf1.c [7.25 KiB]
Downloaded 674 times

Author:  Pirat [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

natirips wrote:
[...]
And then it (wtf2) crashes.

For me, both binaries (compiled as suggested)
behave the same:

$ ./wtf1
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 1 (X_CreateWindow)
Value in failed request: 0x4bee760
Serial number of failed request: 17
Current serial number in output stream: 19
$ ./wtf2
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 1 (X_CreateWindow)
Value in failed request: 0xc6453760
Serial number of failed request: 17
Current serial number in output stream: 19
$ gcc --version
gcc (Debian 4.7.1-2) 4.7.1
[...]
$ uname -r
3.2.0-3-amd64
$

(I'm (still) using Nvidia proprietary driver, if that matters ...)

- Does -O0 (minus oh zero) eliminate the difference in behavior?
- Does moving "int i,j" to the beginning of main()
change anything?

Author:  Pirat [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

Interesting coding style, by the way. Is your space bar broken? ;-)

Author:  natirips [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

Pirat wrote:
$ gcc --version
gcc (Debian 4.7.1-2) 4.7.1
gcc (Debian 4.4.5-8) 4.4.5
Pirat wrote:
$ uname -r
3.2.0-3-amd64
2.6.32-5-amd64 (I have 3.2 kernel too, but I messed up the config so it can't see internal HDD (it can mount root without seeing it :rolleyes: and can see external HDD though))
Pirat wrote:
(I'm (still) using Nvidia proprietary driver, if that matters ...)
So do I.
Pirat wrote:
- Does -O0 (minus oh zero) eliminate the difference in behavior?
- Does moving "int i,j" to the beginning of main()
change anything?
No change whatsoever.
Pirat wrote:
Interesting coding style, by the way. Is your space bar broken? ;-)
I like to keep it compact. Unlike ordinary immortal programmers, I cannot read Python programs because I get lost with all the tabs and newlines. Which is why I use C.

Edit/P.S.: I have a few more ideas about debugging (although I was afk for the past few hours and don't have much time for an hour or two now), but I just find it being funny how declaring a useless variable made such a difference in the result.

Author:  AimMe [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

It's C, place where nothing makes something. Sometimes you simply rewrite your program (so it's 100% same) and it magically starts working.

Author:  natirips [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

Just in case anyone was wondering (you never know) I found the culprit on line 40 (shown here as /* */-commented out):
Code:
win = XCreateWindow(dpy, root, 0, 0, 320, 240, 0, vi->depth, InputOutput, vi->visual, CWColormap /*| CWEventMask*/, &amp;swa);//creates the window
It was because I copy-pasted many lines from another program I was making some time ago.

P.S.: I just tried saving my post with CTRL+S before posting it :lol: .

Author:  SvaRoX [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

AimMe wrote:
It's C, place where nothing makes something. Sometimes you simply rewrite your program (so it's 100% same) and it magically starts working.

C is never wrong, only the programmer is ;)

Author:  eXtr33m [ 08.08.12 ]
Post subject:  Re: C+GCC+X11+OpenGL=WTF

SvaRoX wrote:
C is never wrong, only the programmer is ;)


As anything that has to do with computers..

The only bad thing is that it's a chain from chip manufacturers to some poor guy coding his little application who suddenly has to look where in the chain is the mistake :D

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/