From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id eJfGOIDKnWUVBAEAkFu2QA (envelope-from ) for ; Tue, 09 Jan 2024 23:36:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id EKrTMIDKnWVjaQEAe85BDQ (envelope-from ) for ; Tue, 09 Jan 2024 23:36:48 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=HUyOCAbY; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704839808; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=TxnMbEJQxoPopTyZPjH+rbVd0QA/9E0Kv+CktkCNLXo=; b=LHmvNeNYfbXkegvmkQCLmZcERGF3IsJWpQX7IOma35rDAPym4ELlChCRrjegOwoUErDdgn IOihUq9pjJKgGWaNSMIcr8qAHZXmAYuS+CHqOIEBzOMbST8QNrBEljGbKkyWoG6s62w/mP Hv7WJzOteO7QS71Mh+VMOOYfXPIhKXPqCOfvGZ14XzPT17NURWEf7tFRoYFLYVj8YoCrjx 5cKkr44tQoxdCvuQcacsmTJCRXvZkwqwkn5Q8kAusmCkxLsF45RTNeFylnMH/ioS0ftdPF tMakKxNmngOb14l09dpAycCdqigPTTPzwFE3zqL2obAgIQY6asUZPpEI1VC36Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704839808; a=rsa-sha256; cv=none; b=HJuyDKKXhNfKzWeBej7Nw8wRXGniwIwVbgq5461+xvB0N7MV10hsurWeg+yMLM0B3w/XMW 5am9VDIkpzRzOvaZCw8JTHRT8o/VvpqFhLtdQ6idsPMy9+N8QQ/1555pMs3AoRHSUkDpxW 72p3DOkAENDla07qmKHPF1QVE0yDKxenBDeOQTMW+/ciC9SDTUMmKGjlOYXOeWTkzOX4Et L+dIcfHFlsf2ByPngHqOhqJbY6NdW6F7oVPJV/SF+kmk2PPwuTrlM2IqgZ6OOez8aeU+Ev sjaFAfw+xCdTlaU3M/VftRcv7cs/aHyVz/6lwadZCWy0oQR99nf4JJzMougxeQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=HUyOCAbY; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 73A8F3A022 for ; Tue, 9 Jan 2024 23:36:48 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNKhg-0001sC-BC; Tue, 09 Jan 2024 17:36:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNKhe-0001rI-4E for guix-devel@gnu.org; Tue, 09 Jan 2024 17:36:10 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNKhd-0007xA-SA; Tue, 09 Jan 2024 17:36:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=TxnMbEJQxoPopTyZPjH+rbVd0QA/9E0Kv+CktkCNLXo=; b=HUyOCAbY2aS1DCMWhNtf Nylar+/6p+Hu9cEmMD0tFM6uLIveCVygwuiFdB56eAin7KBTRgdptVG/TJEUwl1HkGw6EBddu1vH2 QyDjbFux84C6msnXdksgBYrxFm1TBSSjk4EbUfKv4NuFRgWvyJKw4ijMckKOzpqZ4HNDcdrpf5aMY umFHlrPD8qliXiFEtSsRvG/N9m6zI1+7PBedqbLqDTvQU6yGJImwtLLxGsTpa0zEihM4tT0JoSvdi BS8dzr1GBVx5fK1asuofzyMNEzx+AJqEoQwICz9gLWUZhSyI5hvtB8OPaME20Ty0+liJfdxxl+MTN LvAV3u68qdEeqw==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Justin Veilleux Cc: guix-devel@gnu.org Subject: Re: using shepherd's (shepherd service repl) in guix system In-Reply-To: <87r0jfliki.fsf@cock.li> (Justin Veilleux's message of "Thu, 21 Dec 2023 09:46:21 -0500") References: <87r0jfliki.fsf@cock.li> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: =?utf-8?Q?D=C3=A9cadi?= 20 =?utf-8?Q?Niv=C3=B4se?= an 232 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Van X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 09 Jan 2024 23:36:06 +0100 Message-ID: <87il42xhgp.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.52 X-Spam-Score: -9.52 X-Migadu-Queue-Id: 73A8F3A022 X-Migadu-Scanner: mx11.migadu.com X-TUID: xyQ2bZGHvHva Hello, Justin Veilleux skribis: > Hi. I thought it would be interesting to have a shepherd service run a > repl like in > https://www.gnu.org/software/shepherd/manual/html_node/REPL-Service.html. > Since there is no shepherd repl service in a (gnu services *) module, I > created a shepherd-service-type and shepherd-service (I copied the code > from `(shepherd service repl)`) Another option is to turn it on only when you need it, along these lines: herd eval root '(begin (use-modules (shepherd service repl)) (register-services (list (repl-service))))' herd start repl (Granted, it=E2=80=99s not as convenient.) > The `reconfigure` runs and after fiddling with permission bits and > connecting to the socket through emacs and geiser (like in the manual), > I am able to execute expressions such as `(+ 2 2)` and `(display > "test\n")` and everything works as expected. > > However, when I try to evaluate `lookup-service` (without calling it), > the repl gets stuck in an infinite loop of > >> scheme@(shepherd-user) [1]> While reading expression: >> Attempt to suspend fiber within continuation barrier Yes: --8<---------------cut here---------------start------------->8--- scheme@(shepherd-user)> (+ 2 3) $6 =3D 5 scheme@(shepherd-user)> (lookup-service 'repl) ;;; socket:56:1: warning: possibly unbound variable `lookup-service' ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: lookup-service Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(shepherd-user) [1]> While reading expression: Attempt to suspend fiber within continuation barrier scheme@(shepherd-user) [1]> While reading expression: Attempt to suspend fiber within continuation barrier --8<---------------cut here---------------end--------------->8--- The problem here is that the exception is raised C code (in libguile/modules.c, then indirectly calling =E2=80=98scm_error=E2=80=99), w= hich makes it a =E2=80=9Ccontinuation barrier=E2=80=9D (meaning that it prevents Fibers f= rom switching contexts among fibers in the shepherd process, hence the error above.) The same goes for many exceptions launched from libguile primitives (for instance division by zero), but it=E2=80=99s fine if we take a C-free path: --8<---------------cut here---------------start------------->8--- scheme@(shepherd-user)> (raise-exception 123) ice-9/boot-9.scm:1685:16: In procedure raise-exception: Throw to key `%exception' with args `(123)'. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(shepherd-user) [1]> ,bt In ice-9/boot-9.scm: 1685:16 0 (raise-exception _ #:continuable? _) scheme@(shepherd-user) [1]> ,q scheme@(shepherd-user)> (+ 1 2) $31 =3D 3 --8<---------------cut here---------------end--------------->8--- And of course it=E2=80=99s all good when there are no exceptions: --8<---------------cut here---------------start------------->8--- scheme@(shepherd-user)> ,use(shepherd service) scheme@(shepherd-user)> (lookup-service 'repl) $12 =3D #< 7fbd052fabd0> scheme@(shepherd-user)> (lookup-service 'root) $13 =3D #< 7fbd056fd1c0> scheme@(shepherd-user)> (service-status $12) $14 =3D running scheme@(shepherd-user)> (service-status-changes $12) $15 =3D ((running . 1704838523) (starting . 1704838523)) --8<---------------cut here---------------end--------------->8--- This is undoubtedly a shortcoming for the REPL. The solution here would be to arrange for Guile primitives to raise exceptions through a different path somehow. Not sure how. Thanks, Ludo=E2=80=99.