CudaText: Cud freezes on startup with Terminal+ / GitStatus

OS: Windows 11 x64

i’m debugging like crazy and finally coming closer to what is happening with strange occasional freezes on Cuda’s start. ( i wrote about it here https://github.com/CudaText-addons/cuda_git_status/issues/38 )

it is hard to reproduce but i’ve found that Cuda hangs when this line is executed: ed.decor(DECOR_SET, line=l, tag=DIFF_TAG, text='', color=MY_DECOR_COLOR) or this one: ed.decor(DECOR_SET, line=line__, tag=DIFF_TAG, text='', color=MY_DECOR_COLOR) ( it’s inside cuda_git_status/git_manager.py file, diff procedure. )

to make them execute AND FREEZE Cuda we need some preconditions. they may not be required for reproducing, but they will increase the chance:

  • install cuda_git_status (obviously).
  • install Terminal+ (make it floating window; activate its button, so it will reappear on Cuda’s start automatically; set shell to cmd.exe)
  • set ui_reopen_session = true, so files can reopen automatically
  • open some file (inside some git repository) and change something in it. (this will trigger ed.decor lines inside diff proc!) now restart Cuda 10-20 times. if you are lucky, you will catch freeze.

now to some screenshots and debugging results. i had to install fpc+lazarus to step into pascal domain. I was too curious.

  1. cuda_git_status/git_manager.py , diff procedure

image

  1. frommain_py_api.inc, function api_ed_decor

image

  1. atsynedit.pas, Update procedure

image

  1. atsynedit.pas, UpdateCursor procedure

image

  1. control.inc, …

image image

  1. then WndProc, then inherited WndProc(message);, and finally Dispatch(TheMessage);

image


after all of this i tried to comment out following lines in hope that it will eliminate freeze and it did! but now mouse cursor is not changing to i-beam obviously:

image

From here I can’t do anything more. Asking you, @Alexey-T to say what you think and how we can make this work. i’m thinking of making these lines thread-safe somehow and building test version for me so i can try to reproduce it again with thread-safe facilities turned on.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 47 (46 by maintainers)

Commits related to this issue

Most upvoted comments

Standard GDB

C:\fpcupdeluxe\fpcupdeluxe\fpcbootstrap\gdb\$(TargetCPU)-$(TargetOS)\gdb.exe

I see the freeze. even w/out TErminal+ activated.

Hint for you:

  • run Cud under debugger
  • when freeze, press IDE “pause” toolbar button to stop the app
  • there, if you call “view / debug windows / Call stack”, you may go to wrong thread! you must activate the 1ST thread!
  • activate 1st thread: “view / debug windows / threads”, select 1st, press ‘current’ button; and now call “call stack” window again for 1st thread
  • I see that ‘call stack’ shows hang inside python when on_timer is run from gitStatus
#0 ntdll!ZwWaitForSingleObject at :0
#1 WaitForSingleObjectEx at :0
#2 python36!PyThread_acquire_lock_timed at :0
#3 python36!_PyOS_SigintEvent at :0
#4 ?? at :0
#5 python36!_PyOS_SigintEvent at :0
#6 ?? at :0
#7 ?? at :0
#8 ?? at :0
#9 python36!_PyCFunction_FastCallDict at :0
#10 python36!_PyCFunction_FastCallKeywords at :0
#11 python36!PyEval_GetFuncDesc at :0
#12 python36!_PyEval_EvalFrameDefault at :0
#13 python36!_PyEval_EvalFrameDefault at :0
#14 python36!PyEval_GetFuncDesc at :0
#15 python36!PyEval_GetFuncDesc at :0
#16 python36!_PyEval_EvalFrameDefault at :0
#17 python36!_PyEval_EvalFrameDefault at :0
#18 python36!PyEval_GetFuncDesc at :0
#19 python36!PyEval_GetFuncDesc at :0
#20 python36!_PyEval_EvalFrameDefault at :0
#21 python36!_PyEval_EvalFrameDefault at :0
#22 python36!_PyFunction_FastCallDict at :0
#23 python36!_PyObject_FastCallDict at :0
#24 python36!_PyObject_Call_Prepend at :0
#25 python36!PyMethod_New at :0
#26 python36!PyObject_Call at :0
#27 METHODEVALOBJECTS(0x1edfef8, 0x6b9457c 'xxcuda_git_status', 0x6b6c924 'on_timer', 0x1e7fbd8, 0) at proc_py.pas:276
#28 RUNCOMMAND(0x1edfef8, 0x6b6c8c4 'cuda_git_status', 0x6b6c924 'on_timer', 0x6b94548) at proc_py.pas:379
#29 DOPYCALLBACKFROMAPI(0x6b9421c 'cuda_git_status.on_timer', 0x6b94548, 0x1aefb8c, 0) at formmain_py_helpers.inc:325
#30 DOPYTIMERTICK(0x6f6f0b0, 0x1efe9d0) at formmain_py_helpers.inc:478

I guess i must stop timer ticks until some initing is done