cookie 32-bit time wrapping and possible gcc problem
Tried running my test/cookies program and got two failures from the 32-bit timestamp wrapping tests. Turned out that I had -O2 set. -O succeeds, and no optimization succeeds. If I insert a MSG("exptime+local_shift %ld\n", exptime + local_shift); after setting local_shift in Cookies_expires_attr(), it works even with -O2. This is with gcc-4.3.3. I'm going to get 4.4.3 and see what happens... PS I don't particularly expect anyone to rush off and try it for themselves, but if you do, it is good to run 'dpidc stop' between runs.
On Mon, Mar 08, 2010 at 06:33:12PM +0000, corvid wrote:
Tried running my test/cookies program and got two failures from the 32-bit timestamp wrapping tests.
Turned out that I had -O2 set. -O succeeds, and no optimization succeeds. If I insert a MSG("exptime+local_shift %ld\n", exptime + local_shift); after setting local_shift in Cookies_expires_attr(), it works even with -O2.
This is with gcc-4.3.3. I'm going to get 4.4.3 and see what happens...
Can you reproduce the issue with a small test program? If yes, we could look at the generated code.
Johannes wrote:
On Mon, Mar 08, 2010 at 06:33:12PM +0000, corvid wrote:
Tried running my test/cookies program and got two failures from the 32-bit timestamp wrapping tests.
Turned out that I had -O2 set. -O succeeds, and no optimization succeeds. If I insert a MSG("exptime+local_shift %ld\n", exptime + local_shift); after setting local_shift in Cookies_expires_attr(), it works even with -O2.
This is with gcc-4.3.3. I'm going to get 4.4.3 and see what happens...
Same behaviour with 4.4.3.
Can you reproduce the issue with a small test program? If yes, we could look at the generated code.
*makes toy program* Haven't been able to get it to break.
I wrote:
Johannes wrote:
On Mon, Mar 08, 2010 at 06:33:12PM +0000, corvid wrote:
Tried running my test/cookies program and got two failures from the 32-bit timestamp wrapping tests.
Turned out that I had -O2 set. -O succeeds, and no optimization succeeds. If I insert a MSG("exptime+local_shift %ld\n", exptime + local_shift); after setting local_shift in Cookies_expires_attr(), it works even with -O2.
This is with gcc-4.3.3. I'm going to get 4.4.3 and see what happens...
Same behaviour with 4.4.3.
Found out what's going on. Signed overflow is undefined, and -O2 gives -fstrict-overflow, which assumes that overflow won't happen. So I will do something of some sort about this :)
On Mon, Mar 08, 2010 at 10:20:05PM +0000, corvid wrote:
I wrote:
Johannes wrote:
On Mon, Mar 08, 2010 at 06:33:12PM +0000, corvid wrote:
Tried running my test/cookies program and got two failures from the 32-bit timestamp wrapping tests.
Turned out that I had -O2 set. -O succeeds, and no optimization succeeds. If I insert a MSG("exptime+local_shift %ld\n", exptime + local_shift); after setting local_shift in Cookies_expires_attr(), it works even with -O2.
This is with gcc-4.3.3. I'm going to get 4.4.3 and see what happens...
Same behaviour with 4.4.3.
Found out what's going on.
Signed overflow is undefined, and -O2 gives -fstrict-overflow, which assumes that overflow won't happen.
good catch!
So I will do something of some sort about this :)
BTW. wikipedia states that generally arithmetic operations on time_t have no defined meaning, but you can use difftime() instead.
participants (2)
-
corvid@lavabit.com
-
Johannes.Hofmann@gmx.de