[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECthreads Conference |
|
Moderator: | PTHRED::MARYS TE ON |
|
Created: | Mon May 14 1990 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 1553 |
Total number of notes: | 9541 |
1525.0. "exception system errors" by HYDRA::BRYANT () Mon Apr 14 1997 19:27
I don't know what this error is all about. Software.com ran into it while
trying to reproduce a problem they think they have with poll(). The problem
with poll() is they don't believe it is returning in a timely manner and they
are currently trying to prove that.
This exception problem I got to reproduce on a 4100 dual processor machine. The
first code segment is srvr.c; the second is clnt.c. Compile them
both and do "srvr 50505" in one window (use a different port number if
that one's taken), and run "clnt 50505 50 1" in another window. On
occasion you'll get the following error:
exception system: exiting dues to multiple internal errors:
exception dispatch or unwind stuck in infinite loop
exception dispatch or unwind stuck in infinite loop
Also try "clnt 50505 200 1". On occasion, the client will hang instead
of exiting.
Can anyone shed any light on this one?
Thanks.
Pat Bryant
Software Partner Engineering
-----------------------------------
//clnt.c
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>
void *clnt(void *);
void die(const char *s) { perror(s); exit(1); }
void die2(const char *s, int x) { fprintf(stderr, "%s: %s\n", s, strerror(x));
exit(1); }
pthread_cond_t scond;
pthread_mutex_t smutex;
int scount;
int rcount;
main(int ac, char **av)
{
int x, lim = atoi(av[2]);
struct sockaddr_in sin;
pthread_cond_init(&scond, NULL);
pthread_mutex_init(&smutex, NULL);
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(atoi(av[1]));
sin.sin_addr.s_addr = htonl(0x7f000001);
scount = lim;
rcount = atoi(av[3]);
for (x = 0; x != lim; x++) {
pthread_t th;
pthread_attr_t pat;
int e;
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
die("socket");
if (connect(fd, (struct sockaddr *) &sin, sizeof sin) < 0)
die("connect");
pthread_attr_init(&pat);
pthread_attr_setdetachstate(&pat, PTHREAD_CREATE_DETACHED);
e = pthread_create(&th, &pat, clnt, (void *) fd);
pthread_attr_destroy(&pat);
if (e != 0)
die2("pthread_create", e);
}
pthread_mutex_lock(&smutex);
while (scount)
pthread_cond_wait(&scond, &smutex);
pthread_mutex_unlock(&smutex);
}
void *clnt(void *fdp)
{
int fd = (int) fdp;
int x;
char buf[100];
const char *s = "this is a sample string";
for (x = 0; x != rcount; x++) {
int n;
write(fd, s, strlen(s));
n = read(fd, buf, sizeof buf);
if (n != strlen(s))
die("bad reply");
if (memcmp(buf, s, n) != 0)
die("bad data");
}
printf("done with %lx\n", pthread_self());
pthread_mutex_lock(&smutex);
scount--;
pthread_cond_signal(&scond);
pthread_mutex_unlock(&smutex);
close(fd);
pthread_exit(NULL);
return NULL;
}
-----------------------------------------
//srvr.c
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>
#include <poll.h>
#include <fcntl.h>
void *srvr(void *);
void die(const char *s) { perror(s); exit(1); }
void die2(const char *s, int x) { fprintf(stderr, "%s: %s\n", s, strerror(x));
exit(1); }
main(int ac, char **av)
{
struct sockaddr_in sin;
int s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
die("socket");
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(atoi(av[1]));
if (bind(s, (struct sockaddr *) &sin, sizeof sin) < 0)
die("bind");
if (listen(s, 128) < 0)
die("listen");
while (1)
{
pthread_t th;
pthread_attr_t pat;
int len = sizeof sin;
int fd = accept(s, (struct sockaddr *) &sin, &len);
int e;
if (fd < 0)
die("accept");
pthread_attr_init(&pat);
pthread_attr_setdetachstate(&pat, PTHREAD_CREATE_DETACHED);
e = pthread_create(&th, &pat, srvr, (void *) fd);
pthread_attr_destroy(&pat);
if (e != 0)
die2("pthread_create", e);
}
}
void *srvr(void *fdp)
{
int fd = (int) fdp;
char buf[100];
struct pollfd pfd;
fcntl(fd, F_SETFL, O_NONBLOCK);
while (1) {
int n, m;
time_t t1 = time(NULL);
time_t t2;
pfd.fd = fd;
pfd.events = POLLIN;
m = poll(&pfd, 1, 30000);
t2 = time(NULL);
if (m <= 0)
die("poll");
if (t2 - t1 >= 10)
printf("long wait: %d\n", t2-t1);
if (t2 - t1 >= 29)
die("bad timeout");
n = read(fd, buf, sizeof buf);
if (n <= 0)
break;
if (write(fd, buf, n) < 0)
die("write");
}
close(fd);
pthread_exit(NULL);
return NULL;
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1525.1 | What version of which OS with what patches are you running? | WTFN::SCALES | Despair is appropriate and inevitable. | Tue Apr 15 1997 12:50 | 9 |
| .0> Can anyone shed any light on this one?
Presumably you're running on Digital Unix... Exactly what version are you
running, and what DECthreads patches have you applied? (This one sounds like
a bug in the system exception handling stuff which Peter was able to fix
recently...)
Webb
|
1525.2 | | DCETHD::BUTENHOF | Dave Butenhof, DECthreads | Wed Apr 16 1997 07:24 | 17 |
| This is a common symptom of shutdown problems in libexc/libc. It was commonly
caused by having threads that tried to raise an exception while the process
is trying to shut down. Note that, in the sample code, main() simply exits,
while the threads terminated by calling pthread_exit(), which raises an
exception.
The problem is that the libc exit handling tears down the data structures
that are required to raise exceptions. If another thread tries to raise an
exception at this point, it gets an internal error... often the one you've
shown.
I'm not sure whether the problem has been completely resolved yet. One
solution would be for libc to not bother tearing down the data (the address
space is going away, after all). That's not necessarily the only (or best)
solution.
/dave
|
1525.3 | Problem fixed ? | BHAJEE::AIGNER | | Mon May 12 1997 10:10 | 16 |
| If there is a patch, how and where can I get it ?
We are running into the same error at process rundown
of multithreaded applications, exactly as descibed in
.1.
We are using Digital UNIX (V4.0 464 alpha) with
Digital DCE V2.0a (Rev. 515) and DEC C++ Version 5.5.
As far as I know, we don't have any DCE (DECthreads)
patches.
Since we use DCE IDL, we compile and link with -threads,
i.e. we use DECthreads POSIX 1003.4a/D4.
Thanks in advance
Helmut
|
1525.4 | It's a "distributed" problem; but, you can work around it yourself... | WTFN::SCALES | Despair is appropriate and inevitable. | Mon May 12 1997 14:59 | 13 |
| .3> If there is a patch, how and where can I get it ?
As far as I'm aware, there is no patch available to address this problem. This
is a problem which occurs "between" components, so it is more difficult than
usual to get it addressed...
Nevertheless, you should be able to work around it in your application by
ensuring that all your process's threads have terminated before you exit the
process. (E.g., are you closing down DCE cleanly, i.e., closing all of your
connections, etc.?)
Webb
|