Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 2000 23:56:29 +0700 (NSS)
From:      Max Khon <fjoe@iclub.nsu.ru>
To:        John Polstra <jdp@polstra.com>
Cc:        hackers@freebsd.org
Subject:   Re: Trouble with dynamic loading of C++ libs in PHP v4.02 on FreeBSD 4.1
Message-ID:  <Pine.BSF.4.21.0009152318270.78659-300000@iclub.nsu.ru>
In-Reply-To: <200009151605.JAA04563@vashon.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-479365117-969036989=:78659
Content-Type: TEXT/PLAIN; charset=US-ASCII

hi, there!

On Fri, 15 Sep 2000, John Polstra wrote:

> > there were some problems with pthreads initialization (but David will not
> > like the way I did it -- some files in contrib/gcc should be changed).
> > this happened because we initialize pthreads from static object
> > constructor (which is not the right thing anyway).
> 
> It seemed like a good idea at the time. :-) What is the problem --
> is it that libc_r is initialized at the wrong time?  What would you
> suggest as a better method for initializing the library?  I'd hate to
> introduce a bunch of "if (!initted) { ... }" checks, since those add
> runtime overhead on every call.

`__register_frame_info' should be called from `do_ctors' in
src/lib/csu/common/crtbegin.c to load frame information from .eh_frame
sections before any constructors are executed because try/catch can be
used in constructors of static objects (`__register_frame_info'
is defined in src/contrib/gcc/frame.c, this file is linked into
libgcc[_r].a). however `__register_frame_info' uses locks and other
threading stuff (using pthreads on FreeBSD) so we must have pthreads
initialized before locks are used.

another issue with our pthreads initialization is that pthreads can be
used in static object constructors so the first `pthread_xxx' call can
happen before `_thread_init' is called from constructor of our
_thread_init_invoker (it depends on order in which constructors are placed
in .ctors section).

I see two solutions (both seem to be hacks for me):
1) we can insert if (!initted) ... in `pthread_once' (this seem to be the
first pthreads function called from __register_frame_info)
2) we can insert 

#if __GTHREADS
  _thread_init();
#endif
 
   at the very beginning of `__register_frame_info'

The second approach seems to be cleaner but require changes in
src/contrib/gcc/

/fjoe

PS I have attached patches and Makefile.inc which should be placed
into src/lib/csu. Makefile.inc can be slightly out of date (I made it
somewhere around May/Jun 2000)

--0-479365117-969036989=:78659
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="eh_frame.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.4.21.0009152356290.78659@iclub.nsu.ru>
Content-Description: 
Content-Disposition: attachment; filename="eh_frame.diff"

LS0tIGNvbnRyaWIvZ2NjL2NvbmZpZy9mcmVlYnNkLmgub3JpZwlXZWQgSnVs
IDE5IDA3OjMwOjUzIDIwMDANCisrKyBjb250cmliL2djYy9jb25maWcvZnJl
ZWJzZC5oCVN1biBKdWwgMjMgMTc6NTk6MzMgMjAwMA0KQEAgLTEzNywxMiAr
MTM3LDYgQEANCiAjdW5kZWYgIEhBTkRMRV9TWVNWX1BSQUdNQQ0KICNkZWZp
bmUgSEFORExFX1NZU1ZfUFJBR01BDQogDQotLyogRnJlZUJTRCBFTEYgdXNp
bmcgb3VyIGhvbWUtZ3Jvd24gY3J0YmVnaW4uby9jcnRlbmQubyBkb2VzIG5v
dCBzdXBwb3J0IHRoZQ0KLSAgIERXQVJGMiB1bndpbmRpbmcgbWVjaGFuaXNt
cy4gIE9uY2UgYG1ha2Ugd29ybGQnIGJvb3RzdHJhcGluZyBwcm9ibGVtcyB3
aXRoDQotICAgdGhlIEVHQ1MgY3J0c3R1ZmYuYyBpcyBvdmVyY29tZSwgd2Ug
d2lsbCBzd2l0Y2ggdG8gdGhlIG5vbi1zamxqLWV4Y2VwdGlvbnMgDQotICAg
dHlwZSBleGNlcHRpb24gbWFjaGFuaXNtLiAgKi8NCi0jZGVmaW5lIERXQVJG
Ml9VTldJTkRfSU5GTyAwDQotDQogLyogRG8gbm90IHVzZSBgYHRodW5rcycn
IHRvIGltcGxlbWVudCBDKysgdnRhYmxlcy4gIFRoaXMgbWV0aG9kIHN0aWxs
IGhhcw0KICAgIGZhdGFsIGJ1Z3MuICBBbHNvLCBHQ0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0tIGxpYi9jc3UvY29tbW9uL2NydGVu
ZC5jLm9yaWcJTW9uIEp1bCAxMCAxNjoxNToyOCAyMDAwDQorKysgbGliL2Nz
dS9jb21tb24vY3J0ZW5kLmMJU3VuIEp1bCAyMyAxNzo1OTozMyAyMDAwDQpA
QCAtMjYsOCArMjYsMTEgQEANCiAgKi8NCiANCiAjaW5jbHVkZSA8c3lzL2Nk
ZWZzLmg+DQorI2luY2x1ZGUgPHN5cy90eXBlcy5oPg0KIA0KIHR5cGVkZWYg
dm9pZCAoKmZwdHIpKHZvaWQpOw0KIA0KIHN0YXRpYyBmcHRyIGN0b3JfZW5k
WzFdIF9fYXR0cmlidXRlX18oKHNlY3Rpb24oIi5jdG9ycyIpKSkgX191bnVz
ZWQgPSB7IDAgfTsNCiBzdGF0aWMgZnB0ciBkdG9yX2VuZFsxXSBfX2F0dHJp
YnV0ZV9fKChzZWN0aW9uKCIuZHRvcnMiKSkpIF9fdW51c2VkID0geyAwIH07
DQorc3RhdGljIHVfaW50MzJfdCBlaF9mcmFtZV9lbmRbMV0gX19hdHRyaWJ1
dGVfXygoc2VjdGlvbigiLmVoX2ZyYW1lIikpKQ0KKwkJCQkgX191bnVzZWQg
PSB7IDAgfTsNCg==
--0-479365117-969036989=:78659
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="Makefile.inc"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.4.21.0009152356291.78659@iclub.nsu.ru>
Content-Description: 
Content-Disposition: attachment; filename="Makefile.inc"

