From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Gran Newsgroups: gmane.lisp.guile.devel Subject: Re: allocation within critical sections Date: Fri, 17 Feb 2012 02:32:03 -0800 (PST) Message-ID: <1329474723.3480.YahooMailNeo@web37906.mail.mud.yahoo.com> References: <87sjijzulh.fsf@pobox.com> <87d39e5uv1.fsf@gnu.org> <874nuqpg6k.fsf@pobox.com> <1329446762.84665.YahooMailNeo@web37906.mail.mud.yahoo.com> <87vcn5ooxp.fsf@pobox.com> Reply-To: Mike Gran NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1329474749 31397 80.91.229.3 (17 Feb 2012 10:32:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 17 Feb 2012 10:32:29 +0000 (UTC) Cc: =?iso-8859-1?Q?Ludovic_Court=E8s?= , "guile-devel@gnu.org" To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Feb 17 11:32:25 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RyL72-0000jr-JR for guile-devel@m.gmane.org; Fri, 17 Feb 2012 11:32:24 +0100 Original-Received: from localhost ([::1]:58043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyL6z-0001S6-P4 for guile-devel@m.gmane.org; Fri, 17 Feb 2012 05:32:21 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyL6s-0001Rq-VH for guile-devel@gnu.org; Fri, 17 Feb 2012 05:32:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyL6j-00048j-Ie for guile-devel@gnu.org; Fri, 17 Feb 2012 05:32:14 -0500 Original-Received: from nm8-vm0.bullet.mail.ac4.yahoo.com ([98.139.52.230]:29985) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RyL6j-00048K-ED for guile-devel@gnu.org; Fri, 17 Feb 2012 05:32:05 -0500 Original-Received: from [98.139.52.189] by nm8.bullet.mail.ac4.yahoo.com with NNFMP; 17 Feb 2012 10:32:03 -0000 Original-Received: from [98.139.52.150] by tm2.bullet.mail.ac4.yahoo.com with NNFMP; 17 Feb 2012 10:32:03 -0000 Original-Received: from [127.0.0.1] by omp1033.mail.ac4.yahoo.com with NNFMP; 17 Feb 2012 10:32:03 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 908236.49802.bm@omp1033.mail.ac4.yahoo.com Original-Received: (qmail 9314 invoked by uid 60001); 17 Feb 2012 10:32:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1329474723; bh=/E4Ox0BqzYWnNPc9MH0XbKBSJhUdg18mKj81m9lpLo0=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=NfPAsVbpclomNmCYsJTFvTzZDhcIJ1tz0oB88CYt9giy8sgRYDhhbNI5tfsBRgeRTmxhYLUjHtiOPgBXjO/jUNqVUyCjFDmHtmplXQ33iO9iKid8vQ5zOJCP7RsElQwsCWLZPCkFXDbsY+C4bV8pJmDrD4WDwqbVAxLkBuhkGNg= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=5cKOAyhaC0Xhu7BF4O4n+BK8Hm0r93UD+5vekeduHzszbOmenkQxLVe6H+7+cFAX2iDBKLMud/iynZsvgX+b70tuyOP2AAuYFkXjeRHEtG863+zZVoySD7MlxMU69xGYv3nrXMyz56ywcbph5NMPFyWS5MIDZzoDk/VRHFYRYmY=; X-YMail-OSG: WsJj2vMVM1k34CgBO.XkgtzzJfHwlALOt4F.Jv69qV.OQPB eSqnrZDOhyZobub_fd5Nea5nWh767AtX1oB1onrmtBKpuGiY12AuNguDg5Zq 2xRI_FfjNyFb2Z9f8.9wVxDnc.prj469Q7grNnemO4lOivO_0NFGhWheN2cr FKKuBK20DvvLnzIvEUS2ZXMQbAURiCPiJtbTHK9IbBh.lXE16jYBgBtNRDx5 yRSAVCfv465ZZVU96tV8pZXaMvjU_f5foBcQoJWvk_F8C2m7Ij2jc2LIH6wX Xf9Jk.QiLQHaAXe3Nk1iTaguN5WcPb.VmPIJ2700Wj6.m9ta6hXt54G.0q.0 ipAL4fbRxOO1jkH0EXwNL7Uq3xMTC.cu7aAtTTlgIhYxGR1mY6SAHDEvrKLx ehYVqxVuhGBsoeNX1APwOIw3yK1mEzSylR4fFswc36gXD23XJWkKeRUJuMIz .Y2pC3ZME074K8OlYIpc- Original-Received: from [71.130.221.176] by web37906.mail.mud.yahoo.com via HTTP; Fri, 17 Feb 2012 02:32:03 PST X-Mailer: YahooMailWebService/0.8.116.338427 In-Reply-To: <87vcn5ooxp.fsf@pobox.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.139.52.230 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13884 Archived-At: > From: Andy Wingo =0A=A0>> As an aside, I can get a simi= lar sort of deadlock during garbage=0A>> collection of SMOBs if my smob_fr= ee function calls a scheme function.=0A>> But the manual does note that yo= u should not call any functions in =0A>> SMOB GC finalizers, so that would= n't happen if I actually followed the=0A>> instructions.=0A> =0A> Any Sche= me function?=A0 With Guile 2.0?=A0 It should be possible to call=0A> arbitr= ary code from finalizers, if we call finalizers from a separate=0A> thread.= =0A=0AHappens with any scheme function called in a SMOB's finalizer, with G= uile 2.0,=0Ain a memory constrained situation.=0A=A0=0AFor example, Guile-n= curses has a SMOB finalizer that calls a guardian previously=0Acreated with= 'make-guardian'.=A0 This is in the
SMOB.=0A=A0=0AHere's the order o= f operations=0A=0A- GC_invoke_finalizers calls the SMOB's free funct= ion 'gc_form_free'=0A=0A- my SMOB finalizer gc_form_free calls=A0a guardian= procedure with=0Ascm_call_0 remove the guardian=0A=0A- That kicks off a ne= w scm_c_vm_run then calls scm_i_smob_apply_trampoline=0A=A0=0A- there is so= me mutex in the trampoline process=0A=0A- A new trampoline causes a memory = allocation with scm_hash_fn_create_handle_x=0A=0A- Since memory is low, it = calls GC_invoke_finalizers=0A=0A- This ends up making a call to=A0my finali= zer=A0gc_form_free.=A0 (Don't know if this=0Ais a recursive call to my SMOB= finalizer or if it is a call to a different=0A's SMOB finalizer, sin= ce I have many forms)=0A=A0=0A- the gc_form_free calls a guardian with scm_= call_0=0A=A0=0A- which kicks off a new scm_c_v_run=0A=0A- which eventually = gets you to scm_i_smob_apply_trampoline again=0A=0A- which leads to a recur= sive mutex lock in scm_i_smob_apply_trampoline=0A=A0=0A-Mike