More PPC pthread madness

That program (uuencoded below) compiled + ran fine, when compiled like
this:

cc t.c -o t -lpthread -static
^^^^^^^

It appears that the libpthread doesn’t like dynamic loading.On Sat, 28 Mar 1998, Sam Lantinga wrote:

Date: Sat, 28 Mar 1998 20:29:32 -0800
From: Sam Lantinga
To: Michael Samuel , ctm at ardi.com
Cc: slouken at devolution.com
Subject: More PPC pthread madness

Apparently pthreads does something evil to the address space of the
process. As far as I can tell, after pthread_create(), malloc()
starts eating into the text and data segments of the process.

[slouken at ickis slouken]$ gcc -o t t.c -lpthread && ./t
Thread running
Allocating 1K
(part 1 of 16)
Segmentation fault
[slouken at ickis slouken]$

The amount of code and the amount of static data in the program
directly affects where the malloc() will generate a segmentation
violation. When -O2 is used in compiling t.c, the code is smaller
and malloc() is able to get the first 64 byte chunk, but fails on
the second.

I did a comparison of the assembly output of egcs 1.0.2 release
for Intel, and egcs 1.0.2 prerelease for PPC, and the code is quite
similar. The only significant difference seems to be that the code
is aligned on 4-byte boundaries on intel, and 2 byte boundaries on
PPC. I don’t know if this matters. If it doesn’t, it leads me to
believe that the implementation of pthreads and possibly glibc1 is
bad on PPC. (The test program and SDL have no problems on Intel)

I suggest upgrading libc to glibc-2.0.6, although it appears that
ppc is not supported by glibc-linuxthreads-2.0.6 out of the box.
There are known multi-threading problems with glibc 1.9.9-2.0.1

Any thoughts?

begin 664 t.c
M"B-I;F-L=61E(#QS=&1I;RYH/@HC:6YC;‘5D92\<W1D;&EB+F@^"B-I;F-L M=61E(#QP=&AR96%D+F@^"@HC9&5F:6YE($Q535!325I%"38T"B\J($EF($Y5 M34Q535!3(#X at -"F)B!.54U,54U04R\(#8@=&AE;B!T:&ES('!R;V=R86T@ M8W)A<VAI;F<@:6X@;6%L;&]C*"D@*B\*+R\C9&5F:6YE($Y534Q535!3"38U M"2\J($QO=R!E;F0L(&UA;&QO8R!S96=F875L=', at 870@<&%R="Q-BH,4LI M("HO"B\O(V1E9FEN92!.54U,54U04PDV- at DO*B!M86QL;V,@<V5G9F%U;'1S M(&%T('!A<G0@,34@*B\*+R\C9&5F:6YE($Y534Q535!3"38W"2\J(&UA;&QO M8R!S96=F875L=', at 870@<&%R="Q-"J+PHO+R-D969I;F4 at 3E5-3%5-4%,) M.#)+RH@;6%L;&]C(’-E9V9A=6QT<R!A="!P87)T(#,@B*+R\C9&5F:6YE
M($Y534Q535!3"3 at Q"2\J(&UA;&QO8R!S96=F875L=’, at 870@<&%R="R("HO M"B-D969I;F4 at 3E5-3%5-4%,).#()+RH@:&EG:"!E;F0L(&UA;&QO8R!S96=F M875L=', at 870@<&%R="Q("HO"G-T871I8R!C:&%R(&QU;7!S6TQ535!325I%
M
DY534Q535!373L*“G9O:60@<G5N*'9O:60@G5N=7-E9"D>PH)9G!R:6YT
M9BAS=&1E<G(L(”)4:’)E860@<G5N;FEN9UQN(BD["@ES;&5E<"@S3L"69P
M<FEN=&8H<W1D97)R+"B5&AR96%D(&9I;FES:&5D7&XB*3L*?0H*:6YT(&UA M:6XH:6YT(&%R9V,L(&-H87(@*F%R9W9;72D*>PH):6YT(&D["@EP=&AR96%D M7W0@=&AR96%D.PH*"6EF("@@<'1H<F5A9%]C<F5A=&4H)G1H<F5A9"P at 3E5, M3"P@*'9O:60@*BER=6XL($Y53$PI("$](#@2!["@D)9G!R:6YT9BAS=&1E
M<G(L(")P=&AR96%D7V-R96%T92 at I(&5R<F]R7&XB
3L*"0EE>&ET*#$I.PH)
M?0H)<VQE97H,2D["B-D969I;F4 at 4$%25%,@,38*"69P<FEN=&8H<W1D97)R M+"B06QL;V-A=&EN9RQ2UQN(BD["@EF;W(@*"!I/3[(&D\4$%25%,[("LK
M:2I('L*"0EF<')I;G1F*'-T9&5R<BP@(BAP87)T("5D(&]F("5D*5QN(BP@ M:2LQ+"!005)44RD["@D);6%L;&]C*#$P,C0O4$%25%,I.PH)?0H)9G!R:6YT M9BAS=&1E<G(L(")786ET:6YG(&9O<B!T:')E860N+BY<;B(I.PH)<'1H<F5A B9%]J;VEN*'1H<F5A9"P at 3E5,3"D["@EE>&ET*#I.PI]"B(I
`
end

See ya!
-Sam Lantinga (slouken at devolution.com)


Author of Linux Maelstrom -
http://www.devolution.com/~slouken/Maelstrom/

Michael Samuel,

Surf-Net City - Internet Cafe and Internet Service Providers
Phone: +61 3 9593-9977
E-Mail:
WWW: http://www.surfnetcity.com.au/~michael/

Thread running
Allocating 1K
(part 1 of 16)
Segmentation fault
[slouken at ickis slouken]$

The amount of code and the amount of static data in the program
directly affects where the malloc() will generate a segmentation
violation. When -O2 is used in compiling t.c, the code is smaller
and malloc() is able to get the first 64 byte chunk, but fails on
the second.

That ‘t.c’ program (the bigger one), when compiled like this:

cc -o t t.c -lpthread -static -O2

with

#define PARTS 128

segfaults at 101…

Is this just something I missed, or is this still the LinuxPPC broken
pthreads?

Michael Samuel,

Surf-Net City - Internet Cafe and Internet Service Providers
Phone: +61 3 9593-9977
E-Mail:
WWW: http://www.surfnetcity.com.au/~michael/On Sat, 28 Mar 1998, Sam Lantinga wrote:

#define PARTS 128

segfaults at 101…

Is this just something I missed, or is this still the LinuxPPC broken
pthreads?

I think it’s LinuxPPC broken pthreads, unfortunately.

Ok, so a reliable LinuxPPC port will either

A) Not use threads
B) Need some poor sucker to rewrite clone.S into PPC asm… (NOT ME!)

Michael Samuel,

Surf-Net City - Internet Cafe and Internet Service Providers
Phone: +61 3 9593-9977
E-Mail:
WWW: http://www.surfnetcity.com.au/~michael/On Wed, 1 Apr 1998, Sam Lantinga wrote:

Date: Wed, 1 Apr 1998 18:52:43 -0800
From: Sam Lantinga
To: Michael Samuel
Subject: Re: More PPC pthread madness