TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The code worked differently when the moon was full (2021)

144 pointsby asicspover 1 year ago

13 comments

pacaroabout 1 year ago
In the mid 90s I worked for a small ISV that wrote at GIS that ran on windows 3.1 (a 32 bit operating system that ran 16 bit processes (that could have 32 bit code segments))<p>One of our customer required perfect uptime, which was a problem with the GetTickCount wraparound described here<p>Our solution was to run under NuMega SoftICE [1] and once a month, or so, dispatch an engineer to the customer to simultaneously patch the kernel value for the tick count and also the expected value in our software (and also clean up various handle based cruft)<p>This worked for years. Unfortunately the engineer in question was also an alcoholic, so a particularly spectacular bender spoiled an approx 3 year uptime<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SoftICE" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SoftICE</a>
评论 #39477233 未加载
darekkayabout 1 year ago
There&#x27;s a repo from danluu, collecting such debugging stories [1]. I&#x27;ve had my own peculiar bug: &quot;Script crashes before 10 a.m.&quot; [2]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;danluu&#x2F;debugging-stories">https:&#x2F;&#x2F;github.com&#x2F;danluu&#x2F;debugging-stories</a><p>[2] <a href="https:&#x2F;&#x2F;darekkay.com&#x2F;blog&#x2F;script-crashes-before-10&#x2F;" rel="nofollow">https:&#x2F;&#x2F;darekkay.com&#x2F;blog&#x2F;script-crashes-before-10&#x2F;</a>
评论 #39480993 未加载
Const-meabout 1 year ago
Interesting bug, but I don’t like the fix.<p>Most computers are 64 bits for decades now. It takes same resources to add&#x2F;subtract&#x2F;compare int64 compared to int32. No reason to use 32-bit integers for time, when I write C++ I use GetTickCount64() API introduced in Vista.<p>The C# equivalent is Environment.TickCount64, but there’s no need because unlike many other languages, C# standard library comes with a good support for dates, times, and time intervals. Instead of integers for elapsedInterval and requiredInterval variables, I prefer TimeSpan type. Safer, more readable, and potentially higher resolution because TimeSpan keeps int64 number of 100 nanoseconds ticks.
评论 #39477605 未加载
omoikaneabout 1 year ago
The bug depends on system clock, but it&#x27;s a bit of a stretch to say that it depends on moon phase.<p>Unless they were using that system to play NetHack:<p><a href="https:&#x2F;&#x2F;nethackwiki.com&#x2F;wiki&#x2F;Time#Moon_phase_and_date" rel="nofollow">https:&#x2F;&#x2F;nethackwiki.com&#x2F;wiki&#x2F;Time#Moon_phase_and_date</a>
评论 #39479664 未加载
评论 #39480049 未加载
yavor-atanasovabout 1 year ago
Reminds me of this &quot;We can&#x27;t send mail more than 500 miles&quot; story - <a href="https:&#x2F;&#x2F;web.mit.edu&#x2F;jemorris&#x2F;humor&#x2F;500-miles" rel="nofollow">https:&#x2F;&#x2F;web.mit.edu&#x2F;jemorris&#x2F;humor&#x2F;500-miles</a>
riffraffabout 1 year ago
I thought this was a reference to the old &quot;phase of the moon&quot; bug entry in the Jargon file[0] and it was very confusing to see it marked 2021. Still, good bug!<p>0: <a href="http:&#x2F;&#x2F;www.catb.org&#x2F;jargon&#x2F;html&#x2F;P&#x2F;phase-of-the-moon.html" rel="nofollow">http:&#x2F;&#x2F;www.catb.org&#x2F;jargon&#x2F;html&#x2F;P&#x2F;phase-of-the-moon.html</a>
评论 #39479479 未加载
Miikoabout 1 year ago
I strongly believe that &quot;having the two fields get initialized to Environment.TickCount&quot; is the correct fix and using unsigned arithmetic is just a workaround. If you save the time of some event in some field, you either need to initialize that field with current time, or have special processing of &quot;value not set&quot; everywhere it is used, otherwise you&#x27;re almost guaranteed to have some hard to debug problem somewhere in the long run.
评论 #39477840 未加载
mynegationabout 1 year ago
“int currentTimeMs” - whoa, I wish the compiler stop me there.
评论 #39476437 未加载
评论 #39478941 未加载
vishnuharidasabout 1 year ago
Another interesting debugging story - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32709045">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32709045</a>
userbinatorabout 1 year ago
<i>currentTimeMs is Environment.TickCount, which in this case happens to be negative.</i><p>It&#x27;s worth noting that GetTickCount() is documented as returning an <i>unsigned</i> count, and unless you really need to time intervals &gt; ~49 days to millisecond accuracy, everything works as expected with modulo arithmetic.<p>Windows&#x27; AppVerifier has an option that causes GTC to rollover much sooner, specifically to test for such bugs.
sealeckabout 1 year ago
Cool case! Always really interesting to read about other people&#x27;s debugging cases and strategies. I can also 100% recommend <a href="https:&#x2F;&#x2F;www.whyprogramsfail.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.whyprogramsfail.com&#x2F;</a>, a book which looks at the theory behind writing correct software.
bombcarabout 1 year ago
Someone somewhere had a QA list of things to check&#x2F;correlate, and one of them was - failure after 49 days.
评论 #39478714 未加载
walrus01about 1 year ago
I was hoping this would be a post about some bug that manifested itself in scada systems for tidal gauges or something actually affected by the physical position of the moon.