On Fri, Jan 28, 2000 at 01:19:01PM -0500, Roland McGrath wrote:
> > Now for the next problem. I think this also is a bug in the hurdish part of
> > glibc. Attached is a stripped-down part of the debian linux portmapper.
> > This works on linux, but on the hurd this crashes in svc_run:
>
> Thanks for the report. That is indeed a libc bug.
> I've fixed the bug and will check that in shortly.
Ok, now glibc-2.1.3 is out, and I've got some time to play with this again.
I've installed the debian libc0.2{,-dev,-dbg}_2.1.3-6.deb packages.
(I can use the CVS sources, but I do not have time nor machine power to
compile glibc myself.)
Anyway, it does no longer crash when entering svc_run(), but when I
establish a (tcp) connection.
Attached is the same test program, but this time it includes tcp support.
If yo run it, and then do 'rpcinfo -p', or 'telnet localhost 111' if
you don't have rpcinfo. The program will crash like this:
Program received signal SIGSEGV, Segmentation fault.
0x1126bd3 in svc_getreqset () at svc.c:222
222 svc.c: No such file or directory.
(gdb) bt
#0 0x1126bd3 in svc_getreqset () at svc.c:222
#1 0x1127329 in svc_run () at svc_run.c:89
#2 0x80489cf in main () at rpct.c:56
(gdb)
I belive udp will behave similar, but since rpcinfo uses tcp, I have only
tested this.
Marcus, tell me when you are ready to decide how to package the various rpc
and yp-daemons and utilities.
Steinar
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define PORTMAP
#include <rpc/rpc.h>
void dispatch() {
fprintf(stderr, "dispatch\n");
}
int
main() {
SVCXPRT *xprt;
int sock;
struct sockaddr_in addr;
/* udp */
int len = sizeof(struct sockaddr_in);
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
fprintf(stderr, "cannot create udp socket: %s\n",
strerror(errno));
exit(1);
}
memset((char *) &addr, 0, sizeof(addr));
addr.sin_addr.s_addr = 0;
addr.sin_family = AF_INET;
addr.sin_port = htons((short)111);
if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
fprintf(stderr, "cannot bind udp: %s\n",
strerror(errno));
exit(1);
}
if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) {
fprintf(stderr, "couldn't do ucp_create\n");
exit(1);
}
/* tcp */
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
fprintf(stderr, "cannot create tcp socket: %s\n",
strerror(errno));
exit(1);
}
if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
fprintf(stderr, "cannot bind tcp: %s\n",
strerror(errno));
exit(1);
}
if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE))
== (SVCXPRT *)NULL) {
fprintf(stderr, "couldn't do tcp_create\n");
exit(1);
}
svc_register(xprt, 98934, 1, dispatch, 0);
svc_run();
fprintf(stderr, "svc_run exited!\n");
exit(1);
}