|
Boost Users : |
From: Brian Plummer (bplummer_at_[hidden])
Date: 2006-01-09 00:53:29
Raul Huertas wrote:
> Brian Plummer escribió:
>
>
>>The following simple program seg faults. (I have boiled it down to the
>>bare essentials to product the fault:
>>
>>
>
> I changed your test program to make compiler happy.
>
> This is my modified version:
> =========bug.cc========
> #include <boost/thread.hpp>
>
> void MMULT2(void);
> void MMULT2CalcMaster(void);
>
> int main(void) {
> MMULT2();
> }
>
> class MMULT2ThreadClass {
> void calculate(void) {}
> public :
> MMULT2ThreadClass() {}
> void operator ()() { calculate(); }
> };
>
> void MMULT2CalcMaster(void) {
> int numThreads = 2;
> boost::thread_group threads;
> for (int i = 0; i < numThreads; ++i)
> threads.create_thread(MMULT2ThreadClass());
> threads.join_all();
> }
>
> void MMULT2(void) {
> MMULT2CalcMaster();
> }
> ================
> (I have changed "void *" to "void" in several places).
>
> It works ok for me.
>
> I've compiled with:
> gcc -c -Wall -g \
> -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \
> -I/opt/boost_1_33_1/include bug.cc -o _linux.O/bug.o
>
> And I've linked with:
> gcc -Wall -g -Ihdrs \
> -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \
> -I/opt/boost_1_33_1/include _linux.O/bug.o \
> -o ../_linux.O/bug -L/opt/boost_1_33_1/lib \
> -Wl,-rpath,/opt/boost_1_33_1/lib \
> -lboost_thread-mt-d -lpthread -lstdc++
>
> My gcc is 4.0.2.
>
> Hope this helps.
>
> Raúl.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
I made the changes that you recommended, but it did not affect the
result. I still have a program that seg faults.
Now, that said, as I stated in my previous post, this segv occurs when I
link against the debug version of the boost::thread library and when I
posted my original message I didn't have the release version because for
some reason, as I stated, a bjam build directly in the thread/build
directory did not build a release version. I was able to create a
release version of the boost:thread library by building the whole world.
Now, when I link my original program with the release version of the
boost::thread library I do not have this problem. Hmmm...I'm not sure
what to make of this.
In general, I think that there is something wrong with the debug version
of the boost:thread library on this platform (RH Linux WS V4 with gcc
3.4.5) and I'm not sure what it is. Either that, or I'm just not
building it properly.
I have pasted the debugger output at the end of this message. Seems
that for some reason it doesn't like the actual functor invocation on
function0. I'm not quite sure about how to debug this, especially since
the release version of the lib works fine.
One note, if I print something to the screen in calculate() I only get
one invocation. Hmmm....
Any ideas are welcome. Thanks!!
gdb output
===========================================
GNU DDD 3.3.9 (i386-redhat-linux-gnu), by Dorothea Lütkehaus and Andreas
Zeller.
Copyright © 1995-1999 Technische Universität Braunschweig, Germany.
Copyright © 1999-2001 Universität Passau, Germany.
Copyright © 2001 Universität des Saarlandes, Germany.
Copyright © 2001-2004 Free Software Foundation, Inc.
(gdb) file //SDE/common/bin/LINUX_X86_GCC3.4.5/debug/BoostThreadProblem
Reading symbols from
/SDE/common/bin/LINUX_X86_GCC3.4.5/debug/BoostThreadProblem...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) set args
(gdb) run
Starting program:
/SDE/common/bin/LINUX_X86_GCC3.4.5/debug/BoostThreadProblem
[Thread debugging using libthread_db enabled] [New Thread -1208088896
(LWP 16871)] [New Thread -1208091728 (LWP 16874)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208091728 (LWP 16874)] 0x005d7c3b in
boost::function0<void, std::allocator<boost::function_base>
>::operator() (this=0x89d8458d) at function_template.hpp:576
/scsi01/software/boost_1_33_1/boost/function/function_template.hpp:576:18862:beg:0x5d7c3b
(gdb) backtrace
#0 0x005d7c3b in boost::function0<void,
std::allocator<boost::function_base> >::operator() (this=0x89d8458d) at
function_template.hpp:576
#1 0xd4758bd4 in ?? ()
#2 0x89d8458d in ?? ()
#3 0x37e82404 in ?? ()
#4 0x89ffffaa in ?? ()
#5 0x10ebd475 in ?? ()
#6 0x89d8458d in ?? ()
#7 0x27e82404 in ?? ()
#8 0xebffffaa in ?? ()
#9 0xd4458913 in ?? ()
#10 0x89d4458b in ?? ()
#11 0x97e82404 in ?? ()
#12 0xe8ffffad in ?? ()
#13 0xffffa222 in ?? ()
#14 0x000000b8 in ?? ()
#15 0x40c48300 in ?? ()
#16 0xc35d5e5b in ?? ()
#17 0x56e58955 in ?? ()
#18 0x10ec8353 in ?? ()
#19 0xffb651e8 in ?? ()
#20 0x6dc381ff in ?? ()
#21 0x8b000086 in ?? ()
#22 0x04890845 in ?? ()
#23 0xa9a8e824 in ?? ()
#24 0x458bffff in ?? ()
#25 0x0440c608 in ?? ()
#26 0x08758b00 in ?? ()
#27 0xffadd9e8 in ?? ()
#28 0x830689ff in ?? ()
#29 0x5e5b10c4 in ?? ()
#30 0x8955c35d in ?? ()
#31 0x835356e5 in ?? ()
#32 0x1be810ec in ?? ()
#33 0x81ffffb6 in ?? ()
#34 0x008637c3 in ?? ()
#35 0x08458b00 in ?? ()
#36 0xe8240489 in ?? ()
#37 0xffffa972 in ?? ()
#38 0xc608458b in ?? ()
#39 0x8b000440 in ?? ()
#40 0xa3e80875 in ?? ()
#41 0x89ffffad in ?? ()
#42 0x10c48306 in ?? ()
#43 0xc35d5e5b in ?? ()
#44 0x56e58955 in ?? ()
#45 0x80c48353 in ?? ()
#46 0xffb5e5e8 in ?? ()
#47 0x01c381ff in ?? ()
#48 0x8b000086 in ?? ()
#49 0x04890845 in ?? ()
#50 0xa93ce824 in ?? ()
#51 0x458bffff in ?? ()
#52 0x0440c608 in ?? ()
#53 0x0c458b01 in ?? ()
#54 0x04244489 in ?? ()
#55 0x8998458d in ?? ()
#56 0xa3e82404 in ?? ()
#57 0xc7ffffaf in ?? ()
#58 0x00009445 in ?? ()
#59 0x458d0000 in ?? ()
#60 0x24448998 in ?? ()
#61 0xfe838d0c in ?? ()
#62 0x89ffff78 in ?? ()
#63 0xc7082444 in ?? ()
#64 0x00042444 in ?? ()
#65 0x8b000000 in ?? ()
#66 0x04890845 in ?? ()
#67 0xa568e824 in ?? ()
#68 0x4589ffff in ?? ()
#69 0x947d8394 in ?? ()
#70 0xc7517400 in ?? ()
#71 0x00082404 in ?? ()
#72 0xa3e80000 in ?? ()
#73 0x89ffffa9 in ?? ()
#74 0x458b9045 in ?? ()
#75 0x24048990 in ?? ()
#76 0xffb485e8 in ?? ()
#77 0x8916ebff in ?? ()
#78 0x758b8c45 in ?? ()
#79 0x90458b8c in ?? ()
#80 0xe8240489 in ?? ()
#81 0xffffa3f2 in ?? ()
#82 0xeb8c7589 in ?? ()
#83 0x94838b2f in ?? ()
#84 0x89ffffff in ?? ()
#85 0x8b082444 in ?? ()
#86 0xffffe883 in ?? ()
#87 0x244489ff in ?? ()
#88 0x90458b04 in ?? ()
#89 0xe8240489 in ?? ()
#90 0xffffb2de in ?? ()
#91 0x8998458d in ?? ()
#92 0x63e82404 in ?? ()
#93 0xebffffb0 in ?? ()
#94 0x8c458916 in ?? ()
#95 0x8d8c758b in ?? ()
#96 0x04899845 in ?? ()
#97 0xa9f0e824 in ?? ()
#98 0x7589ffff in ?? ()
#99 0x8d10eb8c in ?? ()
#100 0x04899845 in ?? ()
#101 0xa9e0e824 in ?? ()
#102 0x1febffff in ?? ()
#103 0x8b8c4589 in ?? ()
#104 0x458b8c75 in ?? ()
#105 0x24048908 in ?? ()
#106 0xffa43de8 in ?? ()
#107 0x8c7589ff in ?? ()
#108 0x898c458b in ?? ()
#109 0x7fe82404 in ?? ()
#110 0x83ffffb1 in ?? ()
#111 0x5e5b80ec in ?? ()
#112 0x8955c35d in ?? ()
#113 0x835356e5 in ?? ()
#114 0xd3e880c4 in ?? ()
#115 0x81ffffb4 in ?? ()
#116 0x0084efc3 in ?? ()
#117 0x08458b00 in ?? ()
#118 0xe8240489 in ?? ()
#119 0xffffa82a in ?? ()
#120 0xc608458b in ?? ()
#121 0x8b010440 in ?? ()
#122 0x44890c45 in ?? ()
#123 0x458d0424 in ?? ()
#124 0x24048998 in ?? ()
#125 0xffae91e8 in ?? ()
#126 0x9445c7ff in ?? ()
#127 0x00000000 in ?? ()
(gdb)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net