Bug 600070 - VNC server crashes when connected by any VNC client other than TigerVNC 1.0.1
Summary: VNC server crashes when connected by any VNC client other than TigerVNC 1.0.1
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: vnc
Version: 13
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Adam Tkac
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-03 22:04 UTC by Mehmet ALLAR
Modified: 2013-04-30 23:46 UTC (History)
5 users (show)

Fixed In Version: tigervnc-1.0.90-0.12.20100420svn4030.fc13
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-06-29 15:34:18 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
vnc log (4.02 KB, text/plain)
2010-06-03 22:05 UTC, Mehmet ALLAR
no flags Details
vncserver log with backtrace (3.42 KB, text/plain)
2010-06-07 07:06 UTC, Stefan Becker
no flags Details
vncserver log (4.43 KB, application/octet-stream)
2010-06-08 08:08 UTC, Mehmet ALLAR
no flags Details
xsession log (1.41 KB, application/octet-stream)
2010-06-08 08:10 UTC, Mehmet ALLAR
no flags Details
VNClog (4.00 KB, text/plain)
2010-06-09 08:18 UTC, Mehmet ALLAR
no flags Details
Patch (1.47 KB, patch)
2010-06-09 11:37 UTC, Adam Tkac
no flags Details | Diff

Description Mehmet ALLAR 2010-06-03 22:04:16 UTC
Description of problem: VNC server crashes when connected by any VNC clienct otther than TigerVNC 1.0.1 (win)


Version-Release number of selected component (if applicable): TigerVNC 1.0.90


How reproducible: always


Steps to Reproduce:
1. run VNC server on x64 F13 box
2. connect it with UVNC client
3. enter password
  
Actual results: Crashing the entire VNC server session. 


Expected results: Connect and work without problems (was working @F12 , installed F13 and having this problem) , or at least give and error for an incompatible client. 


Additional info: filing log ...

Comment 1 Mehmet ALLAR 2010-06-03 22:05:25 UTC
Created attachment 421053 [details]
vnc log

Comment 2 Mehmet ALLAR 2010-06-03 22:07:22 UTC
Using UltraVNC to connect.

Comment 3 Stefan Becker 2010-06-07 07:06:38 UTC
Created attachment 421728 [details]
vncserver log with backtrace

I can confirm the crash with krdc (KDE VNC viewer) too. If I use the tigervnc client everything works fine.

Comment 4 Stefan Becker 2010-06-07 07:37:40 UTC
This seems to be a 64-bit issue in the server code:

  32-bit krdc connected to 32-bit tigervnc server: OK
  64-bit krdc connected to 32-bit tigervnc server: OK
  32-bit krdc connected to 64-bit tigervnc server: CRASH
  64-bit krdc connected to 64-bit tigervnc server: CRASH

Mehmet: can you confirm that?

Comment 5 Mehmet ALLAR 2010-06-07 10:57:59 UTC
yes, I can confirm . I can connect to 32bit server without problems.

Comment 6 Stefan Becker 2010-06-07 12:57:57 UTC
I installed tigervnc-debuginfo and ran Xvnc inside gdb to get a backtrace:

(gdb) bt
#0  0x0000000000515578 in rfb::Encoder::supported (encoding=-131069)
    at Encoder.cxx:35
#1  0x000000000053d579 in rfb::ConnParams::setEncodings (this=0xa4f388, 
    nEncodings=<value optimized out>, encodings=<value optimized out>)
    at ConnParams.cxx:132
#2  0x000000000051d995 in rfb::SMsgHandler::setEncodings (this=0xa4f380, 
    nEncodings=<value optimized out>, encodings=<value optimized out>)
    at SMsgHandler.cxx:44
#3  0x000000000053dea8 in rfb::SMsgReader::readSetEncodings (this=0xa49230)
    at SMsgReader.cxx:57
#4  0x00000000005276d8 in rfb::VNCSConnectionST::processMessages (
    this=0xa4f380) at VNCSConnectionST.cxx:117
#5  0x000000000050485c in XserverDesktop::wakeupHandler (this=0x875a90, 
    fds=0x85a720, nfds=<value optimized out>) at XserverDesktop.cc:572
#6  0x00000000004fd464 in vncWakeupHandler (data=<value optimized out>, 
    nfds=1, readmask=0x85a720) at vncExtInit.cc:313
#7  0x00000000005661c3 in WakeupHandler (result=1, pReadmask=0x85a720)
    at dixutils.c:403
#8  0x00000000005aa68f in WaitForSomething (pClientsReady=0xa48d70)
    at WaitFor.c:232
#9  0x0000000000560c22 in Dispatch () at dispatch.c:375
#10 0x00000000004fc8cb in main (argc=6, argv=0x7fffffffdad8, 
    envp=<value optimized out>) at main.c:286

