Bug with pointer corruption when assigning smth to dereferenced pointer (part of a structure)

twilight pipfstarrd at openmailbox.org
Mon May 9 13:58:11 UTC 2016


Hello!

When I were working on my FreeBSD-powered ThinkPad X200 I encounted a
bug (not sure what causes that) that produced a segfault. After some
investigation I were able to cut down the problem to such a small piece
of code: https://ideone.com/VVtgpG.

As you can see on ideone, it works absolutely fine.
But in my case I have:

###############################
In main we've got
container->first: 0x801006060
container->last 0x801006060
container: 0x801006058

In main after change we've got
container->first: 0x801006060
container->last 0x800000005
container: 0x801006058
###############################


I've wondered if it's hardware related or compiler related, so at first
I tried to compile with gcc and got the same result. Then, I tried to
compile and run the same on Ubuntu Live USB (with gcc). Everything
worked like a charm.

Here's the generated asm code: http://pastebin.com/8yRyk5nG.

Any suggestions where to submit the bug or what extra information to
provide?

-- 
Cheers~

PGP key fingerprint:
07B3 2177 3E27 BF41 DC65  CC95 BDA8 88F1 E9F9 CEEF

You can retrieve my public key at pgp.mit.edu.


More information about the freebsd-questions mailing list