Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* BookReader threads example crashes
@ 1995-12-18  5:00 J Frankland
  1995-12-19  5:00 ` Jeffrey M. Denham
  1995-12-21  5:00 ` Chris Davis 
  0 siblings, 2 replies; 3+ messages in thread
From: J Frankland @ 1995-12-18  5:00 UTC (permalink / raw)


The threads programming example in the Guide to DECthreads (accessible
by the bookreader) which conducts a prime number search, crashes.
It is Example 5-1.  After compiling with the -lpthreads link flag, and
running it, it Seg Faults before it get to the main() function.

It appears to get into a recursive loop where the function
mig_get_reply_port() calls port_allocate() which calls mig_get_reply_port()
which calls port_allocate(), and so on until the stack overflows resulting
in a Seg Fault.

Here is what the stack looks like before it overflows:

(gdb) where
#0  port_allocate () at ./mach_user.c:6092
#1  0x3ff818043c8 in mig_get_reply_port ()
    at ../../../../../src/usr/ccs/lib/libmach/mig_support.c:68
#2  0x3ff81808924 in port_allocate () at ./mach_user.c:6096
#3  0x3ff818043c8 in mig_get_reply_port ()
    at ../../../../../src/usr/ccs/lib/libmach/mig_support.c:68
#4  0x3ff81808924 in port_allocate () at ./mach_user.c:6096
#5  0x3ff818043c8 in mig_get_reply_port ()
    at ../../../../../src/usr/ccs/lib/libmach/mig_support.c:68
#6  0x3ff81808924 in port_allocate () at ./mach_user.c:6096
#7  0x3ff818043c8 in mig_get_reply_port ()
    at ../../../../../src/usr/ccs/lib/libmach/mig_support.c:68
#8  0x3ff81808924 in port_allocate () at ./mach_user.c:6096
#9  0x3ff818043c8 in mig_get_reply_port ()
    at ../../../../../src/usr/ccs/lib/libmach/mig_support.c:68
#10 0x3ff81805230 in vm_allocate () at ./mach_user.c:678
#11 0x3ff8082da7c in more_memory ()
    at ../../../../../src/usr/ccs/lib/DECthreads/alpha/cma_malloc.c:253
#12 0x3ff8082dce8 in malloc ()
    at ../../../../../src/usr/ccs/lib/DECthreads/alpha/cma_malloc.c:376
#13 0x3ff80841138 in cma__alloc_mem ()
    at ../../../../../src/usr/ccs/lib/DECthreads/COMMON/cma_vm.c:562
#14 0x3ff8082fb40 in cma__get_first_mutex ()
    at ../../../../../src/usr/ccs/lib/DECthreads/COMMON/cma_mutex.c:1495
#15 0x3ff8081f360 in cma__init_attr ()
    at ../../../../../src/usr/ccs/lib/DECthreads/COMMON/cma_attr.c:1256
#16 0x3ff8082d140 in cma__init_static ()
    at ../../../../../src/usr/ccs/lib/DECthreads/COMMON/cma_init.c:868
#17 0x3ff8082cff8 in cma_init ()
    at ../../../../../src/usr/ccs/lib/DECthreads/COMMON/cma_init.c:650
(gdb) 



I get the same problem when I compile and run any other sample threads
programs (using pthreads calls) that I have found.  I have had this problem
on a number of DEC Alpha's running various version of OSF/1; 3.0 through 3.2.





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

* Re: BookReader threads example crashes
  1995-12-18  5:00 BookReader threads example crashes J Frankland
@ 1995-12-19  5:00 ` Jeffrey M. Denham
  1995-12-21  5:00 ` Chris Davis 
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey M. Denham @ 1995-12-19  5:00 UTC (permalink / raw)



In article <4b2q2j$i1l@harbinger.cc.monash.edu.au>, jvf@aurora.cc.monash.edu.au (J Frankland) writes:
>The threads programming example in the Guide to DECthreads (accessible
>by the bookreader) which conducts a prime number search, crashes.
>It is Example 5-1.  After compiling with the -lpthreads link flag, and
>running it, it Seg Faults before it get to the main() function.

You're building the programs incorrectly. The flag is -threads, not -lpthreads
etc.

cc -o prog proc.c -lwhatever1 -lwhatever2 -threads

The -threads switch insures the proper ordering of the other libraries
specified with the libraries required for running threads programs.
Build with just -lpthreads leaves out a few vital libraries. The
correct hand-crafted link would look like this:

cc -o prog prog.c -lwhatever1 -lwhatever2 -lpthreads -lmach -lc_r

libmach is the library used by the threads library to Mach threads stuff
with the kernel. libc_r is the thread-safe reentrant C runtime library.

NOTE: with V4.0 of Digital UNIX, due early next year, building threads
programs will change slightly.

To build "legacy" threaded application (ones based on 1003.1c/D4, as
in V3.2C and below):

cc -o prog prog.c -threads

To build "new" threaded applications based on the final pthreads standard
(1003.1c/D10):

cc -o prog prog.c -pthread

Note also that libc_r will go away. Instead, the only and only libc is
now thread safe.

Hope this is off some help to you.
-- 

-----------------------------------------------------------------------------
Jeff Denham, Unix Software Group, Digital Equipment Corporation
email: denham@zk3.dec.com, voice: (603) 881-0057



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

* Re: BookReader threads example crashes
  1995-12-18  5:00 BookReader threads example crashes J Frankland
  1995-12-19  5:00 ` Jeffrey M. Denham
@ 1995-12-21  5:00 ` Chris Davis 
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Davis  @ 1995-12-21  5:00 UTC (permalink / raw)


In <4b2q2j$i1l@harbinger.cc.monash.edu.au> jvf@aurora.cc.monash.edu.au
(J Frankland) writes: 
>
>The threads programming example in the Guide to DECthreads (accessible
>by the bookreader) which conducts a prime number search, crashes.
>It is Example 5-1.  After compiling with the -lpthreads link flag, and
>running it, it Seg Faults before it get to the main() function.

On 3.2c, we traced this problem to the DEC shared libraries pulled in
by -lpthreads.

In our other words, even the simple program below would seg fault:
***********

main()
{
    printf("Hello world\n");
    exit(0);
}
******************
It doesn't even have any thread calls!

We were able to run thread applications after manually linking in the
other libraries.



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

end of thread, other threads:[~1995-12-21  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-12-18  5:00 BookReader threads example crashes J Frankland
1995-12-19  5:00 ` Jeffrey M. Denham
1995-12-21  5:00 ` Chris Davis 

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