[Gambas-user] Crash with Free()

Demosthenes Koptsis demosthenesk at ...626...
Thu Jan 13 22:41:37 CET 2011


:) Pointers are tricky!
And may be this subject is difficult for BASIC programmers like me.
But in time we can learn their tricks and pay attention to such cases.

In my book i simulate and describe such cases based on
http://www.yolinux.com/TUTORIALS/C++MemoryCorruptionAndMemoryLeaks.html

i do not make exact port of the C code to Gambas3 and i know that it
cannot be done but i can make some remarks for the usage of pointers and
common mistakes.

Jussi you can also use this page to write code for your Tester.
For example this crash you saw was

"Freeing memory that was not allocated."

 

On Thu, 2011-01-13 at 22:07 +0200, Jussi Lahtinen wrote:
> Aaaa... of course, pointer is not correct to free after "pp += 4".
> Though, result shouldn't be signal 11.
> 
> Jussi
> 
> 
> 2011/1/13 Benoît Minisini <gambas at ...1...>
> 
> > > Hi!
> > > I was adding some test for pointer arithmetic when noticing this.
> > > GambasTester will pass, but when you close main form, signal 11 will
> > rise.
> > > Commenting out Free(pp) from mTest: line 1070, will prevent crash.
> > >
> > > Gambas 3 rev 3452 @ Ubuntu 10.10 64bit
> > >
> > > Jussi
> >
> > You are calling Free(pp) whereas pp is not the pointer returned by Alloc()
> > anymore. So you get a crash...
> >
> > --
> > Benoît Minisini
> >
> >
> > ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand
> > malware threats, the impact they can have on your business, and how you
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand 
> malware threats, the impact they can have on your business, and how you 
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

-- 
Regards,
Demosthenes





More information about the User mailing list