[ROOT] TServerSocket bug?

From: Xavier Bertou (bertou@in2p3.fr)
Date: Sat Nov 17 2001 - 17:47:09 MET


Hi all,
this small program:

#include "TROOT.h"
#include "TServerSocket.h"
#include <stdlib.h>
#include <stdio.h>

TROOT TRoot ("Test","My test");

int main()
{
	for (int i=10000;i<20000;i++) {
		TServerSocket *ss=new TServerSocket(i,kTRUE);
		if (ss->IsValid() && ss->GetLocalPort()!=i)
			printf("ROOT took %d instead of %d!!!\n",ss->GetLocalPort(),i);
		delete ss;
	}
	return 0;
}

Gives the following output on a few different computers:
lpnp256 ~  gcc `root-config --cflags` a.cc `root-config --libs`
lpnp256 ~  ./a.out                                                       
ROOT took 5415 instead of 10005!!!
SysError in <TUnixSystem::UnixTcpService>: bind (Permission denied)
ROOT took 1064 instead of 10244!!!
ROOT took 1320 instead of 10245!!!
ROOT took 1576 instead of 10246!!!
ROOT took 1832 instead of 10247!!!
[...]

In particular, once a port has been found, it is very simple to reproduce
the bug:
lpnp256 ~  /Raid/opt/root/bin/root
[...]
root [0] TServerSocket *ss=new TServerSocket(10005)
root [1] ss->GetLocalPort()
(Int_t)5415

Of course, I can bind this port with a simple 'nc -l -p 10005' and it
works perfectly.

This happens with all the root versions installed on our computers (from
2.25 to 3.02.03). The output is not dependant on the root version, but
depends on the machine, and the ports on which the error is seen are
different on our Mandrake 7.0, 7.2 and 8.1 boxes, on Pentium II or III
Pcs. They all are stock mandrake distributions, and root has been
compiled on them with the basic compiler of the distribution and with the
configuration:
./configure linuxegcs --prefix=$DIR --libdir=$DIR/lib --incdir=$DIR/include --mandir=$DIR/man/man1 --etcdir=$DIR/etc --docdir=$DIR/doc --datadir=$DIR/share --enable-rpath

Any idea? Anyone able to reproduce that on other architectures?
-- 
Xavier



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:08 MET