(gdb) l
30      {
31      }
32
33      EncoderCreateFnType Encoder::createFns[encodingMax+1] = { 0 };
34
35      bool Encoder::supported(int encoding)
36      {
37        return encoding <= encodingMax && createFns[encoding];
38      }


encoding is -131069 => 0xFFFFFFFFFFFE0003, so I assume the original value was "3" but got incorrectly converted somehow.

2 levels up I see:

42      void SMsgHandler::setEncodings(int nEncodings, rdr::S32* encodings)
43      {
44        cp.setEncodings(nEncodings, encodings);
45        supportsLocalCursor();
46      }

So I assume "rdr::S32" conversion to "int" breaks on 64-bit?

One more level up:

(gdb) up
#3  0x000000000053dea8 in rfb::SMsgReader::readSetEncodings (this=0xa49230)
    at SMsgReader.cxx:57
57        handler->setEncodings(nEncodings, encodings.buf);
(gdb) l
52        is->skip(1);
53        int nEncodings = is->readU16();
54        rdr::S32Array encodings(nEncodings);
55        for (int i = 0; i < nEncodings; i++)
56          encodings.buf[i] = is->readU32();
57        handler->setEncodings(nEncodings, encodings.buf);
58      }
(gdb) print nEncodings
$6 = 18

Hmm, I guess "rdr:S32" means "signed 32-bit". Reading unsigned 32-bit values into such a variable is a little bit dangerous...

I wonder if the problem goes away if "bool Encoder::supported(int encoding)" would be changed to rdr::S32?

Comment 7 Adam Tkac 2010-06-07 13:13:12 UTC
(In reply to comment #6)
> Hmm, I guess "rdr:S32" means "signed 32-bit". Reading unsigned 32-bit values
> into such a variable is a little bit dangerous...
> 
> I wonder if the problem goes away if "bool Encoder::supported(int encoding)"
> would be changed to rdr::S32?    

Your theory looks valid but this code is pretty old and worked fine for a long time. I wonder why it got broken, conversion between "int" and "unsigned int" should be no problem, both values are 4 bytes long. I'm going to test your proposed solution.

Comment 8 Adam Tkac 2010-06-07 15:37:14 UTC
After inspection problem is not the unsigned->signed cast.

Would it be possible to test proposed update, please? Download appropriate packages from http://koji.fedoraproject.org/koji/taskinfo?taskID=2236284. Thank you in advance.

Comment 9 Stefan Becker 2010-06-07 17:22:41 UTC
The new package works like a charm for me.

So what was the actual correction? Maybe you can attach the patch?

Comment 10 Mehmet ALLAR 2010-06-08 08:08:50 UTC
Created attachment 422093 [details]
vncserver log

Comment 11 Mehmet ALLAR 2010-06-08 08:10:05 UTC
Created attachment 422094 [details]
xsession log

Comment 12 Mehmet ALLAR 2010-06-08 08:11:04 UTC
I can't confim the correction after installing those packages . (I might've done something wrong, I can provide any info you might need )  .

As second , if any way i stop VNCserver service once , or server chrashes , server is not able start normally again. After restarting the service , I get the logs in the attchment and the result in viewer here : 

http://img41.imageshack.us/img41/3220/desktoperror.jpg

Comment 13 Stefan Becker 2010-06-08 10:23:40 UTC
Mehmet: are you sure you installed the correct *server* package on the machine where you run vncserver on? E.g. do you see in the shell:

$ rpm -q tigervnc-server
tigervnc-server-1.0.90-0.11.20100420svn4030.fc13.1.x86_64

$ sha1sum /usr/bin/Xvnc 
9cb300241e99837722741ac2aad14c4ae2d78cc1  /usr/bin/Xvnc

I have now tested the package on both of my 64-bit machines and it works now.

Comment 14 Stefan Becker 2010-06-08 10:26:53 UTC
BTW: the crashed server can leave locks behind, e.g. if VNC was running on server:5901 then please check on the server that /tmp/.X1-lock and /tmp/.X11-unix/X1 are removed before trying again. If vncserver detects those locks it will assign the next free port, e.g. server:5902.

