* [Linux-ia64] Two IA-64 Linux bugs
@ 2000-06-05 5:44 Wan-Teh Chang
2000-06-05 20:42 ` Dan Pop
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Wan-Teh Chang @ 2000-06-05 5:44 UTC (permalink / raw)
To: linux-ia64
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
System info:
[nspr@tl2 unix]$ uname -a
Linux tl2.compile.sourceforge.net 2.3.99-pre6-000501-18smp
#1 SMP Sat May 6 21:30:48 PDT 2000 ia64 unknown
Bug #1: pthread_cond_wait sometimes returns EINVAL (22).
Run the first attachment (pingpong.c) repeatedly.
Note that this test doesn't call pthread_cond_destroy
so it is impossible that we are waiting on a destroyed
condition variable. This failure is intermittent so you
may need to try many times to reproduce it.
Bug #2: sysconf(_SC_NPROCESSORS_ONLN) returns 0.
It should return the number of processors online.
Run the second attachment (ncpus.c) to reproduce it.
Wan-Teh
[-- Attachment #2: pingpong.c.txt --]
[-- Type: text/plain, Size: 3052 bytes --]
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define LOOP 20000
int toggle = 0; /* either 0 or 1 */
pthread_mutex_t mutex; /* protects 'toggle' */
pthread_cond_t cond; /* for the threads to wait on */
void *ping(void *arg)
{
int i;
int rv;
rv = pthread_mutex_lock(&mutex);
if (rv) {
fprintf(stderr, "pthread_mutex_lock failed: %d\n", rv);
exit(1);
}
for (i = 0; i < LOOP; i++) {
while (toggle == 0) {
rv = pthread_cond_wait(&cond, &mutex);
if (rv) {
fprintf(stderr, "pthread_cond_wait failed: %d\n", rv);
exit(1);
}
}
toggle--;
rv = pthread_cond_signal(&cond);
if (rv) {
fprintf(stderr, "pthread_cond_signal failed: %d\n", rv);
exit(1);
}
}
rv = pthread_mutex_unlock(&mutex);
if (rv) {
fprintf(stderr, "pthread_mutex_unlock failed: %d\n", rv);
exit(1);
}
return NULL;
}
void *pong(void *arg)
{
int i;
int rv;
rv = pthread_mutex_lock(&mutex);
if (rv) {
fprintf(stderr, "pthread_mutex_lock failed: %d\n", rv);
exit(1);
}
for (i = 0; i < LOOP; i++) {
while (toggle == 1) {
rv = pthread_cond_wait(&cond, &mutex);
if (rv) {
fprintf(stderr, "pthread_cond_wait failed: %d\n", rv);
exit(1);
}
}
toggle++;
rv = pthread_cond_signal(&cond);
if (rv) {
fprintf(stderr, "pthread_cond_signal failed: %d\n", rv);
exit(1);
}
}
rv = pthread_mutex_unlock(&mutex);
if (rv) {
fprintf(stderr, "pthread_mutex_unlock failed: %d\n", rv);
exit(1);
}
return NULL;
}
int main()
{
pthread_attr_t attr;
pthread_t t1, t2;
int rv;
rv = pthread_mutex_init(&mutex, NULL);
if (rv) {
fprintf(stderr, "pthread_mutex_init failed: %d\n", rv);
exit(1);
}
rv = pthread_cond_init(&cond, NULL);
if (rv) {
fprintf(stderr, "pthread_cond_init failed: %d\n", rv);
exit(1);
}
rv = pthread_attr_init(&attr);
if (rv) {
fprintf(stderr, "pthread_attr_init failed: %d\n", rv);
exit(1);
}
rv = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
if (rv) {
fprintf(stderr, "pthread_attr_setdetachstate failed: %d\n", rv);
exit(1);
}
rv = pthread_create(&t1, &attr, ping, NULL);
if (rv) {
fprintf(stderr, "pthread_create failed: %d\n", rv);
exit(1);
}
rv = pthread_create(&t2, &attr, pong, NULL);
if (rv) {
fprintf(stderr, "pthread_create failed: %d\n", rv);
exit(1);
}
rv = pthread_join(t1, NULL);
if (rv) {
fprintf(stderr, "pthread_join failed: %d\n", rv);
exit(1);
}
rv = pthread_join(t2, NULL);
if (rv) {
fprintf(stderr, "pthread_join failed: %d\n", rv);
exit(1);
}
return 0;
}
[-- Attachment #3: ncpus.c.txt --]
[-- Type: text/plain, Size: 142 bytes --]
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("# processors online = %d\n", sysconf(_SC_NPROCESSORS_ONLN));
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Linux-ia64] Two IA-64 Linux bugs
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
@ 2000-06-05 20:42 ` Dan Pop
2000-06-05 20:58 ` Bill Nottingham
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Dan Pop @ 2000-06-05 20:42 UTC (permalink / raw)
To: linux-ia64
On Sun, 4 Jun 2000, Wan-Teh Chang wrote:
> System info:
> [nspr@tl2 unix]$ uname -a
> Linux tl2.compile.sourceforge.net 2.3.99-pre6-000501-18smp
> #1 SMP Sat May 6 21:30:48 PDT 2000 ia64 unknown
>
> Bug #2: sysconf(_SC_NPROCESSORS_ONLN) returns 0.
> It should return the number of processors online.
I've fixed that in the "official" glibc tree one week ago. It's been
fixed in HJ's tree a few weeks ago (but I don't know how he did it).
This is implemented by counting the lines starting with "CPU#" in
/proc/cpuinfo. If the kernel guys change the format of that file, it
might break again.
Dan
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Linux-ia64] Two IA-64 Linux bugs
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
2000-06-05 20:42 ` Dan Pop
@ 2000-06-05 20:58 ` Bill Nottingham
2000-06-05 22:10 ` Dan Pop
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bill Nottingham @ 2000-06-05 20:58 UTC (permalink / raw)
To: linux-ia64
Dan Pop (Dan.Pop@cern.ch) said:
> I've fixed that in the "official" glibc tree one week ago. It's been
> fixed in HJ's tree a few weeks ago (but I don't know how he did it).
>
> This is implemented by counting the lines starting with "CPU#" in
> /proc/cpuinfo. If the kernel guys change the format of that file, it
> might break again.
Is there any reason why this reads /proc/cpuinfo and not /proc/stat?
/proc/stat is at least consistent across architectures...
Bill
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Linux-ia64] Two IA-64 Linux bugs
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
2000-06-05 20:42 ` Dan Pop
2000-06-05 20:58 ` Bill Nottingham
@ 2000-06-05 22:10 ` Dan Pop
2000-06-06 17:08 ` Boehm, Hans
2000-06-07 14:57 ` Wan-Teh Chang
4 siblings, 0 replies; 6+ messages in thread
From: Dan Pop @ 2000-06-05 22:10 UTC (permalink / raw)
To: linux-ia64
On Mon, 5 Jun 2000, Bill Nottingham wrote:
> Dan Pop (Dan.Pop@cern.ch) said:
> >
> > This is implemented by counting the lines starting with "CPU#" in
> > /proc/cpuinfo. If the kernel guys change the format of that file, it
> > might break again.
>
> Is there any reason why this reads /proc/cpuinfo and not /proc/stat?
> /proc/stat is at least consistent across architectures...
The right person to answer this question is the glibc maintainer, who
happens to be a colleague of yours :-)
Dan
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [Linux-ia64] Two IA-64 Linux bugs
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
` (2 preceding siblings ...)
2000-06-05 22:10 ` Dan Pop
@ 2000-06-06 17:08 ` Boehm, Hans
2000-06-07 14:57 ` Wan-Teh Chang
4 siblings, 0 replies; 6+ messages in thread
From: Boehm, Hans @ 2000-06-06 17:08 UTC (permalink / raw)
To: linux-ia64
We also had problems around here with pthread_cond_wait. The glibc version
we were using was used a linuxthreads snapshot taken at a bad time.
Pthread_cond_wait checked that the current thread owned the mutex.
Unfortunately, it did so even for "fast" mutexes, for which the owner field
wasn't set.
If this is the problem, I would guess that you should be able to avoid it by
using recursive or checking mutexes. The problem is hopefully very
temporary, since the glibc on sourceware exhibited this problem for only a
day.
Hans
> Bug #1: pthread_cond_wait sometimes returns EINVAL (22).
> Run the first attachment (pingpong.c) repeatedly.
> Note that this test doesn't call pthread_cond_destroy
> so it is impossible that we are waiting on a destroyed
> condition variable. This failure is intermittent so you
> may need to try many times to reproduce it.
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Linux-ia64] Two IA-64 Linux bugs
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
` (3 preceding siblings ...)
2000-06-06 17:08 ` Boehm, Hans
@ 2000-06-07 14:57 ` Wan-Teh Chang
4 siblings, 0 replies; 6+ messages in thread
From: Wan-Teh Chang @ 2000-06-07 14:57 UTC (permalink / raw)
To: linux-ia64
"Boehm, Hans" wrote:
>
> We also had problems around here with pthread_cond_wait. The glibc version
> we were using was used a linuxthreads snapshot taken at a bad time.
> Pthread_cond_wait checked that the current thread owned the mutex.
> Unfortunately, it did so even for "fast" mutexes, for which the owner field
> wasn't set.
>
> If this is the problem, I would guess that you should be able to avoid it by
> using recursive or checking mutexes. The problem is hopefully very
> temporary, since the glibc on sourceware exhibited this problem for only a
> day.
Indeed, if I use a recursive or error-checking mutex,
I cannot make my test case (pingpong.c) fail.
Wan-Teh
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-06-07 14:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-06-05 5:44 [Linux-ia64] Two IA-64 Linux bugs Wan-Teh Chang
2000-06-05 20:42 ` Dan Pop
2000-06-05 20:58 ` Bill Nottingham
2000-06-05 22:10 ` Dan Pop
2000-06-06 17:08 ` Boehm, Hans
2000-06-07 14:57 ` Wan-Teh Chang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox