arXiv:2608.29225cs.PLAug 2026

Manuscript Offprint

arXiv:2608.29225

Fine-grained Causal Reversibility for Asynchronous Channel-based Programming

Shunya Oguchi, Shoji Yuen, Nobuko Yoshida, Claudio Antares Mezzina

Shunya Oguchi 1^{1}, Shoji Yuen 1^{1}[0000-0003-2642-0647],

Nobuko Yoshida 2^{2}[0000-0002-3925-8557], and

Claudio Antares Mezzina 3^{3}[0000-0003-1556-2623]

1^{1} Graduate School of Informatics, Nagoya University, Japan

{oguchi321,yuen}@sqlab.jp

2^{2} Department of Computer Science, University of Oxford, England, United Kingdom

nobuko.yoshida@cs.ox.ac.uk

3^{3} University of Bari Aldo Moro, Italy

claudio.mezzina@uniba.it

Abstract. Causal reversibility has emerged as an effective technique for debugging concurrent systems. In particular, rolling back and replaying a concurrent program with causal consistency has been found very helpful in debugging concurrency bugs. In channel-based communication, queue ordering creates dependencies that prevent causally independent actions from being rolled back and replayed. To enable efficient rollback and replay without being constrained by queue dependencies, it is necessary to analyse causal dependencies between messages in queues and reorder independent messages. This paper presents revGo, a core of the Go programming language assuming unbounded asynchronous channels. Our rollback-and-replay semantics allows us to reorder messages in the queue if they are not causally related in the forward execution. It is shown that reordering independent messages generates no configuration with non-reachable processes. By reordering independent messages, rollback and replay are implementable with minimality by assigning unique keys to communications.

Keywords: Golang · Concurrency · Reversible computation · Causal-consistent reversibility · Channel communication · Rollback and replay

1 Introduction

Programming distributed systems is inherently challenging due to the presence of concurrency, partial failures, and unpredictable communication delays. Even when individual components are simple, their interactions can lead to complex global behaviours that are difficult to reason about and even harder to debug.

∗^{*} An extended version of the paper accepted at ICTAC 2026. This version includes complete proofs and additional technical material.

Shunya Oguchi et al.

Modern programming languages increasingly provide concurrency and communication primitives to help developers structure distributed programs, but these abstractions do not eliminate the fundamental difficulty of understanding and diagnosing erroneous behaviours that arise from concurrent interactions.

Such erroneous behaviours are known as concurrency bugs [12]. Concurrency bugs are particularly problematic because they are typically non-deterministic and hard to reproduce: rerunning the program may not trigger the same faulty behaviour, and small changes in timing or load may hide the bug altogether. Undoing an action in a concurrent or distributed setting should not arbitrarily erase unrelated progress; rather, it should affect only those actions that are causally dependent on it. This observation is at the basis of causally consistent reversible debugging [4,6], which preserves the causal structure of concurrent computations during rollback and replay. In the setting of actor-based languages, several reversible debuggers have been developed for message-passing systems, notably for Erlang [18,7]. Among these, CauDEr [7] supports causal-consistent rollback and replay of concurrent executions in an actor system. CauDEr exploits Erlang's asynchronous message-passing semantics and mailbox-based communication to track causal dependencies between send and receive actions, enabling selective undo while preserving causal correctness. While communications in Erlang are by the mailbox, Go [2] processes communicate by channel queues. Channel queues have the dependencies due to message ordering in channels, which do not exist in the Erlang semantics. To handle this dependency of message queues, rollback and replay require safely reordering independent messages in channel queues.

This work introduces revGo, a calculus with a rollback-and-replay semantics that assumes unbounded asynchronous channels and abstracts away from Go's bounded and synchronized channels, aiming at supporting effective reversible debugging for concurrent and distributed Go programs. Unlike message-passing communication in actor-based models, channel-based communication [11] introduces additional causal structures due to channel queues.

By enriching Go’s operational semantics with histories for processes and channels, revGo enables not only reversible executions but also selective rollback-and-replay of executions, allowing developers to focus on the actions relevant to a failure. In revGo, dependencies among messages in channel queues must be considered when reversing executions. In rollback-and-replay semantics in particular, messages in channel queues that are irrelevant to a failure have to be abstracted away.

The following example illustrates the potential uncertainty of channel-based communications when a channel queue is shared among multiple threads. The behaviour is highly dependent on the runtime, such as goroutine scheduling and channel queue capacities.

Example 1.

func S(c chan int, n int) { c <- n; S(c, n) } func R(c chan int) { n := <-c; if 2/n == 2 { R(c) } } func main() { c := make(chan int, *); go S(c, 0); go S(c, 1); R(c) }

Fig. 1: A program example where a division-by-zero error may arise.

In the example, traditional debugging techniques cannot easily isolate the faulty interaction, since replaying the program may lead to a different message ordering, and stepping backwards would undo many actions that are causally independent of the failure. The challenge is therefore to identify and undo only the concurrent actions that caused main to receive 0.

Our main contribution is to introduce a causally-consistent equivalence over channel queues. The semantics identifies channel queues via equivalence classes, e.g. all possible message reorderings. To ensure that message reorderings are sound with respect to reachability, we attach a unique key [16,15] to each message to track independence in behaviour. As long as communication actions involving the keys are independent, the messages are independent. In the above example, all messages with 1 are independent of those with 0 since the two processes S are independent. Due to independence, even if many messages with 1 are communicated before or after the message with 0 that caused the error, all the messages with 1 are irrelevant to the error.

It is shown that reordering independent messages does not generate unreachable processes, thereby establishing the soundness of the reordering technique. This property enables greater flexibility in managing channel queues during reversible debugging to reach a target event. Under the reordering of independent messages, the rollback-and-replay semantics exhibits both soundness and minimality in reaching a rollback action, as observed in Erlang [5].

Related Work: The idea of exploiting causal-consistent reversible semantics for debugging purposes was first introduced in [4] in the context of a subset of the Oz programming language [17]. This approach was subsequently developed and refined for Erlang, leading to the implementation of the CauDEr reversible debugger [7,8,5,9], which supports causal-consistent rollback and replay of concurrent executions in actor-based systems. We depart from these works in several respects. Although the language considered in [4] features channel-based communication, its reversible semantics does not support queue reordering, and thus cannot abstract away from causally independent message orderings. In contrast, CauDEr targets Erlang, an actor-based language with mailbox semantics, where message ordering does not play the same causal role as in channel-based systems. Our approach instead focuses on explicit FIFO channels, where message ordering is an essential part of the causal structure, and introduces a formal mechanism to safely reorder causally independent messages. [13] studies reversible semantics for asynchronous multiparty session types with higher-order messages over a single global queue.

Shunya Oguchi et al.

RevMiGo[15] proposed by the authors gives a reversible semantics by constructing a graph structure to store the dependency among communications. The graph is globally shared by all processes, whereas this paper proposes a semantics different from RevMiGo, where the dependency is stored in each process and each channel queue in a distributed manner.

Paper Organisation Section 2 introduces revGo as a core language with channel-based communication and presents its reversible operational semantics with causal consistency. Section 3 presents a rollback-and-replay semantics, and Section 4 discusses key reversible properties of this semantics and its usefulness for reversible debugging, based on soundness and minimality. Section 5 concludes.