Recent

Author Topic: Mysterious Debugger message  (Read 881 times)

winni

  • Hero Member
  • *****
  • Posts: 2709
Mysterious Debugger message
« on: September 16, 2021, 07:14:48 pm »
Hi!

A simple App runs without problems - all checks enabled.

But when I want to close it - then it crashes with 216 General Protection fault


If I run it from a Konsole then after closing this mysterious message appears:


Code: Bash  [Select][+][-]
  1. [DEBUG] Name com.canonical.AppMenu.Registrar does not exist on the session bus
  2.  
  3. Exception at 00000000004372D7: EAccessViolation:
  4. Access violation.
  5. WARNING: TButton.Destroy with LCLRefCount>0. Hint: Maybe the component is processing an event?
  6.  

The Buttons have only onClick assigned.

The Debugger shows:
Code: Text  [Select][+][-]
  1. 00000000004372ED c3                       ret    
  2. 00000000004372EE 0000                     add    %al,(%rax)
  3. SYSTEM_$$_WAITFREE_VAR$PMEMCHUNK_VAR
  4. 00000000004372F0 53                       push   %rbx
  5. 00000000004372F1 4889fb                   mov    %rdi,%rbx
  6. 00000000004372F4 488d3d55867600           lea    0x768655(%rip),%rdi        # 0xb9f950 <U_$SYSTEM_$$_HEAP_LOCK>
  7. 00000000004372FB e8d00c0000               call   0x437fd0 <SYSTEM_$$_ENTERCRITICALSECTION$TRTLCRITICALSECTION>
  8. 0000000000437300 4889d8                   mov    %rbx,%rax
  9. 0000000000437303 488b5008                 mov    0x8(%rax),%rdx
  10. 0000000000437307 488b92b8000000           mov    0xb8(%rdx),%rdx
  11. 000000000043730E 48895018                 mov    %rdx,0x18(%rax)
  12. 0000000000437312 488b5008                 mov    0x8(%rax),%rdx
  13. 0000000000437316 488982b8000000           mov    %rax,0xb8(%rdx)
  14. 000000000043731D 488d3d2c867600           lea    0x76862c(%rip),%rdi        # 0xb9f950 <U_$SYSTEM_$$_HEAP_LOCK>
  15. 0000000000437324 e8e70c0000               call   0x438010 <SYSTEM_$$_LEAVECRITICALSECTION$TRTLCRITICALSECTION>
  16. 0000000000437329 5b                       pop    %rbx
  17. 000000000043732A c3                       ret    
  18. 000000000043732B 0000                     add    %al,(%rax)
  19. 000000000043732D 0000                     add    %al,(%rax)
  20. 000000000043732F 00                       add    %dl,0x41(%rbx)
  21. SYSTEM_$$_SYSFREEMEM_FIXED$PFREELISTS$PMEMCHUNK_FIXED$$QWORD
  22. 0000000000437330 53                       push   %rbx
  23. 0000000000437331 4154                     push   %r12
  24. 0000000000437333 4155                     push   %r13
  25. 0000000000437335 4889f3                   mov    %rsi,%rbx
  26.  


Has anyone an idea what the hell is going on?

Linux64 fpc 3.2 Lazarus 2.0.12

Winni

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7439
  • Debugger - SynEdit - and more
    • wiki
Re: Mysterious Debugger message
« Reply #1 on: September 16, 2021, 08:37:28 pm »
The first bit "com.cannonical" is OS related.

The last bit "refcount" could be a consequence of the crash. Strange though, I would have expected it before the crash.
Did you press any button, and could you be inside that button's "OnClick" (or MouseDown/Up) code?

As for the Access-violation. This is what would stop the app in the debugger.
If you are in some package for which no debug info was generated then you want see any sources. (You can add debug info to most packages, using "Additions and Overrides".

Have you opened the debuggers stack window? What does it show?

winni

  • Hero Member
  • *****
  • Posts: 2709
Re: Mysterious Debugger message
« Reply #2 on: September 16, 2021, 09:03:48 pm »
Thanx Martin_fr

Some more info:

Start in Konsole. If I stop the app with ALT-F4 the message about the button disappears and there is only left:

Code: Bash  [Select][+][-]
  1. [DEBUG] Name com.canonical.AppMenu.Registrar does not exist on the session bus
  2.  
  3. Exception at 0000000000437307: EAccessViolation:
  4. Access violation.
  5.  

Second: The crash does not happen always. I have tried to detect some logic, but that was not successful.

Third: I am not alone. This problem appeared in 2019 but without a solution:

https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg52052.html

And I forgot: The cursor of the assembler is at

Code: ASM  [Select][+][-]
  1. 0000000000437307 488b92b8000000           mov    0xb8(%rdx),%rdx
  2.  

Winni


Bart

  • Hero Member
  • *****
  • Posts: 4475
    • Bart en Mariska's Webstek
Re: Mysterious Debugger message
« Reply #3 on: September 16, 2021, 10:17:42 pm »
I remember having a similar issue when the OnClick actually lead to the destruction (freeing) of the control.
I solved that by calling Application.ReleaseComponent instead.

May or may not be applicable to your problem.

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7439
  • Debugger - SynEdit - and more
    • wiki
Re: Mysterious Debugger message
« Reply #4 on: September 16, 2021, 10:26:52 pm »
If it appears "at random", it may be a double free / dangling pointer.

As you are on Linux, run your app under
  valgrind --tool=memcheck   yourapp

winni

  • Hero Member
  • *****
  • Posts: 2709
Re: Mysterious Debugger message
« Reply #5 on: September 17, 2021, 02:59:33 pm »
Hi!

Thanx for all the hints.

I enabled the heaptrace which showed me an awfull amount of unfreed memory.

Following the heaptrace messages and your hints about dangling pointers I found the "evil":

A pBGRApixel (Pointer to pixel) outside the  dimensions of a BGRAbitmap.

Thanx to everybody.
Problem solved and something learned about (late) strange behaviour.

Winni


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7439
  • Debugger - SynEdit - and more
    • wiki
Re: Mysterious Debugger message
« Reply #6 on: September 17, 2021, 03:07:22 pm »
After a crash, heaptrc is likely to report a lot. After all, the crash terminates your app before it gets to free the mem.

About the "outside access" => Valgrind is really good at finding those. Even if they do not cause an error.

winni

  • Hero Member
  • *****
  • Posts: 2709
Re: Mysterious Debugger message
« Reply #7 on: September 17, 2021, 03:58:35 pm »
After a crash, heaptrc is likely to report a lot. After all, the crash terminates your app before it gets to free the mem.

About the "outside access" => Valgrind is really good at finding those. Even if they do not cause an error.

Hi!

Yes I know. But  anyway heaptrace gave me the necessary infos.
I know about valgrind.  But it is not easy to read .....

Winni

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7439
  • Debugger - SynEdit - and more
    • wiki
Re: Mysterious Debugger message
« Reply #8 on: September 17, 2021, 04:26:27 pm »
Yes I know. But  anyway heaptrace gave me the necessary infos.
I know about valgrind.  But it is not easy to read .....

Menu: View > Leaks and traces

You can import the valgrind output (at least for the memcheck tool)

 

TinyPortal © 2005-2018