Prob. w/ C++ ``new'' in multithreading program - client.cxx

Hi Guys,

I’ve attached a test program that seems to exhibit a problem with
using the C++ built-in ``new’’ operator to create instances of objects
or arrays in an multithreaded program.

While the program runs to completion on the x86, it almost always
dies somewhere mid-run when I run it on an ARM target.

I’m building on QNX RTP 6.1 (uname reports 6.1.0 2002/08/23) and
compiling with:

QCC -g -Vgcc_ntoarmle -o client client.cxx

Am I missing an option or something?

begin 644 client.cxx
M+R@0RLK"@HC:6YC;‘5D92\<W1D;&EB+F@^"B-I;F-L=61E(#QS=&1I;RYH M/@H*(VEN8VQU9&4@/'-E;6%P:&]R92YH/@HC:6YC;'5D92<‘1H<F5A9"YH
M/@H*<W1A=&EC(&-O;G-T(&EN="!.54U?5$A214%$4R](#,["@IC:&%R(&1I M<W!L87E?:61;3E5-7U1(4D5!1%-=.PIS96U?="!S>6YC7W-T87)T6TY535]4 M2%)%041373L*<V5M7W0@<WEN8U]D;VYE6TY535]42%)%041373L*"F-L87-S M($9A<F4*>PH@("@;&]N9R!W86QK.PH@("@<VAO<G0@<&EE<CL*?3L*"G9O M:60@*DYE=T1E;&5T95=O<FME<BAV;VED*B!I9"D*>PH@("@8VAA<B!M>5]I
M9"]("HH<W1A=&EC7V-A<W0\8VAA<BH^*&ED*2D["B@("!L;VYG(&EN9&5X
M(#T@<W1A=&EC7V-A<W0;&]N9SXH;7E?:60I(“T@-#@[”@H@(“@+R\@16%C M:"!T:')E860@=V%I=',@9F]R('1H92!M86EN('1H<F5A9"!T;R!S=&%R="!H M:6T@=7N”@H@("@<V5M7W=A:70H)G-Y;F-?<W1A<G1;:6YD97A=*3L*"B@
M("O+R!$;R!T:&4@=V]R:PH*("@(&9O<BH:6YT(&D@/2P.R!I(#P@,C4[
M(“LK:2D*(“@('L*"69O<BH:6YT(&H@/2P.R!J(#P@,C4[(&HK*RD*"7L* M"2@(”!N97<@1F%R93L*“2@("!N97<@;&]N9ULQ,ET["@E]"@H@("@(”@ M('!R:6YT9B@B)6,B+"!M>5]I9"D["B@(”@("@9F9L=7-H*’-T9&]U=“D[
M”@H@("@?0H*("@("\O($%N;F]U;F-E(&-O;7!L971I;VX@;V8@=&AE(’=O
M<FL*“B@("!P<FEN=&8H(CPE8SXB+"!M>5]I9"D["B@(”!F9FQU<V@H<W1D
M;W5T3L"B@("!S96U?<&]S="@F<WEN8U]D;VYE6VEN9&5X72D["@H@("@
M<F5T=7)N(#["@I]"@II;G0*4G5N5&5S="AC;VYS="!C:&%R("IT97-T7VYA M;64L('9O:60@*B@J=V]R:V5R*2AV;VED("HI*0I["B@("!I;G0@:3L*("@ M(&EN="!R8SL*"B@("!P<FEN=&8H(B5S('1E<W0@8F5G:6YS+BXN7&XB+"!T
M97-T7VYA;64I.PH@("@9F9L=7-H*'-T9&]U="D["@H@("@+R@0W)E871E
M('1H92!W;W)K97(@=&AR96%D<PH*(“@(&9O<BH:2](#[(&D@/”!.54U?
M5$A214%$4SL@RMI0H@("@>PH@("@(“@(&1I<W!L87E?:61;:5T@/2G
M,”<@R!I.PH)<F,@/2!P=&AR96%D7V-R96%T92A.54Q,+"!.54Q,+"!W;W)K
M97(L(“9D:7-P;&%Y7VED6VE=3L(”@('T*"B@("O+R!,970@=&AE('1H M<F5A9',@<G5N"@H@("@9F]R("AI(#T@,#L@:2\($Y535]42%)%0413.RK
M
VDI"B@("!["B@("@("@<V5M7W!O<W0H)G-Y;F-?<W1A<G1;:5TI.PH@
M("@?0H*("@("\O(%=A:70@9F]R('1H96T@=&@8V]M<&QE=&4*“B@("!F M;W(@*&D@/2P.R!I(#P@3E5-7U1(4D5!1%,[(“LK:2D*(”@('L*("@(”@ M("!S96U?=V%I="@F<WEN8U]D;VYE6VE=*3L*("@(‘T*“B@("!R971U<FX@ M=')U93L*"GT*"FEN="!M86EN("AI;G0@87)G8RP@8VAA<BJ87)G=EM=2* M>PH@("@:6YT(&D["@H@("@9F]R("AI(#T@,#L@:2($Y535]42%)%0413
M.RK*VDI"B@("!["B@("@("@<V5M7VEN:70H)G-Y;F-?<W1A<G1;:5TL M(#L(#I.PH@("@("@('-E;5]I;FET*"9S>6YC7V1O;F5;:5TL(#L(#I M.PH@("@?0H
(”@(%)U;E1E<W0H(E9E8V]R(&YE=R]D96QE=&4B+"!.97=$ M96QE=&57;W)K97(I.PH*("@(’!R:6YT9B@B7&XB3L("@('!R:6YT9B@B D2&%P<'DL(&AA<'!Y7&XB*3L*"B@("!R971U<FX@,#L*?0H*
`
end

jwc@ois.com (J. Bill Chilton) wrote in news:a6r0rr$m3q$1@nntp.qnx.com:

Hi Guys,

I’ve attached a test program that seems to exhibit a problem with
using the C++ built-in ``new’’ operator to create instances of objects
or arrays in an multithreaded program.

While the program runs to completion on the x86, it almost always
dies somewhere mid-run when I run it on an ARM target.

Where does it die? How do you know it’s “new” which is causing the
problem?

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

In article Xns91D261D91C3F8amalloryqnxcom@209.226.137.4, Adam Mallory <amallory@qnx.com> wrote:

jwc@ois.com > (J. Bill Chilton) wrote in news:a6r0rr$m3q$> 1@nntp.qnx.com> :

Hi Guys,

I’ve attached a test program that seems to exhibit a problem with
using the C++ built-in ``new’’ operator to create instances of objects
or arrays in an multithreaded program.

While the program runs to completion on the x86, it almost always
dies somewhere mid-run when I run it on an ARM target.

Where does it die? How do you know it’s “new” which is causing the
problem?

Excellent questions. I’m just examining the core files now and it dies
at <__builtin_new+176>. Also, if I override the default C++ operator
new and operator new[] with replacements that just call malloc, it
runs clean.

Do you see any problems with the test program? I’ll be interested to
hear if it behaves differently for you…

Thanks!

/jwc

Hi, I tried it on a 6.2 beta system and it ran clean without modification.

J. Bill Chilton <jwc@ois.com> wrote:

In article Xns91D261D91C3F8amalloryqnxcom@209.226.137.4, Adam Mallory <> amallory@qnx.com> > wrote:
jwc@ois.com > (J. Bill Chilton) wrote in news:a6r0rr$m3q$> 1@nntp.qnx.com> :

Hi Guys,

I’ve attached a test program that seems to exhibit a problem with
using the C++ built-in ``new’’ operator to create instances of objects
or arrays in an multithreaded program.

While the program runs to completion on the x86, it almost always
dies somewhere mid-run when I run it on an ARM target.

Where does it die? How do you know it’s “new” which is causing the
problem?

Excellent questions. I’m just examining the core files now and it dies
at <__builtin_new+176>. Also, if I override the default C++ operator
new and operator new[] with replacements that just call malloc, it
runs clean.

Do you see any problems with the test program? I’ll be interested to
hear if it behaves differently for you…

Thanks!

/jwc


cburgess@qnx.com