Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-09

AV on messagedialogs?

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michal Bukovjan

Hi,

today Lazarus started crashing on MessageDialogs (or it may have crashed always and surfaced to me only today). Using fpc 1.0.6, GTK+ backend. Here are some clues:

1) It manifests itself sometimes (rarely) in messagedialogs example
2) It manifests itself always in the following scenarion:

- start lazarus (new project opens)
- type something into the unit edit window, so that the unit file changes
- try to close Lazarus (either choose quit or try to close its window)
- when asked to save the file, choose Cancel
- try to close Lazarus again -> crash

3) If I close the dialog via Window Manager (right click on the titlebar and choose Close), the crash does not occur and I can try to close Lazarus many times. This could perhaps mean that the crash happens / can be attributed to clicked signal handling and form destroy?

I found that it perhaps crashes during the dialog show, but was unable to find more yet, as gdb was not of much help. This looks like dangling pointers or memory overwriting to me.
This could be related to the other errors reported here. Does anyone know of a decent memory debugger like valgrind for Free Pascal?

Michal

Reply by email

Michal Bukovjan
to Michal Bukovjan
Mattias Gaertner wrote 20 lines
On Wed, 04 Sep 2002 01:12:25 +0200 Florian Klaempfl wrote: >At 00:01 04.09.2002 +0200, you wrote: > > > >>I found that it perhaps crashes during the dialog show, but was unable to >>find more yet, as gdb was not of much help. This looks like dangling >>pointers or memory overwriting to me. >> >> gdb helped me to find out: The crash comes with the gtk_accel_group_add statements. For example for TBitBtn. Probably the accelerators were not released, when the widgets were destroyed or the accelerator changes. Probably the people who implemented the accelerator stuff have an idea where to start.

Yes, that was the code. GTK does not release accelerators upon widget destroy, and thus there remains a dangling pointer in accelerator group. As soon as you try to add the same accelerator for a second time, it tries to remove existing accelerator for now non-existent object and GTK crashes.

This is now fixed by always releasing all accelererators upon widget destroy.

Michal

Reply by email

Michal Bukovjan
to Michal Bukovjan: today Lazarus started crashing on MessageDialogs (or it may have crashed always and…
Mattias Gaertner wrote 19 lines
On Wed, 04 Sep 2002 01:12:25 +0200 Florian Klaempfl wrote: >At 00:01 04.09.2002 +0200, you wrote: > > > >>I found that it perhaps crashes during the dialog show, but was unable to >>find more yet, as gdb was not of much help. This looks like dangling >>pointers or memory overwriting to me. >> >> gdb helped me to find out: The crash comes with the gtk_accel_group_add statements. For example for TBitBtn. Probably the accelerators were not released, when the widgets were destroyed or the accelerator changes. Probably the people who implemented the accelerator stuff have an idea where to start.

That would be me. How did you find out? My backtrace ended on gtkclickcb and I could not make anything useful out of it, I'll check that today.

Show quoted text 14 lines
>>This could be related to the other errors reported here. >>Does anyone know of a decent memory debugger like valgrind for Free Pascal? >> >> >Did you try the heaptrc unit? > > Yeah, very useful unit. Although I wish, some of the internal variables/procs would be readable via functions in the interface. Like getmem_cnt.

I'll try that unit.

Thanks,

Michal

Reply by email

Florian Klaempfl
to Michal Bukovjan: today Lazarus started crashing on MessageDialogs (or it may have crashed always and…
you wrote 5 lines
I found that it perhaps crashes during the dialog show, but was unable to find more yet, as gdb was not of much help. This looks like dangling pointers or memory overwriting to me. This could be related to the other errors reported here. Does anyone know of a decent memory debugger like valgrind for Free Pascal?

Did you try the heaptrc unit?

Reply by email

Mattias Gaertner
to Michal Bukovjan: today Lazarus started crashing on MessageDialogs (or it may have crashed always and…
Show quoted text 5 lines
At 00:01 04.09.2002 +0200, you wrote: >I found that it perhaps crashes during the dialog show, but was unable to >find more yet, as gdb was not of much help. This looks like dangling >pointers or memory overwriting to me.

gdb helped me to find out:
The crash comes with the gtk_accel_group_add statements. For example for TBitBtn. Probably the accelerators were not released, when the widgets were destroyed or the accelerator changes. Probably the people who implemented the accelerator stuff have an idea where to start.

>This could be related to the other errors reported here. >Does anyone know of a decent memory debugger like valgrind for Free Pascal? Did you try the heaptrc unit?

Yeah, very useful unit. Although I wish, some of the internal variables/procs would be readable via functions in the interface. Like getmem_cnt.

Mattias

Reply by email

Florian Klaempfl
to Florian Klaempfl: Did you try the heaptrc unit?
you wrote 5 lines
> Did you try the heaptrc unit? Yeah, very useful unit. Although I wish, some of the internal variables/procs would be readable via functions in the interface. Like getmem_cnt.

If you've ideas how to improve the heaptrc unit, feel free to post them at the fpc mailing list. I don't think
that Pierre who did most of the heaptrc implementation reads the lazarus mailing list.

Reply by email