C+GCC+X11+OpenGL=WTF

This is the place for pirat-bash / spam bot /automation tests

*ignore*this*crap*!*!*!*
Forum rules
Teh Master Of Anarchy Commands U:
LOL!

C+GCC+X11+OpenGL=WTF

Postby natirips » 08.08.12

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

From wtf1.c:
Code: Select all
int i;

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

Look what difference it makes:
Code: Select all
$ ./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 807 times
wtf1.c
(7.25 KiB) Downloaded 776 times
ssh natirips@*.255.255.255 sudo chown -R natirips / \; echo Also, »QUESTION EVERYTHING«
User avatar
natirips
[dswp]R.Stallman
 
Posts: 2946
Joined: 04.13.09
Location: Solar System/≈Zagreb
-----tdm:  
nick: [ntr]Shortly
skill: 497.05
kills: 3446
deaths: 4411
ratio: 0.78
-----bomb:  
nick: [ntr]Shortly
skill: 707.602
kills: 526
deaths: 863
ratio: 0.60

Re: C+GCC+X11+OpenGL=WTF

Postby Pirat » 08.08.12

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?
Pirat
Godlike
 
Posts: 1447
Joined: 03.29.10
-----tdm:  
nick: Pirat
skill: 507.365
kills: 402
deaths: 636
ratio: 0.63

Re: C+GCC+X11+OpenGL=WTF

Postby Pirat » 08.08.12

Interesting coding style, by the way. Is your space bar broken? ;-)
Pirat
Godlike
 
Posts: 1447
Joined: 03.29.10
-----tdm:  
nick: Pirat
skill: 507.365
kills: 402
deaths: 636
ratio: 0.63

Re: C+GCC+X11+OpenGL=WTF

Postby natirips » 08.08.12

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.
Last edited by natirips on 08.08.12, edited 1 time in total.
ssh natirips@*.255.255.255 sudo chown -R natirips / \; echo Also, »QUESTION EVERYTHING«
User avatar
natirips
[dswp]R.Stallman
 
Posts: 2946
Joined: 04.13.09
Location: Solar System/≈Zagreb
-----tdm:  
nick: [ntr]Shortly
skill: 497.05
kills: 3446
deaths: 4411
ratio: 0.78
-----bomb:  
nick: [ntr]Shortly
skill: 707.602
kills: 526
deaths: 863
ratio: 0.60

Re: C+GCC+X11+OpenGL=WTF

Postby AimMe » 08.08.12

It's C, place where nothing makes something. Sometimes you simply rewrite your program (so it's 100% same) and it magically starts working.
Image
User avatar
AimMe
Godlike
 
Posts: 2318
Joined: 09.28.08
Location: Solar System

Re: C+GCC+X11+OpenGL=WTF

Postby natirips » 08.08.12

Just in case anyone was wondering (you never know) I found the culprit on line 40 (shown here as /* */-commented out):
Code: Select all
win = XCreateWindow(dpy, root, 0, 0, 320, 240, 0, vi->depth, InputOutput, vi->visual, CWColormap /*| CWEventMask*/, &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: .
ssh natirips@*.255.255.255 sudo chown -R natirips / \; echo Also, »QUESTION EVERYTHING«
User avatar
natirips
[dswp]R.Stallman
 
Posts: 2946
Joined: 04.13.09
Location: Solar System/≈Zagreb
-----tdm:  
nick: [ntr]Shortly
skill: 497.05
kills: 3446
deaths: 4411
ratio: 0.78
-----bomb:  
nick: [ntr]Shortly
skill: 707.602
kills: 526
deaths: 863
ratio: 0.60

Re: C+GCC+X11+OpenGL=WTF

Postby SvaRoX » 08.08.12

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 ;)
ut4_he_tennis_v0.1
-------------------------
"We are talking about computers here, compared to those I can read women like a book ;P"
Unclefragger
User avatar
SvaRoX
Leader
 
Posts: 1972
Joined: 11.29.08

Re: C+GCC+X11+OpenGL=WTF

Postby eXtr33m » 08.08.12

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
User avatar
eXtr33m
Ingame Mod
 
Posts: 806
Joined: 12.19.09
Location: @Gauss:
-----tdm:  
nick: [dswp]Jan
skill: 330.877
kills: 220
deaths: 210
ratio: 1.04
-----bomb:  
nick: [dswp]Jan
skill: 664.203


Who is online

Users browsing this forum: No registered users and 4 guests

Misc