Comment 15 Mehmet ALLAR 2010-06-08 14:00:34 UTC
(In reply to comment #14)
> BTW: the crashed server can leave locks behind, e.g. if VNC was running on
> server:5901 then please check on the server that /tmp/.X1-lock and
> /tmp/.X11-unix/X1 are removed before trying again. If vncserver detects those
> locks it will assign the next free port, e.g. server:5902.    

It is not a lock issue . It still starts on 5901 , but dbus keeps giving errors. And it happens even if I stop vncserver service gracefully . 
The other issue is : 

[root@local hdd]# rpm -iv tigervnc-*
Preparing packages for installation...
tigervnc-server-module-1.0.90-0.11.20100420svn4030.fc13.1
tigervnc-1.0.90-0.11.20100420svn4030.fc13.1
[root@local hdd]# sha1sum /usr/bin/Xvnc
207ef36c3d32d5a717e775967a7126446fcea60e  /usr/bin/Xvnc

Stopped services , rebooted ,  removed the packages and reinstalled. But sha1sum does not match. are you sure it is right?

Comment 16 Stefan Becker 2010-06-09 05:14:20 UTC
The sha1sum changes if prelink is activated on the machine, so it is useless for comparison.

Comment 17 Mehmet ALLAR 2010-06-09 08:18:13 UTC
Created attachment 422470 [details]
VNClog

[root@local ~]# rpm -qva | grep tigervnc
tigervnc-server-1.0.90-0.11.20100420svn4030.fc13.x86_64
tigervnc-server-module-1.0.90-0.11.20100420svn4030.fc13.1.x86_64
tigervnc-1.0.90-0.11.20100420svn4030.fc13.1.x86_64


If sha1sum match is not neccessary , then I still can't confim it works. 

Ps: I have got some warnings about protocol version mismatch in my log. Please check the last one I posted.

Comment 18 Adam Tkac 2010-06-09 11:32:01 UTC
(In reply to comment #17)
> Created an attachment (id=422470) [details]
> VNClog
> 
> [root@local ~]# rpm -qva | grep tigervnc
> tigervnc-server-1.0.90-0.11.20100420svn4030.fc13.x86_64

                                             ^^^^^^^ should be .fc13.1.x86_64

> tigervnc-server-module-1.0.90-0.11.20100420svn4030.fc13.1.x86_64
> tigervnc-1.0.90-0.11.20100420svn4030.fc13.1.x86_64

You have updated only "tigervnc" and "tigervnc-server-module" packages but you have to update the "tigervnc-server" package. Fix is in the Xvnc binary which is part of the tigervnc-server.

Comment 19 Adam Tkac 2010-06-09 11:35:58 UTC
(In reply to comment #9)
> The new package works like a charm for me.
> 
> So what was the actual correction? Maybe you can attach the patch?    

The actual correction was expansion of the encoding range checks. Per RFB protocol only signed 32bit values from interval <0;255> are used as encodings but some VNC implementations use negative values for their private purposes, like UltraVNC. I will attach the patch.

Comment 20 Adam Tkac 2010-06-09 11:37:01 UTC
Created attachment 422509 [details]
Patch

This patch extends encoding range checks.

Comment 21 Adam Tkac 2010-06-09 11:40:08 UTC
(In reply to comment #12)
> As second , if any way i stop VNCserver service once , or server chrashes ,
> server is not able start normally again. After restarting the service , I get
> the logs in the attchment and the result in viewer here : 
> 
> http://img41.imageshack.us/img41/3220/desktoperror.jpg    

If you are able to continuously reproduce this issue please open a separate bug for it. This bug is about Xvnc crashes when different clients than vncviewer/vinagre are used.

Comment 22 Radek Hladik 2010-06-15 16:49:16 UTC
It seems that this bug has one really irritating impact. The server is also used for vnc option in anacanoda. And if you do not know about this problem you just wonder why instalation crashes everytime you try to connect. For now it seems that using tigervnc solved the problem however is there any easy workaround how to add the corrected VNC server to stage2 file?
I did install 32bit version without any problems few days ago so this really seems to be only problem of 64bit version.

Comment 23 Daniel Berrangé 2010-06-23 11:49:17 UTC
> The actual correction was expansion of the encoding range checks. Per RFB
> protocol only signed 32bit values from interval <0;255> are used as encodings
> but some VNC implementations use negative values for their private purposes,
> like UltraVNC. I will attach the patch.    

I don't think is a entirely correct reading of the RFB protocol. The latest PDF of the spec doesn't appear to mention the 0;255 interval at all. I think that simply by convention they are allocating positive numbers to real framebuffer encodings, and negative numbers to pseudo encodings. There are many psuedo encodings listed in the RFB spec with negative numbers already.

Comment 24 Fedora Update System 2010-06-24 10:16:48 UTC
tigervnc-1.0.90-0.12.20100420svn4030.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/tigervnc-1.0.90-0.12.20100420svn4030.fc13

Comment 25 Fedora Update System 2010-06-24 16:24:40 UTC
tigervnc-1.0.90-0.12.20100420svn4030.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update tigervnc'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/tigervnc-1.0.90-0.12.20100420svn4030.fc13

Comment 26 Fedora Update System 2010-06-29 15:34:08 UTC
tigervnc-1.0.90-0.12.20100420svn4030.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.