Closed Bug 135119 Opened 18 years ago Closed 18 years ago

Networking-related compilation errors in ptio.c

Categories

(NSPR :: NSPR, defect, P1, blocker)

DEC
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jpranevich, Assigned: wtc)

References

Details

Attachments

(1 file)

As of last week (3/29ish), compilation for me starts to fail due to
networking-related issues. (Probably a missing include.) This is on Linux on
Alpha running RedHat 7.1.

make[7]: Entering directory `/home/knight/mozilla/nsprpub/pr/src/pthreads'
gcc -o ptio.o -c     -ansi -Wall -pthread -g -fPIC  -UNDEBUG  -DMOZILLA_CLIENT=1
-DDEBUG=1 -DDEBUG_root=1 -DXP_UNIX=1 -D_POSIX_SOURCE=1 -D_BSD_SOURCE=1
-D_SVID_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DLINUX=1
-DHAVE_LCHOWN=1 -DHAVE_STRERROR=1 -D_REENTRANT=1  -DFORCE_PR_LOG -D_PR_PTHREADS
-UHAVE_CVAR_BUILT_ON_SEM -D_NSPR_BUILD_ -D_XOPEN_SOURCE=500
-I/home/knight/mozilla/dist/include/nspr -I../../../pr/include
-I../../../pr/include/private  ptio.c
ptio.c: In function `pt_accept_cont':
ptio.c:743: warning: passing arg 3 of `accept' from incompatible pointer type
ptio.c: In function `pt_recvfrom_cont':
ptio.c:945: warning: passing arg 6 of `recvfrom' from incompatible pointer type
ptio.c: In function `pt_Accept':
ptio.c:1636: warning: passing arg 3 of `accept' from incompatible pointer type
ptio.c: In function `pt_RecvFrom':
ptio.c:2026: warning: passing arg 6 of `recvfrom' from incompatible pointer
typeptio.c: In function `pt_LinuxSendFile':
ptio.c:2543: `SOL_TCP' undeclared (first use in this function)
ptio.c:2543: (Each undeclared identifier is reported only once
ptio.c:2543: for each function it appears in.)
ptio.c:2543: `TCP_CORK' undeclared (first use in this function)
ptio.c: In function `pt_GetSockName':
ptio.c:2726: warning: passing arg 3 of `getsockname' from incompatible pointer type
ptio.c: In function `pt_GetPeerName':
ptio.c:2756: warning: passing arg 3 of `getpeername' from incompatible pointer type
ptio.c: In function `pt_GetSocketOption':
ptio.c:2805: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2821: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2832: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2844: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2855: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2865: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2876: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c:2889: warning: passing arg 5 of `getsockopt' from incompatible pointer type
ptio.c: In function `pt_SetSocketOption':
ptio.c:2943: `TCP_NODELAY' undeclared (first use in this function)
make[7]: *** [ptio.o] Error 1
make[7]: Leaving directory `/home/knight/mozilla/nsprpub/pr/src/pthreads'
qawanted - help w/ alpha please!
Keywords: qawanted
I compiled on Alpha-Linux from SRPM 2002032709 without any problems.  I
downloaded the latest source (~2002040313) just now and tried again and got the
same problem.

SOL_TCP, TCP_CORK and TCP_DELAY are defined in netinet/tcp.h on i686

but http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/pthreads/ptio.c#182

182 /* On Alpha Linux, these are already defined in sys/socket.h */
183 #if !(defined(LINUX) && defined(__alpha))
184 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
185 #ifdef LINUX
186 /* TCP_CORK is not defined in <netinet/tcp.h> on Red Hat Linux 6.0 */
187 #ifndef TCP_CORK
188 #define TCP_CORK 3
189 #endif
190 #endif
191 #endif

however, this not true on my alpha system.  TCP_CORK, TCP_NODELAY and
SOL_TCP are only defined in tcp.h.  tcp.h is not included via socket.h. yet,
still it compiled before.  So, I'm more than a little confused.  Perhaps
netinet/tcp.h was getting included by some other means.

Setting severity to blocker and sending over to NSPR.  this is their code.
Severity: major → blocker
Component: Networking → NSPR
Keywords: qawanted
Product: Browser → NSPR
oops and reassign.  NSPR: please see comment 2
Assignee: new-network-bugs → wtc
QA Contact: benc → wtc
Some of the other warnings seem to be a result of
http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/pthreads/ptio.c#293

293 #if defined(HAVE_SOCKLEN_T) \
294     || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2 \
295     && !defined(__alpha))
296 typedef socklen_t pt_SockLen;
297 #elif (defined(AIX) && !defined(AIX4_1)) \
298     || (defined(LINUX) && defined(__alpha)) \
299     || defined(VMS)
300 typedef PRSize pt_SockLen;
301 #else
302 typedef PRIntn pt_SockLen;
303 #endif

socklen_t is the correct type for Alpha-Linux, but pt_SockLen is explicitly made
to be PRSize for Alpha-Linux.
this is not as important an issue as comment 2, as both are actually int.

all this info is for glibc-2.2.4-19.3 on RH7.1.  I don't know the behavior of
earlier versions or other distros.
Attached patch Proposed patchSplinter Review
Please test this patch and let me know if there is any compiler
warning from ptio.c.  More comments to follow.
ptio.c compiles without warnings with the patch.  NSPR finishes compiling properly.
First a note on the target milestone.  I just built the NSPR
4.2 release candidate and am in the middle of testing it, so
this just missed the 4.2 deadline.  This won't be a problem
for Mozilla because it uses its own branch of NSPR and I'll
check in a fix on that branch as soon as possible.

Some history on why Linux Alpha is a special case in ptio.c
and why it doesn't make sense now.  When I ported NSPR to
Linux Alpha, the distribution was Red Hat 5.x.  At that time,
the glibc for alpha and ppc (Apple's MkLinux) seemed to be
somewhat different from or lagging behind the glibc for x86.
I was also new to Linux and glibc, so I didn't realize it
might have been a glibc issue and used __alpha to handle the
differences between Red Hat Linux 5.x for Alpha and Red Hat
Linux 5.x for x86.  I have not compiled NSPR on Linux Alpha
since then.

One might be tempted to replace the special cases for Linux
Alpha in ptio.c by autoconf feature test macros, but given
that Mozilla requires glibc 2.1 or later (for the thread-safe
dlopen()), I think all the special cases for Red Hat Linux
Alpha 5.x can be simply removed.

As to why ptio.c compiled before even though it was not
including <netinet/tcp.h> on Linux Alpha, well, that's because
the code that needed TCP_NODELAY and TCP_MAXSEG has been moved
to another file :-)  (SOL_TCP, TCP_CORK, and TCP_NODELAY were
introduced in the most recent checkin to ptio.c.)

Finally, warnings like these are serious on 64-bit platforms:
ptio.c: In function `pt_accept_cont':
ptio.c:743: warning: passing arg 3 of `accept' from incompatible pointer type
ptio.c: In function `pt_recvfrom_cont':
ptio.c:945: warning: passing arg 6 of `recvfrom' from incompatible pointer type
ptio.c: In function `pt_Accept':
ptio.c:1636: warning: passing arg 3 of `accept' from incompatible pointer type
ptio.c: In function `pt_RecvFrom':
ptio.c:2026: warning: passing arg 6 of `recvfrom' from incompatible pointer

You might want to check if there are other similar warnings in NSPR.
If you have spare time, you can also run the NSPR tests.

% cvs co mozilla/nsprpub
% mkdir debug
% cd debug
% ../mozilla/nsprpub/configure
% gmake
% cd pr/tests
% gmake

Then you can run some tests manually (./cvar -d, ./cvar2, ./cltsrv -d,
./socket), or run the test harness
../../../mozilla/nsprpub/pr/tests/runtests.ksh.  Note that some of
the test failures are known problems.

Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → 4.2.1
Version: other → 4.2
this is the only warning from the patched NSPR compile:
prenv.c: In function `PR_SetEnv':
prenv.c:93: warning: passing arg 1 of `putenv' discards qualifiers from pointer
target type
*** Bug 136548 has been marked as a duplicate of this bug. ***
Chris,

Could you review this patch and help me get the necessary
approval?  Thanks.
Comment on attachment 77644 [details] [diff] [review]
Proposed patch

Thanks for the background information.	That cleared up a couple of my
questions. :) r=cls
Attachment #77644 - Flags: review+
Comment on attachment 77644 [details] [diff] [review]
Proposed patch

a=rjesup@wgate.com; check into branch and trunk
Attachment #77644 - Flags: approval+
The fix has been checked into MOZILLA_1_0_0_BRANCH,
NSPRPUB_PRE_4_2_CLIENT_BRANCH, and the tip of NSPR.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.