Skip to contentSkip to conversation

client: set rl_prompt after saving

PATCH In review Justin Bronder 2 participants 5 messages Oct 18, 2025 – Mar 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: set rl_prompt after saving

Readline 8.3 crashes when rl_save_prompt() is called without rl_set_prompt() being called first [1]. This means that interactive connmanctl immediately crashes upon invocation. As we're about to clear the line anyways, we can just set the buffer to an empty string as well.

Alternatively, I believe that both rl_set_prompt() and rl_replace_line() could be replaced by a call to rl_message("") but I don't want to expand the scope of this patch.

1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html

---
 client/input.c | 1 +
 1 file changed, 1 insertion(+)
client/input.c +1 -0
index 78319ff8..27c281d1 100644
@@ -62,6 +62,7 @@ void __connmanctl_save_rl(void)
 		saved_point = rl_point;
 		saved_line = rl_copy_text(0, rl_end);
 		rl_save_prompt();
+		rl_set_prompt("");
 		rl_replace_line("", 0);
 		rl_redisplay();
 	}
Signature · 1 line
2.51.0
#1 lore raw

||Shouldn't rl_set_prompt("") be called first as stated in your intro (and the link referenced)?

I only see __connmanctl_agent_mode setting the prompt as well, so if this function is not called before, there's still a save without a set before?

Quoted 28 lines · Justin Bronder

Readline 8.3 crashes when rl_save_prompt() is called without rl_set_prompt() being called first [1]. This means that interactive connmanctl immediately crashes upon invocation. As we're about to clear the line anyways, we can just set the buffer to an empty string as well.

Alternatively, I believe that both rl_set_prompt() and rl_replace_line() could be replaced by a call to rl_message("") but I don't want to expand the scope of this patch.

1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html

---
  client/input.c | 1 +
  1 file changed, 1 insertion(+)
client/input.c +1 -0
index 78319ff8..27c281d1 100644
@@ -62,6 +62,7 @@ void __connmanctl_save_rl(void)
  		saved_point = rl_point;
  		saved_line = rl_copy_text(0, rl_end);
  		rl_save_prompt();
+		rl_set_prompt("");
  		rl_replace_line("", 0);
  		rl_redisplay();
  	}
#2 lore raw
Quoted 2 lines · Thomas Bartosik

||Shouldn't rl_set_prompt("") be called first as stated in your intro (and the link referenced)?

As I understand it, rl_save_prompt() sets rl_prompt to NULL and we need to set it to something after that (by using rl_set_prompt()) prior to rl_redisplay() being called.

Quoted 35 lines

I only see __connmanctl_agent_mode setting the prompt as well, so if this function is not called before, there's still a save without a set before?

Quoted 28 lines · Justin Bronder

Readline 8.3 crashes when rl_save_prompt() is called without rl_set_prompt() being called first [1]. This means that interactive connmanctl immediately crashes upon invocation. As we're about to clear the line anyways, we can just set the buffer to an empty string as well.

Alternatively, I believe that both rl_set_prompt() and rl_replace_line() could be replaced by a call to rl_message("") but I don't want to expand the scope of this patch.

1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html

---
  client/input.c | 1 +
  1 file changed, 1 insertion(+)
client/input.c +1 -0
index 78319ff8..27c281d1 100644
@@ -62,6 +62,7 @@ void __connmanctl_save_rl(void)
  		saved_point = rl_point;
  		saved_line = rl_copy_text(0, rl_end);
  		rl_save_prompt();
+		rl_set_prompt("");
  		rl_replace_line("", 0);
  		rl_redisplay();
  	}
Signature · 1 line
Justin Bronder
#3 lore raw

Yes, sorry, I think you're right. I misread this, my bad!

Quoted 38 lines · Justin Bronder
Quoted 2 lines · Thomas Bartosik

||Shouldn't rl_set_prompt("") be called first as stated in your intro (and the link referenced)?

As I understand it, rl_save_prompt() sets rl_prompt to NULL and we need to set it to something after that (by using rl_set_prompt()) prior to rl_redisplay() being called.

Quoted 33 lines

I only see __connmanctl_agent_mode setting the prompt as well, so if this function is not called before, there's still a save without a set before?

Quoted 28 lines · Justin Bronder

Readline 8.3 crashes when rl_save_prompt() is called without rl_set_prompt() being called first [1]. This means that interactive connmanctl immediately crashes upon invocation. As we're about to clear the line anyways, we can just set the buffer to an empty string as well.

Alternatively, I believe that both rl_set_prompt() and rl_replace_line() could be replaced by a call to rl_message("") but I don't want to expand the scope of this patch.

1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html

---
   client/input.c | 1 +
   1 file changed, 1 insertion(+)
client/input.c +1 -0
index 78319ff8..27c281d1 100644
@@ -62,6 +62,7 @@ void __connmanctl_save_rl(void)
   		saved_point = rl_point;
   		saved_line = rl_copy_text(0, rl_end);
   		rl_save_prompt();
+		rl_set_prompt("");
   		rl_replace_line("", 0);
   		rl_redisplay();
   	}
#4 lore raw
In reply to Justin Bronder
Quoted 10 lines · Justin Bronder

Readline 8.3 crashes when rl_save_prompt() is called without rl_set_prompt() being called first [1]. This means that interactive connmanctl immediately crashes upon invocation. As we're about to clear the line anyways, we can just set the buffer to an empty string as well.

Alternatively, I believe that both rl_set_prompt() and rl_replace_line() could be replaced by a call to rl_message("") but I don't want to expand the scope of this patch.

1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html

Hi,

Just checking in on if this patch is appropriate for merging or if outside contributions are not accepted? I assumed that connmanctl immediately segfaulting with readline 8.3 would be something that would be fixed on a bit shorter of a timeline.

I'm sitting on changes that I'd like to push up to openSUSE, but if this project isn't supported there, I can just drop them.

Best,

Signature · 1 line
Justin Bronder