VEFSR0VUX0FSQ0g/PQkke01BQ0hJTkVfQVJDSH0NCg0KLmlmICR7VEFSR0VU
X0FSQ0h9ID09ICJtaXBzZWwiIHx8ICR7VEFSR0VUX0FSQ0h9ID09ICJtaXBz
ZWIiDQpHQ0NfQVJDSD0JbWlwcw0KLmVsc2UgDQpHQ0NfQVJDSD0JJHtUQVJH
RVRfQVJDSH0NCi5lbmRpZg0KR0NDRElSPQkJJHsuQ1VSRElSfS8uLi8uLi8u
Li9jb250cmliL2djYw0KDQpHRU5TUkNTPQl0bS5oDQpTUkNTKz0JCSR7R0VO
U1JDU30NCkNMRUFORklMRVMrPQkke0dFTlNSQ1N9DQpDRkxBR1MrPQktSS4g
LUkke0dDQ0RJUn0gLUkke0dDQ0RJUn0vY29uZmlnXA0KCQktSSR7LkNVUkRJ
Un0vLi4vLi4vLi4vZ251L3Vzci5iaW4vY2MvY2NfdG9vbHMNCg0KIyAgICAg
ICBLRUVQIFRISVMgSU4gU1lOQyB3aXRoIHNyYy9nY2MvbGliL2xpYmdjYy9N
YWtlZmlsZSAhIQ0KdG0uaDoNCgllY2hvICcjaW5jbHVkZSAiJHtHQ0NfQVJD
SH0vJHtHQ0NfQVJDSH0uaCInCT4gJHsuVEFSR0VUfQ0KLmlmICR7R0NDX0FS
Q0h9ID09ICJpMzg2Ig0KCWVjaG8gJyNpbmNsdWRlICIke0dDQ19BUkNIfS9h
dHQuaCInCQk+PiAkey5UQVJHRVR9DQouZW5kaWYNCgllY2hvICcjaW5jbHVk
ZSA8ZnJlZWJzZC5oPicJCQk+PiAkey5UQVJHRVR9DQoJZWNobyAnI2luY2x1
ZGUgIiR7R0NDX0FSQ0h9L2ZyZWVic2QuaCInCQk+PiAkey5UQVJHRVR9DQou
aWYgJHtHQ0NfQVJDSH0gPT0gImkzODYiDQoJZWNobyAnI2luY2x1ZGUgIiR7
R0NDX0FSQ0h9L3BlcmZvcm0uaCInCQk+PiAkey5UQVJHRVR9DQouZW5kaWYN
CgllY2hvICcjaW5jbHVkZSA8ZnJlZWJzZC1uYXRpdmUuaD4nCQk+PiAkey5U
QVJHRVR9DQo=
--0-479365117-969036989=:78659--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0009152318270.78659-300000>