Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[linux] imcopy (and many other operations) fail: Out of memory #61
On linux (32 bit), many command, like
Update from the debugging of
seems to be wrong and should be replaced by a
Update: when the address is freed, the first step is that it is checked whether the pointer is negative. And then, there are some more consistency checks that will fail with negative values. So, if we don't want to disable them, we need to make sure the address is not negative (by resetting the MSB in the address).
Maybe you still didn't understand this bug: The cause of the "out of memory" failures is the following piece of code which has an implementation dependent behaviour according to the C standard:
The pointer returned from
When a signed integer with a negative value is right shifted, the C standard makes it implementation depending whether a zero is shifted in (which would make the result positive), or a one (which would keep the result negative):
ISO/IEC 9899/1999, §6.5.8:
In that case, the C compiler has the (implementation defined) freedom what to do. gcc keeps the sign, and then returns a negative value (which is then returned as an error by
For unsigned values, the right shift is defined to shift in a zero. This obviously works well independently what the compiler does for signed values. And the left shift does not have these problems; here the behaviour is well-defined. On error,
The release notes of 2.12 describe basically the same problem:
The only thing the patch #62 does is to ensure that a zero is shifted in, and this works on all systems.