Sign in Join

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

Mailing lists / fpc-pascal / 2009-09

mysterious crashing, maybe related to setlength

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

David Emerson

My program is crashing, and I just can't figure out why. Heaptrc has given me this rather cryptic info:

Marked memory at $B79BA208 invalid
Wrong signature $000020D8 instead of 8E1C71B6

Using lazurus's step-into functionality, I've it down to the line where it's crashing -- seems to be crashing upon completion of a function. Alternately, I can get it to make a similar crash on setlength of a dynamic array to length 0. (The array has refcount 1.)

I haven't been able to reduce my code to anything reasonable; whenever I cut out seemingly irrelevant/unrelated sections, the crashing stops.

Thanks for any advice!
~David.

Reply by email

Jonas Maebe
to David Emerson
David Emerson wrote 5 lines
My program is crashing, and I just can't figure out why. Heaptrc has given me this rather cryptic info: Marked memory at $B79BA208 invalid Wrong signature $000020D8 instead of 8E1C71B6

It means that you probably have a buffer overrun somewhere.

Using lazurus's step-into functionality, I've it down to the line where it's crashing -- seems to be crashing upon completion of a function.

At the end of a function, all local variables are finalised. It's probably finalising a local dynamic array (possibly the one you mention below).

Show quoted text 6 lines
Alternately, I can get it to make a similar crash on setlength of a dynamic array to length 0. (The array has refcount 1.) I haven't been able to reduce my code to anything reasonable; whenever I cut out seemingly irrelevant/unrelated sections, the crashing stops.

Have you tried compiling with range checking on? (-Cr)

Jonas

Reply by email

David Emerson
to Jonas Maebe

Thanks, Jonas!

Just before I posted the other day, I had discovered a buffer overrun via range checking. I took care of it before writing my previous message. Maybe there is another buffer overflow that the range checker is somehow missing?

There IS a local dynamic array to be finalized, so this seems likely. However, range checking is not catching it, so I am stumped.

Thanks!
~David.

Jonas Maebe wrote 34 lines
On 06 Sep 2009, at 10:16, David Emerson wrote: > My program is crashing, and I just can't figure out why. Heaptrc has > given me this rather cryptic info: > > Marked memory at $B79BA208 invalid > Wrong signature $000020D8 instead of 8E1C71B6 It means that you probably have a buffer overrun somewhere. > Using lazurus's step-into functionality, I've it down to the line > where > it's crashing -- seems to be crashing upon completion of a function. At the end of a function, all local variables are finalised. It's probably finalising a local dynamic array (possibly the one you mention below). > Alternately, I can get it to make a similar crash on setlength of a > dynamic array to length 0. (The array has refcount 1.) > > I haven't been able to reduce my code to anything reasonable; > whenever I > cut out seemingly irrelevant/unrelated sections, the crashing stops. Have you tried compiling with range checking on? (-Cr) Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to David Emerson
David Emerson wrote
Just before I posted the other day, I had discovered a buffer overrun via range checking. I took care of it before writing my previous message. Maybe there is another buffer overflow that the range checker is somehow missing?

If the overflow happens via a pointer access rather than via an array index, that's quite possible.

There IS a local dynamic array to be finalized, so this seems likely. However, range checking is not catching it, so I am stumped.

If you are under Linux, you can try compiling with -gv and then run your program under Valgrind to see whether that one turns up something.

Jonas

Reply by email