Linux MIPS Architecture development
 help / color / mirror / Atom feed
* pthread_create() gets BUS ERROR
@ 2000-10-19 22:31 Jun Sun
  2000-10-19 22:39 ` Ralf Baechle
  0 siblings, 1 reply; 6+ messages in thread
From: Jun Sun @ 2000-10-19 22:31 UTC (permalink / raw)
  To: linux-mips

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]


I am running a simple pthread_create() test.  The thread gets created,
but the creating thread gets BUS error after the function call.  In
fact, it gets SIGUSR1 signal.  Does anybody know what is wrong here?

It looks to me that creating thread is waiting for the created thread to
start up, but somehow did not install the signal handler correctly!?

I am running with the "stable" toolchain that I generated recently,
i.e., binutil 2.8.1, egcs 1.0.3a and glibc2.0.6.

I attached the program and the strace output.

Thanks.

Jun

[-- Attachment #2: pthread.c --]
[-- Type: text/plain, Size: 532 bytes --]

#include <pthread.h>
#include <stdio.h>
#include <errno.h>

typedef void * (*pthread_func_t) (void *);


void myfunc(void *arg)
{
   printf("slave : myfunc runs.\n");
}

main()
{
    int ret;

    pthread_t thread;

    printf("master : before create a thread ... \n");

    ret = pthread_create(&thread, NULL, (pthread_func_t)myfunc, NULL);
    perror("after creating a thread ... :");
   printf("master : after create a thread ... %d(%s)\n", ret, strerror(ret));

   if (ret == EAGAIN) {
      printf("error is EAGAIN\n");
   }
}

[-- Attachment #3: output --]
[-- Type: text/plain, Size: 3341 bytes --]

execve("./pthread", ["./pthread"], [/* 15 vars */]) = 0
brk(0)                                  = 0x10010fb0
cacheflush(0x7ffffbb8, 0x28, 0x3)       = 0
cacheflush(0x7ffffb40, 0x28, 0x3)       = 0
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 715829248
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
cacheflush(0x7ffffaa8, 0x28, 0x3)       = 0
open("/etc/ld.so.cache", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/lib/libpthread.so.0", O_RDONLY)  = 3
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 715833344
munmap(0x2aaac000, 4096)                = 0
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 715833344
mprotect(0x2aab7000, 281200, PROT_NONE) = 0
mmap(NULL, 0, PROT_NONE, MAP_FILE, 0, 0) = 0x2aaf6000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 716161024
munmap(0x2aafc000, 4096)                = 0
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 716161024
mprotect(0x2abb3000, 330496, PROT_NONE) = 0
mmap(0x18f, 0, 0x8f380000, MAP_SHARED|MAP_FIXED|MAP_RENAME|0x180, 0, 0x8f380000) = 0x2abf2000
mmap(0x8f364045, 87, PROT_NONE, MAP_FILE|0x8f380000, 121, 0ptrace: umoven: Input/output error
) = 717201408
close(3)                                = 0
mprotect(0x2aafc000, 749568, PROT_READ|PROT_WRITE) = 0
mprotect(0x2aafc000, 749568, PROT_READ|PROT_EXEC) = 0
mprotect(0x2aaac000, 45056, PROT_READ|PROT_WRITE) = 0
mprotect(0x2aaac000, 45056, PROT_READ|PROT_EXEC) = 0
personality(PER_LINUX)                  = 0
getpid()                                = 92
getpid()                                = 92
sigaction(SIGUSR1, {0x10000000, [TRAP EMT BUS SEGV SYS ALRM USR2 CHLD WINCH IO TSTP TTIN VTALRM XCPU], 0}, NULL, 0x5c) = 0
sigaction(SIGUSR2, {SIG_DFL}, NULL, 0x5c) = 0
sigprocmask(SIG_BLOCK, [USR1], NULL)    = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(3, 0), ...}) = 0
mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 717242368
ioctl(1, TCGETS, {B9600 opost isig icanon echo ...}) = 0
write(1, "master : before create a thread "..., 37master : before create a thread ... 
) = 37
brk(0)                                  = 0x10010fb0
brk(0x10012fa8)                         = 0x10012fa8
brk(0x10013000)                         = 0x10013000
pipe([717225552, 0])                    = 3
clone(child_stack=0x10012f78, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND) = 93
sigprocmask(SIG_SETMASK, NULL, [USR1])  = 0
write(4, "\0\220\257*\0\0\0\0\0\0\0\0\220\v@\0\0\0\0\0\0\200\0\0"..., 148) = 148
sigprocmask(SIG_SETMASK, NULL, [USR1])  = 0
sigsuspend(~[HUP INT QUIT ILL EMT FPE BUS] <unfinished ...>
--- SIGUSR1 (User defined signal 1) ---
<... sigsuspend resumed> )              = -1 EINTR (Interrupted system call)
sigreturn()                             = ? (mask now [TRAP FPE BUS SEGV SYS ALRM TERM CHLD PWR PROF])
--- SIGBUS (Bus error) ---
+++ killed by SIGBUS +++
sh-2.03# slave : myfunc runs.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread_create() gets BUS ERROR
  2000-10-19 22:31 pthread_create() gets BUS ERROR Jun Sun
@ 2000-10-19 22:39 ` Ralf Baechle
  2000-10-19 23:00   ` Jun Sun
  2000-10-24  1:24   ` Jun Sun
  0 siblings, 2 replies; 6+ messages in thread
From: Ralf Baechle @ 2000-10-19 22:39 UTC (permalink / raw)
  To: Jun Sun; +Cc: linux-mips

On Thu, Oct 19, 2000 at 03:31:54PM -0700, Jun Sun wrote:

> I am running a simple pthread_create() test.  The thread gets created,
> but the creating thread gets BUS error after the function call.  In
> fact, it gets SIGUSR1 signal.  Does anybody know what is wrong here?
> 
> It looks to me that creating thread is waiting for the created thread to
> start up, but somehow did not install the signal handler correctly!?
> 
> I am running with the "stable" toolchain that I generated recently,
> i.e., binutil 2.8.1, egcs 1.0.3a and glibc2.0.6.

Which libc release exactly?

I've uploaded another release glibc-2.0.6-7lm to oss:/pub/linux/mips/glibc/.
In case you're running big endian, could you try that release?

(Sorry, no source, will upload the srpm tomorrow.)

  Ralf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread_create() gets BUS ERROR
  2000-10-19 22:39 ` Ralf Baechle
@ 2000-10-19 23:00   ` Jun Sun
  2000-10-24  1:24   ` Jun Sun
  1 sibling, 0 replies; 6+ messages in thread
From: Jun Sun @ 2000-10-19 23:00 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips

Ralf Baechle wrote:
> 
> On Thu, Oct 19, 2000 at 03:31:54PM -0700, Jun Sun wrote:
> 
> > I am running a simple pthread_create() test.  The thread gets created,
> > but the creating thread gets BUS error after the function call.  In
> > fact, it gets SIGUSR1 signal.  Does anybody know what is wrong here?
> >
> > It looks to me that creating thread is waiting for the created thread to
> > start up, but somehow did not install the signal handler correctly!?
> >
> > I am running with the "stable" toolchain that I generated recently,
> > i.e., binutil 2.8.1, egcs 1.0.3a and glibc2.0.6.
> 
> Which libc release exactly?
> 
> I've uploaded another release glibc-2.0.6-7lm to oss:/pub/linux/mips/glibc/.
> In case you're running big endian, could you try that release?
> 
> (Sorry, no source, will upload the srpm tomorrow.)
> 
>   Ralf

I am running little endian - and I am running with my own setup.

Can you post the diff file first?  Assuming no other changes ...

Jun

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread_create() gets BUS ERROR
  2000-10-19 22:39 ` Ralf Baechle
  2000-10-19 23:00   ` Jun Sun
@ 2000-10-24  1:24   ` Jun Sun
  2000-10-24  1:37     ` Ralf Baechle
  1 sibling, 1 reply; 6+ messages in thread
From: Jun Sun @ 2000-10-24  1:24 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips

Ralf Baechle wrote:
> 
> On Thu, Oct 19, 2000 at 03:31:54PM -0700, Jun Sun wrote:
> 
> > I am running a simple pthread_create() test.  The thread gets created,
> > but the creating thread gets BUS error after the function call.  In
> > fact, it gets SIGUSR1 signal.  Does anybody know what is wrong here?
> >
> > It looks to me that creating thread is waiting for the created thread to
> > start up, but somehow did not install the signal handler correctly!?
> >
> > I am running with the "stable" toolchain that I generated recently,
> > i.e., binutil 2.8.1, egcs 1.0.3a and glibc2.0.6.
> 
> Which libc release exactly?
> 
> I've uploaded another release glibc-2.0.6-7lm to oss:/pub/linux/mips/glibc/.
> In case you're running big endian, could you try that release?
> 
> (Sorry, no source, will upload the srpm tomorrow.)
> 
>   Ralf


Since Ralf has not posted his patch for glibc yet, I looked into the
problem a little bit more.

It appears to be another toolchain related problem, instead of a glibc
problem.

In linuxthread/pthread.c:pthread_initialize_manager(), it accesses a
global variable __pthread_initial_thread_bos in pthread shared library. 
Apparently the code finds out the address of the variable through some
table (why is that?).  It looks like the offset for variable is off by
8.  Another ld problem?

I am using the "old but stable" toolchains, as I stated in an earlier
email. :-9

Jun

======

"...
I finally settled down with the old but deemed reliable versions :

a) binutils v2.8.1 + mips patch 

ftp://sourceware.cygnus.com/pub/binutils/releases/
ftp://oss.sgi.com/pub/linux/mips/binutils/binutils-2.8.1-3.diff.gz

b) egcs 1.0.3a + mips patch

ftp://ftp.mvista.com/pub/Area51/mips_le/misc/egcs-1.0.3a.tar.gz
ftp://oss.sgi.com/pub/linux/mips/egcs/egcs-1.0.3a-2.diff.gz


c) glibc 2.0.6 + mips patch

ftp://oss.sgi.com/pub/linux/mips/glibc/srpms/glibc-2.0.6-5lm.src.rpm
..."

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread_create() gets BUS ERROR
  2000-10-24  1:24   ` Jun Sun
