From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Boehm, Hans" Newsgroups: gmane.comp.programming.garbage-collection.boehmgc,gmane.lisp.guile.bugs Subject: RE: pthreads and libgc Date: Sun, 20 Mar 2011 03:51:05 +0000 Message-ID: <238A96A773B3934685A7269CC8A8D04272EFCB8D2E@GVW0436EXB.americas.hpqcorp.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1300593283 23387 80.91.229.12 (20 Mar 2011 03:54:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 Mar 2011 03:54:43 +0000 (UTC) Cc: bug-guile , "gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org" To: Andy Wingo , Ivan Maidanski Original-X-From: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org Sun Mar 20 04:54:39 2011 Return-path: Envelope-to: gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org Original-Received: from gundega.hpl.hp.com ([192.6.19.190]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q19iw-0005Vd-I8 for gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org; Sun, 20 Mar 2011 04:54:38 +0100 Original-Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by gundega.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id p2K3sAkH019507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 19 Mar 2011 20:54:10 -0700 Original-Received: from napali.hpl.hp.com (napali.hpl.hp.com [15.4.89.123]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id p2K3s9rn019250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 19 Mar 2011 20:54:09 -0700 Original-Received: from napali.hpl.hp.com (localhost.hpl.hp.com [127.0.0.1]) by napali.hpl.hp.com (8.13.4/8.13.4/HPL-PA send-recv-int) with ESMTP id p2K3pNcq002510; Sat, 19 Mar 2011 19:51:25 -0800 Original-Received: from G5W2206G.americas.hpqcorp.net (g5w2206g.atlanta.hp.com [16.228.43.185]) by napali.hpl.hp.com (8.13.4/8.13.4/HPL-PA send-recv-int) with ESMTP id p2K3pJMg002507 for ; Sat, 19 Mar 2011 19:51:20 -0800 Original-Received: from G3W0632.americas.hpqcorp.net (16.233.58.62) by G5W2206G.americas.hpqcorp.net (16.228.43.185) with Microsoft SMTP Server (TLS) id 14.1.270.1; Sun, 20 Mar 2011 03:51:13 +0000 Original-Received: from GVW0436EXB.americas.hpqcorp.net ([16.234.32.154]) by G3W0632.americas.hpqcorp.net ([16.233.58.62]) with mapi; Sun, 20 Mar 2011 03:51:07 +0000 Thread-Topic: [Gc] pthreads and libgc Thread-Index: AcvmjYlz9GySCBO9S5WmAw6ufg7wCQAIOzMg In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US X-MIME-Autoconverted: from quoted-printable to 8bit by napali.hpl.hp.com id p2K3pJMg002507 X-BeenThere: gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Garbage Collector bugs/discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org Errors-To: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org X-Scanned-By: MIMEDefang 2.71 on 15.0.48.190 Xref: news.gmane.org gmane.comp.programming.garbage-collection.boehmgc:4439 gmane.lisp.guile.bugs:5351 Archived-At: > From: Andy Wingo > ... > [From Ivan:] > > But, anyway, it is recommended to initialize GC explicitly (i.e. by > > GC_INIT), so placing GC_INIT() (together with > > GC_set_all_interior_pointer) to the beginning of your main() should > be > > the best way out. > > We can add some documentation to this regard in the manual, if needed. > But is there no way to get around this, and do the right thing? For > example, to avoid implicit GC initialization in response to a > pthread_create. > The problem is that GC_pthread_create needs to allocate memory, and relies on some other GC state. Hence the GC must have been initialized for it to work. For newer collectors, it might be possible to instead arrange for pthread_create not to be redirected to GC_pthread_create, and for threads that need to be known to the GC to register themselves. I haven't thought through whether that might be feasible here. Another imperfect solution might be to set all_interior_pointers and probably call GC_INIT in a constructor, either a C++ constructor, or a C function that's suitably attributed. That still fails if other constructors run into this problem before our constructor runs. Hans