public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/expect] f45: Fix segfault on Ctrl-C when tclreadline is loaded
@ 2026-08-31  9:24 Vitezslav Crhonek
  0 siblings, 0 replies; only message in thread
From: Vitezslav Crhonek @ 2026-08-31  9:24 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/expect
Branch : f45
Commit : cc0a6f19877597fa98ff277646747b3391388b32
Author : Vitezslav Crhonek <vcrhonek@redhat.com>
Date   : 2026-08-31T11:24:46+02:00
Stats  : +72/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/expect/c/cc0a6f19877597fa98ff277646747b3391388b32?branch=f45

Log:
Fix segfault on Ctrl-C when tclreadline is loaded

---
diff --git a/expect-5.45.4-exit-sighandler.patch b/expect-5.45.4-exit-sighandler.patch
new file mode 100644
index 0000000..da4c127
--- /dev/null
+++ b/expect-5.45.4-exit-sighandler.patch
@@ -0,0 +1,64 @@
+diff -up expect5.45.4/exp_command.c.exit-sighandler expect5.45.4/exp_command.c
+--- expect5.45.4/exp_command.c.exit-sighandler	2026-08-18 10:47:10.722479406 +0200
++++ expect5.45.4/exp_command.c	2026-08-18 13:01:09.524036587 +0200
+@@ -2516,6 +2516,30 @@ Exp_ExitObjCmd(
+     }
+
+     /*
++     * When exit is called from a signal trap handler (e.g., the default
++     * SIGINT handler runs "exit 130" on Ctrl-C), we may be deep inside
++     * Tcl's event loop via Tcl_AsyncInvoke.  Calling Tcl_Exit in that
++     * context crashes because FinalizeThread tears down the event system
++     * (epoll file descriptors, channel handlers) while it is still in use
++     * on the call stack.  Restore the terminal and exit immediately.
++     */
++    if (exp_in_signal_handler()) {
++	if (exp_onexit_action) {
++	    Tcl_GlobalEval(interp, exp_onexit_action);
++	}
++
++	if (!exp_disconnected
++	    && !exp_forked
++	    && (exp_dev_tty != -1)
++	    && isatty(exp_dev_tty)) {
++	    if (exp_ioctled_devtty) {
++		exp_tty_set(interp, &exp_tty_original, exp_dev_tty, 0);
++	    }
++	}
++	_exit(value);
++    }
++
++    /*
+      * Restore previous definition of close.  Needed when expect is
+      * dynamically loaded after close has been redefined
+      * e.g.  the virtual file system in tclkit
+diff -up expect5.45.4/exp_command.h.exit-sighandler expect5.45.4/exp_command.h
+--- expect5.45.4/exp_command.h.exit-sighandler	2026-08-18 10:47:10.721479410 +0200
++++ expect5.45.4/exp_command.h	2026-08-18 10:51:06.973377387 +0200
+@@ -249,6 +249,7 @@ EXTERN int		exp_2tcl_returnvalue (int);
+ EXTERN void		exp_rearm_sigchld (Tcl_Interp *);
+ EXTERN int		exp_string_to_signal (Tcl_Interp *,char *);
+
++EXTERN int		exp_in_signal_handler (void);
+ EXTERN char *exp_onexit_action;
+
+ #define exp_new(x)	(x *)malloc(sizeof(x))
+diff -up expect5.45.4/exp_trap.c.exit-sighandler expect5.45.4/exp_trap.c
+--- expect5.45.4/exp_trap.c.exit-sighandler	2026-08-18 10:47:10.720479415 +0200
++++ expect5.45.4/exp_trap.c	2026-08-18 10:50:59.578411909 +0200
+@@ -77,6 +77,15 @@ static int current_sig = NO_SIG;
+ int exp_nostack_dump = FALSE;	/* TRUE if user has requested unrolling of */
+ 				/* stack with no trace */
+
++/* Return whether we are currently inside a signal trap handler.
++ * This is used by Exp_ExitObjCmd to avoid calling Tcl_Exit from within
++ * event processing (via Tcl_AsyncInvoke), which would crash because
++ * Tcl_Exit tears down the event system while it is still in use. */
++int
++exp_in_signal_handler(void)
++{
++	return current_sig != NO_SIG;
++}
+
+
+ /*ARGSUSED*/

diff --git a/expect.spec b/expect.spec
index 0f1424e..96bfcb1 100644
--- a/expect.spec
+++ b/expect.spec
@@ -5,7 +5,7 @@
 Summary: A program-script interaction and testing utility
 Name: expect
 Version: %{majorver}
-Release: 33%{?dist}
+Release: 34%{?dist}
 License: LicenseRef-Fedora-Public-Domain
 URL: https://core.tcl.tk/expect/index
 Source: http://downloads.sourceforge.net/%{name}/%{name}%{version}.tar.gz
@@ -53,6 +53,8 @@ Patch17: expect-5.45.4-tcl9-eval-tokens.patch
 Patch18: expect-5.45.4-tcl9-alloc.patch
 # Patch19: update int to Tcl_Size for tcl9 API changes, fix function signatures
 Patch19: expect-5.45.4-tcl9-size.patch
+# Patch20: fix segfault when Ctrl-C is pressed with tclreadline loaded, rhbz#2497646
+Patch20: expect-5.45.4-exit-sighandler.patch
 # examples patches
 # Patch100: changes random function
 Patch100: expect-5.32.2-random.patch
@@ -128,6 +130,7 @@ of expectk.
 %patch -P17 -p1 -b .tcl9-eval-tokens
 %patch -P18 -p1 -b .tcl9-alloc
 %patch -P19 -p1 -b .tcl9-size
+%patch -P20 -p1 -b .exit-sighandler
 # examples fixes
 %patch -P100 -p1 -b .random
 %patch -P101 -p1 -b .mkpasswd-dash
@@ -219,6 +222,10 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/libexpect%{version}.so
 %{_mandir}/man1/tknewsbiff.1*
 
 %changelog
+* Mon Aug 31 2026 Vitezslav Crhonek <vcrhonek@redhat.com> - 5.45.4-34
+- Fix segfault on Ctrl-C when tclreadline is loaded
+  Resolves: #2497646
+
 * Wed Jul 15 2026 Fedora Release Engineering <releng@fedoraproject.org> - 5.45.4-33
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-31  9:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31  9:24 [rpms/expect] f45: Fix segfault on Ctrl-C when tclreadline is loaded Vitezslav Crhonek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox