Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.54k stars 173 forks source link

custom app build, crashes, [FORMS.PP] ExceptionOccurred #5037

Closed ghost closed 1 year ago

ghost commented 1 year ago

Error occurs with any recent version in cudatext-qt5, at least 1.189.x - 1.192.x:

Eg running: $ cudatext readme.txt Does open the file but also throws error [FORMS.PP] ExceptionOccurred Sender=EAccessViolation Exception=Access violation Stack trace: $00000000004301F1 $000000000052E7D1 $000000000052E777 $000000000052F54B $0000000000435C8B $000000000043A517 Exception at 00000000004301F1: EAccessViolation: Access violation.

There is no error when running: cudatext -n readme.txt

What does this error indicate?

Thank you in advance.

Alexey-T commented 1 year ago

I cannot repeat it on last version, both gtk2 and qt5. I removed 'settings' folder and run app 2 times (one_instance is true). second run with a file parameter. parameter was passed to 1st instance OK.

Can you check on another PC?

ghost commented 1 year ago

The cudatext used is built from source. When I compare the ldd output for this executable and a downloaded one, the downloaded one has these enties extra:

libpthread.so.0 /usr/lib/libpthread.so.0 libdl.so.2 /usr/lib/libdl.so.2 The rest is identical.

Version of fpc is 3.2.2 and lazarus 2.2.4.

Do any build/link flags have to be set?

Alexey-T commented 1 year ago

Some flags are wrong on your IDE but I dont have idea which. threads-lib is always used on Linux

  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
ghost commented 1 year ago

It's a batch install that installs lazarus and fpc in a clean chroot. For lazarus no options are set. For fpc only -Fl and -Fu The actual build is done with cudaup.sh -m -w qt5 -o Linux Where should I check for the IDE flags being set/used?

veksha commented 1 year ago

try to update your system. what glibc/musl version do you have?

ghost commented 1 year ago

It's a rolling distro - archi derivative - so up to date. glibc is version 2.37

veksha commented 1 year ago

maybe this will help:

https://wiki.lazarus.freepascal.org/Qt5_Interface#Systems_using_Wayland (also check libQt5Pas version.)

image

ghost commented 1 year ago

Thank you for the suggestion. I don't use Wayland nor gnome, just qt5 on xorg.

No matter what I try, these keep missing: libpthread.so.0 /usr/lib/libpthread.so.0 libdl.so.2 /usr/lib/libdl.so.2

I added -dUseCThreads to the fpc cfg and also modified {$IFDEF UNIX}cthreads,{$ENDIF} to cthreads, in cudatext.lpr, but that also does not help.

Alexey-T commented 1 year ago

Do these files exist on your PC? libpthread.so.0 /usr/lib/libpthread.so.0 libdl.so.2 /usr/lib/libdl.so.2

ghost commented 1 year ago

Yes, both do exist : -rwxr-xr-x 1 root root 14416 Feb 3 23:43 /usr/lib/libdl.so.2 -rwxr-xr-x 1 root root 14424 Feb 3 23:43 /usr/lib/libpthread.so.0

ghost commented 1 year ago

I tried every fpc and lazarus flag I could find to have libdl.so libpthread.so linked into the cudatext executable but no luck so far. Is there any way to force this?

z4ziggy commented 1 year ago

https://github.com/Alexey-T/CudaText/blob/028af41850f3b5b81177670449d5d5aaff3fe2b1/app/proc_globdata.pas#L4054

Alexey-T commented 1 year ago

What does your comment mean, @z4ziggy ?

z4ziggy commented 1 year ago

@Alexey-T This is the cause for the EAccessViolation

Alexey-T commented 1 year ago

I cannot see the repro here, so I won't remove this line.

z4ziggy commented 1 year ago

you shouldn't remove this line as it will cause a memory leak. Someone who cares for this editor should fix it. I don't have the time.

Alexey-T commented 1 year ago

I should not react to such posts, where only line of code is given

ghost commented 1 year ago

Thx for the suggestion. I tested with a patch removing line 4054 in proc_globdata.pas and it does indeed prevent the error. To prevent a memory leak the statement should be present but executed only conditionally. Question is, on what condition?

ghost commented 1 year ago

I added the conditions cudatext is not setup for single instance, or not running already. That seems to work OK.

Alexey-T commented 1 year ago

Applied the fix from @z4ziggy

ghost commented 1 year ago

Tested with fix; no more errors. Thx!

Alexey-T commented 1 year ago

Related FPC bug: https://gitlab.com/freepascal.org/fpc/source/-/issues/40276