@ 2000-10-24  1:37     ` Ralf Baechle
  2000-10-24 21:36       ` Jun Sun
  0 siblings, 1 reply; 6+ messages in thread
From: Ralf Baechle @ 2000-10-24  1:37 UTC (permalink / raw)
  To: Jun Sun; +Cc: Ralf Baechle, linux-mips

On Mon, Oct 23, 2000 at 06:24:18PM -0700, Jun Sun wrote:

> Since Ralf has not posted his patch for glibc yet, I looked into the
> problem a little bit more.

If you'd be waiting just a few minutes longer I'd have announced it :-)

The srpm is currently uploading to oss.sgi.com:/pub/linux/mips/glibc/
srpms/glibc-2.0.6-7lm.src.rpm.  The file is 4682466 bytes long, so don't
start downloading before it's completly uploaded :-)

> It appears to be another toolchain related problem, instead of a glibc
> problem.
> 
> In linuxthread/pthread.c:pthread_initialize_manager(), it accesses a
> global variable __pthread_initial_thread_bos in pthread shared library. 
> Apparently the code finds out the address of the variable through some
> table (why is that?).  It looks like the offset for variable is off by
> 8.  Another ld problem?
> 
> I am using the "old but stable" toolchains, as I stated in an earlier
> email.:-9

This description somehow rings a bell.  I'll dig through my mailfolders
and will post if I find something.

  Ralf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread_create() gets BUS ERROR
  2000-10-24  1:37     ` Ralf Baechle
@ 2000-10-24 21:36       ` Jun Sun
  0 siblings, 0 replies; 6+ messages in thread
From: Jun Sun @ 2000-10-24 21:36 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips

Ralf Baechle wrote:
> 
> On Mon, Oct 23, 2000 at 06:24:18PM -0700, Jun Sun wrote:
> 
> > Since Ralf has not posted his patch for glibc yet, I looked into the
> > problem a little bit more.
> 
> If you'd be waiting just a few minutes longer I'd have announced it :-)
> 
> The srpm is currently uploading to oss.sgi.com:/pub/linux/mips/glibc/
> srpms/glibc-2.0.6-7lm.src.rpm.  The file is 4682466 bytes long, so don't
> start downloading before it's completly uploaded :-)
> 
> > It appears to be another toolchain related problem, instead of a glibc
> > problem.
> >
> > In linuxthread/pthread.c:pthread_initialize_manager(), it accesses a
> > global variable __pthread_initial_thread_bos in pthread shared library.
> > Apparently the code finds out the address of the variable through some
> > table (why is that?).  It looks like the offset for variable is off by
> > 8.  Another ld problem?
> >
> > I am using the "old but stable" toolchains, as I stated in an earlier
> > email.:-9
> 
> This description somehow rings a bell.  I'll dig through my mailfolders
> and will post if I find something.
> 
>   Ralf

Since I suspect it is binutils problem, I tried to use the latest
binutil with egcs 1.0.3a and glibc 2.0.6.  This leads to unusable
userland programs - init hangs.  sash runs, but nothing else seems to
work.  Do that mean I should not mix up the versions among toolchains? 
Has anybody tried that above combo before?

I will try glibc-2.0.6-7lm.src.rpm, but I am very hopeful that it will
solve this problem.

BTW, has anybody got pthread running on any 2.4 Linux/MIPS?  I want to
know if I am just unlucky or else...

Jun

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-10-24 21:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-19 22:31 pthread_create() gets BUS ERROR Jun Sun
2000-10-19 22:39 ` Ralf Baechle
2000-10-19 23:00   ` Jun Sun
2000-10-24  1:24   ` Jun Sun
2000-10-24  1:37     ` Ralf Baechle
2000-10-24 21:36       ` Jun Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox