'read_char' in src/keyboard.c returns -1 to indicate the end of a keyboard macro. This case is supposed to be propagated via 'read_key_sequence' and 'command_loop_2' to 'Fexecute_kbd_macro'. But 'read_key_sequence' is not the only caller of 'read_char'. It is also called by 'read-event' and similar lisp functions, and in that case, the magic C return value -1 is wrongly propagated to the lisp caller.  There are at least workarounds for this bug in at least three lisp modules in the code base, in subr.el, in calc and most recently added in dbus.el (bug #62018), see the attached patches. These patches are supposed to resolve the underlying issue, and then remove the workarounds.