* [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu
@ 2001-05-25 23:17 Robboy, David G
2001-05-31 4:26 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Dan Pop
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Robboy, David G @ 2001-05-25 23:17 UTC (permalink / raw)
To: linux-ia64
I have reported this on bugzilla also, Bug #42354. I don't know whether it
is
a kernel bug, libc, or libpthread.
The attached program spawns 3 new threads, and each of the 4 threads does a
malloc. Run it on a 4P Lion.
On Linux kernel R2.4.3 (Red Hat release 7.0.98), it aborts with a
segmentation fault. The same binary executable runs correctly on a R2.4.1
kernel.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <asm/page.h>
#define MAXPROCS 4
void SlaveStart();
typedef struct
{
volatile int bt_count0;
volatile int bt_count1;
} barrier_t;
static pthread_mutex_t barrier_lock;
pthread_mutex_t (idlock);
int id = 0;
barrier_t start;
barrier_t end;
static int threadno = 0;
static pthread_t thread[MAXPROCS];
void
init_barrier(barrier_t *barr)
{
pthread_mutex_init(&(barrier_lock), (const pthread_mutexattr_t *)0);
barr->bt_count0 = barr->bt_count1 = 0;
}
void
wait_barrier(barrier_t *barr, int nprocs)
{
int rc;
/* Two barriers guarantee that no one comes around to the barrier
* again before everyone is out if it, even if there are long
* delays in the kernel.
*/
rc = pthread_mutex_lock(&barrier_lock);
if (barr->bt_count0 = nprocs)
barr->bt_count0 = 1;
else
++barr->bt_count0;
rc = pthread_mutex_unlock(&barrier_lock);
while (barr->bt_count0 < nprocs){
;
}
rc = pthread_mutex_lock(&barrier_lock);
/* If this has been called before, re-initialize the counter */
if (barr->bt_count1 = nprocs)
barr->bt_count1 = 1;
else
++barr->bt_count1;
rc = pthread_mutex_unlock(&barrier_lock);
while (barr->bt_count1 < nprocs){
;
}
}
main(argc, argv)
int argc;
char *argv;
{
int i;
int j;
int c;
int status;
pthread_attr_t *attr = 0;
init_barrier(&start);
init_barrier(&end);
for (i=1; i<MAXPROCS; i++) {
status = pthread_create(&thread[threadno++], attr,(void
*)(SlaveStart),(void *)0);
}
SlaveStart();
{exit(0);};
}
void SlaveStart()
{
int i;
int j;
int MyNum;
double error;
double *upriv;
int initdone;
int finish;
int l_transtime=0;
int MyFirst;
int MyLast;
{pthread_mutex_lock(&(idlock));};
MyNum = id;
id++;
{pthread_mutex_unlock(&(idlock));};
{wait_barrier((barrier_t *)&(start), (MAXPROCS));};
printf("Calling malloc: %d\n", MyNum);
upriv = (double *) malloc(2*(28000000-1)*sizeof(double));
if (upriv = NULL) {
fprintf(stderr,"Proc %d could not malloc memory for upriv\n",MyNum);
exit(-1);
}
printf("Called malloc: %d\n", MyNum);
{wait_barrier((barrier_t *)&(end), (MAXPROCS));};
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3.
2001-05-25 23:17 [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu Robboy, David G
@ 2001-05-31 4:26 ` Dan Pop
2001-05-31 5:33 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu David Mosberger
2001-06-01 8:03 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Andreas Schwab
2 siblings, 0 replies; 4+ messages in thread
From: Dan Pop @ 2001-05-31 4:26 UTC (permalink / raw)
To: linux-ia64
On Fri, 25 May 2001, Robboy, David G wrote:
> I have reported this on bugzilla also, Bug #42354. I don't know whether it
> is a kernel bug, libc, or libpthread.
More likely, a problem with your system.
> The attached program spawns 3 new threads, and each of the 4 threads does a
> malloc. Run it on a 4P Lion.
> On Linux kernel R2.4.3 (Red Hat release 7.0.98), it aborts with a
> segmentation fault. The same binary executable runs correctly on a R2.4.1
> kernel.
I couldn't reproduce your problem, despite having exactly the same
hardware and software configuration:
pcpole67:~ 0 6> uname -a
Linux pcpole67 2.4.3-2.10.1smp #1 SMP Fri Apr 20 12:10:00 EDT 2001 ia64 unknown
pcpole67:~ 0 7> cat /etc/issue
Red Hat Linux release 7.0.98 (Wolverine)
Kernel 2.4.3-2.10.1smp on a 4-processor ia64
pcpole67:~ 0 8> gcc foo.c -lpthread
pcpole67:~ 0 9> ./a.out
Calling malloc: 0
Calling malloc: 3
Called malloc: 0
Called malloc: 3
Calling malloc: 1
Calling malloc: 2
Called malloc: 1
Called malloc: 2
pcpole67:~ 0 10>
The box has a vanilla Red Hat release 7.0.98 installation.
> main(argc, argv)
>
> int argc;
> char *argv;
^^^^^^^^^^
If you want to define main in this antique fashion, at least do it right.
Dan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu
2001-05-25 23:17 [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu Robboy, David G
2001-05-31 4:26 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Dan Pop
@ 2001-05-31 5:33 ` David Mosberger
2001-06-01 8:03 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Andreas Schwab
2 siblings, 0 replies; 4+ messages in thread
From: David Mosberger @ 2001-05-31 5:33 UTC (permalink / raw)
To: linux-ia64
>>>>> On Fri, 25 May 2001 16:17:37 -0700, "Robboy, David G" <david.g.robboy@intel.com> said:
David.R> I have reported this on bugzilla also, Bug #42354. I don't
David.R> know whether it is a kernel bug, libc, or libpthread. The
David.R> attached program spawns 3 new threads, and each of the 4
David.R> threads does a malloc. Run it on a 4P Lion. On Linux
David.R> kernel R2.4.3 (Red Hat release 7.0.98), it aborts with a
David.R> segmentation fault. The same binary executable runs
David.R> correctly on a R2.4.1 kernel.
You didn't say how you compiled the program. Let's assume you used
"gcc -O2 -pthread": for what it's worth, this works fine here, both on
Wolverine and Guinness. In both cases with kernel 2.4.4 and on
Wolverine I'm using glibc-2.2.2-10.
--david
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3.
2001-05-25 23:17 [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu Robboy, David G
2001-05-31 4:26 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Dan Pop
2001-05-31 5:33 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu David Mosberger
@ 2001-06-01 8:03 ` Andreas Schwab
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2001-06-01 8:03 UTC (permalink / raw)
To: linux-ia64
"Robboy, David G" <david.g.robboy@intel.com> writes:
|> I have reported this on bugzilla also, Bug #42354. I don't know whether it
|> is
|> a kernel bug, libc, or libpthread.
|> The attached program spawns 3 new threads, and each of the 4 threads does a
|> malloc. Run it on a 4P Lion.
|> On Linux kernel R2.4.3 (Red Hat release 7.0.98), it aborts with a
|> segmentation fault. The same binary executable runs correctly on a R2.4.1
|> kernel.
I have no problem running it with 2.4.4 on SuSE 7.2.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-06-01 8:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-25 23:17 [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu Robboy, David G
2001-05-31 4:26 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Dan Pop
2001-05-31 5:33 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu David Mosberger
2001-06-01 8:03 ` [Linux-ia64] Bug report: 4-threaded program gets seg. fault on malloc, on linu x R2.4.3 Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox