This is backtraces when this problem happens:

By using gdb to debug the problem but cannot get helpful information since it's using compiled binary files of Emacs packages.
(gdb) step
Single stepping until exit from function F707974686f6e2d6e61762d656e642d6f662d73746174656d656e74_python_nav_end_of_statement_0,
which has no line number information.
Finally, I gave up and used workarounds to add or fix docstring:
- py-pyment-region command from the package py-pyment
- replace non-standard docstring by command anzu-query-replace from the package anzu
Besides, in Emacs 28.1 + gcc/9.5.0_jit, typing single quote or typing double quotes before single quote will cause this problem.
Typing double quotes in blank line or not before single quote won't have this problem.
More info from gdb:
(gdb) backtrace
#0 0x0000000000676a6c in syntax_property_with_flags ()
#1 0x000000000067e33a in scan_sexps_forward ()
#2 0x000000000067eae9 in Fparse_partial_sexp ()
#3 0x0000000000635396 in funcall_subr ()
#4 0x0000000000634e7a in Ffuncall ()
#5 0x00007f366cb8de6f in F73796e7461782d70707373_syntax_ppss_0 () at /xxx/emacs/28.1/x86_64-pc-linux-gnu/../../../../bin/../lib/emacs/28.1/native-lisp/28.1-7901736e/preloaded/syntax-bf4e4bc4-19987706.eln
...
#68 0x000000000046df78 in redisplay_window_1 ()
#69 0x0000000000631365 in internal_condition_case_1 ()
#70 0x000000000046d2ae in redisplay_internal ()
#71 0x000000000046b129 in redisplay ()
#72 0x000000000057e312 in read_char ()
#73 0x000000000058d619 in read_key_sequence ()
#74 0x000000000057b509 in command_loop_1 ()
#75 0x00000000006312be in internal_condition_case ()
#76 0x000000000057ad96 in command_loop_2 ()
#77 0x00000000006309fa in internal_catch ()
#78 0x000000000057ad3e in command_loop ()
#79 0x000000000057a2f2 in recursive_edit_1 ()
#80 0x000000000057a490 in Frecursive_edit ()
#81 0x0000000000576fc2 in sort_args ()
(gdb)
So, it looks like that the emacs code has some issue causing this problem.
However, this problem CANNOT be reproduced when start Emacs without init.el file. So, it should be triggered by installed packages.
Finally, when I comment out the below line in custom-set-variables, the problem disappeared. So, it's NOT caused by any packages, at least for Emacs 28.1 + gcc/9.5.0_jit.
;; '(debug-on-error t)
It's reproduced by adding only blow content in init.el file:
(custom-set-variables
'(debug-on-error t)
)
'(debug-on-error t)
could be also '(debug-on-error '(nil))
By using '(debug-on-error nil)
, it doesn't have problem.
Therefore, as long as debug-on-error
is enabled as always - t
or when - '(nil)
, then it will cause the problem.