Re: what am I missing?

new topic     » goto parent     » topic index » view thread      » older message » newer message
jacques_desch said...

the extra byte is at end of allocated struct. Matt code give this on Linpus lite compiled with gcc 4.1.2

termios2: 44 
c_iflag:  0xbfc9e408 
c_oflag:  0xbfc9e40c 
c_cflag:  0xbfc9e410 
c_lflag:  0xbfc9e414 
c_line:   0xbfc9e418 
c_cc:     0xbfc9e419 
c_ispeed: 0xbfc9e42c 
c_ospeed: 0xbfc9e430 
So there is no padding between fields but allocationg 44 crash my program. Well I will take it as a mystery and go on with TERMIOS_SIZE=45

That's odd. What happens if you do the same in C? Meaning, can you malloc 44 bytes and not have it crash?

It sounds like the code is writing out of bounds somewhere. Actually, I'd recommend running it under valgrind, so see where the illegal access is happening. Sounds like a bug in the library. If you do any C coding on Linux, valgrind can be your best friend for tracking down weird memory issues.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu