Re: wxEuphoria on FreeBSD

new topic     » goto parent     » topic index » view thread      » older message » newer message

Robert Craig wrote:
> 
> The dirty assumptions that I make about malloc() have always
> been a problem when porting.

Yeah, I've been working on linux for a bit now, and I've discovered that
(at least for FC6--not sure what version of libc that has) if you realloc
smaller, and it gives you the same pointer back, malloc_usable_size()
gives you the old answer, causing you to make invalid writes to memory.

> > After banging my head for a while, I've come to the conclusion that the
> > simplest way to get this to work is to just always malloc 8 more bytes
> > than asked for, and put MAGIC_FILLER in for a 4 byte alligned chunk,
> > and a 0 in for an 8 byte alignment.  Of course, I'll have to memcopy
> > in realloc if we switch alignments.
> 
> Good idea. Just get it working cleanly. We can worry about
> saving memory later.

I haven't even really attempted to figure out what you do with all the
cache and pool junk in there.

> Subtle malloc bugs can be nightmarishly difficult to track down.
> I'm impressed that you've figured out this much.
> I hope you don't blame me for your torture. smile

No, not really.  Of course, a big issue is the rate of change in free and
open source operating systems.  I generally enjoy digging and digging until
I figure out this sort of thing.  I must say, valgrind really helps, 
especially when you remember to turn on debugging symbols (slaps head).

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu