From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id A1CB87F891 for ; Thu, 20 Mar 2014 06:30:01 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of ygrek@autistici.org) identity=pra; client-ip=82.221.99.153; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ygrek@autistici.org"; x-sender="ygrek@autistici.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of ygrek@autistici.org designates 82.221.99.153 as permitted sender) identity=mailfrom; client-ip=82.221.99.153; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ygrek@autistici.org"; x-sender="ygrek@autistici.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@diserzione.investici.org designates 82.221.99.153 as permitted sender) identity=helo; client-ip=82.221.99.153; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ygrek@autistici.org"; x-sender="postmaster@diserzione.investici.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIEAKh7KlNS3WOZnGdsb2JhbABaxmYleBYOAQEBAQEICwkJFCiCHQgBAQEDAUABATcBBAsLCRglD0gZhXaBewysV4RVAQWechEGjmUHgn6BOolUhgd6hgyBaQGGTI8e X-IPAS-Result: AtIEAKh7KlNS3WOZnGdsb2JhbABaxmYleBYOAQEBAQEICwkJFCiCHQgBAQEDAUABATcBBAsLCRglD0gZhXaBewysV4RVAQWechEGjmUHgn6BOolUhgd6hgyBaQGGTI8e X-IronPort-AV: E=Sophos;i="4.97,692,1389740400"; d="asc'?scan'208";a="63722193" Received: from diserzione.investici.org ([82.221.99.153]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 20 Mar 2014 06:29:58 +0100 Received: from [82.221.99.153] (diserzione [82.221.99.153]) (Authenticated sender: ygrek@autistici.org) by localhost (Postfix) with ESMTPSA id 7C86E18133C for ; Thu, 20 Mar 2014 05:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1395293394; bh=UuolUsahW8+s72QYX3gqW/C96ifUMlhQ4I6Hxyjc938=; h=Date:From:Cc:Subject:In-Reply-To:References; b=G0Xfo30BlEWrBiIThEx0WxZf+ybuczh4TmSNn7CTbbgnx1lMgsaZQTS8ClCR1j5Go /9ddgL7Ae2bICduLvpTXeJjsbTkIkIfMvUZOITuo4g2mnInr8bIdSCP3+hB29ZOXrU iRAzkzoJuGmq9M7GuG0sbXeAkLxirEtMuXVotuZ4= Date: Thu, 20 Mar 2014 13:29:41 +0800 From: ygrek Cc: caml-list Message-ID: <20140320132941.09aa04f4@kiwi.local.tld> In-Reply-To: <1395271296.27397.11.camel@zotac> References: <532A0A5E.6070107@fugmann.net> <1395271296.27397.11.camel@zotac> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/SCfE7lyDqpqiGu/ejc4yL5S"; protocol="application/pgp-signature" Subject: Re: [Caml-list] Bug when printing from signal handlers? --Sig_/SCfE7lyDqpqiGu/ejc4yL5S Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 20 Mar 2014 00:21:36 +0100 Gerd Stolpmann wrote: > OCaml printing isn't printf in C - it calls directly write() and is > always possible. OCaml signal handlers aren't signal handlers from the C > viewpoint: When the signal is caught, a flag in the OCaml runtime is > set, and this flag is regularly checked by the running code. (I.e. what > you suggest is already done in the runtime.) >=20 > So, I'd say this is a bug in the OCaml runtime. The bug goes away when > you print to a different channel from the signal handler, so it looks > like channels and signal handlers have some unwanted effect on each > other. stdlib channels are protected with non-recursive mutex, so the deadlock on = re-entrant invocation is guaranteed.=20 AFAICS runtime system tries to execute signal immediately (see signal_handl= e in asmrun/signals_asm.c) and if that is not possible - records signal for later execution. Anyway doing complex stuff in signal handler is a bad idea, because even wi= th delayed processing (when things are safe from the libc point of view) the points of invocation of OC= aml signal handler are scattered all around the program (allocation sites) and any OCaml resource that doesn= 't support reentrant usage will break the program. --=20 --Sig_/SCfE7lyDqpqiGu/ejc4yL5S Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlMqfMUACgkQY0a5RXCNWgwjWACg6fUR6i2eET0N9Yjevi/ghQmm mvoAn0Qkdu70Vued4f5jWzK1+UKG1dhA =5GoX -----END PGP SIGNATURE----- --Sig_/SCfE7lyDqpqiGu/ejc4yL5S--