@EastonMan 看的新闻
+碎碎念
+膜大佬
+偶尔猫猫
+伊斯通听的歌
dramforever's blog
Legendary off-by-ones, bugs or not

CRC-32 k6'

Using carryless multiplication (CLMUL) to efficiently compute a cyclic redundancy check (CRC) consists of two steps: folding and Barret reduction. For both, some pre-computed constants are used.

The mathematics of CRC is described in detail elsewhere and will not be repeated here. See the Intel whitepaper linked below for a comprehensive explanation.

This concerns only a specific variant of CRC known as the IEEE or Zlib CRC-32. It uses the polynomial 0x104c11db7.

In the computation, a constant used was known as as k6'. The Intel whitepaper by Gopal et al. gives the value of this constant as:
k6' = 0x1db710640

However, as Kutenin described, some implementations use this value of k6' instead:
k6' = 0x1db710641

This discrepancy was also noted in the wuffs library.

A mathematical analysis reveals that the two constants are equivalent. In effect, the LSB of k6' is unused. You can think of this as the LSB of the multiplicand having no effect on the high-half of a carryless multiplication:

(p(x)+a)(q(x)+b)=p(x)q(x)+aq(x)+bp(x)+ab (p(x) + a) (q(x) + b) = p(x)q(x) + a q(x) + b p(x) + a b

The addition of the constant terms a and b results in a difference of degree no more than max⁡{deg⁡(p(x)),deg⁡(q(x))}\max\{\deg(p(x)), \deg(q(x))\}.

Therefore, this is not a bug.

See also:

Danila Kutenin, How a Bug(?) in the Linux CRC-32 Checksum Turned out not to be a Bug
Intel, Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction (Link to the Internet Archive)
common_up_x86_sse42.wuffs from wuffs

Swift Float.pi

The constant Float.pi in Swift is the IEEE 754 binary32 approximation of π\pi. Its value is:
0x1.921fb4p+1 ≈ 3.14159250…

Most other language standard libraries provide this value instead:
0x1.921fb6p+1 ≈ 3.14159274…

The two differ in only the least significant bit of the significant. In other words, they differ by a single ULP.
                    s e        m
0x1.921fb4p+1 = f32(0 10000000 10010010000111111011010)
0x1.921fb6p+1 = f32(0 10000000 10010010000111111011011)

The latter larger value is closer to the true value of π\pi, 3.14159365…. However, Swift’s value is chosen as rounding π\pi towards zero, in order to nudge trigonometric functions into the expected quadrants more often.

There is later consensus among the IEEE 754 working group that implementations should provide the closer-rounded value. Therefore, there is a proposal to “fix” the value of It is humorously referred to as the “Indiana π bill, take 2”, in reference to the 1897 legislative bill in Indiana, United States that would have incidentally legislated the value of π\pi as 3.2.

See: [Pitch] round π to nearest on the Swift Forums.

This is not a bug, but it may be fixed anyway.

Rockchip calendar

The RK808 PMIC had a real-time clock (RTC) that would count the time and date with very little power. However, there is a bug in that chip. It would be difficult to describe the off-by-one better than the patch message that added the corresponding workaround to Linux.

rtc: rk808: Compensate for Rockchip calendar deviation on November 31st

In A.D. 1582 Pope Gregory XIII found that the existing Julian calendar insufficiently represented reality, and changed the rules about calculating leap years to account for this. Similarly, in A.D. 2013 Rockchip hardware engineers found that the new Gregorian calendar still contained flaws, and that the month of November should be counted up to 31 days instead. […]
(See: https://git.kernel.org/torvalds/c/f076ef44a44d02ed91543f820c14c2c7dff53716)

The workaround eventually decided on was to arbitrarily consider 2016-01-01 the date at which the Rockchip and Gregorian calendars are synchronized. Then, dates are converted as needed. Unfortunately this does mean that firmware and dual-booted operating systems need the same synchronization convention, but it is probably fine.

This is definitely a bug, but since it’s worked around in software, nobody has to see it.

source
杰哥的{教学,运维,编程,调板子}小笔记
修复绿联 UG307-95348 HDMI 采集卡清晰度与颜色问题

source 修复绿联 UG307-95348 HDMI 采集卡清晰度与颜色问题 - 杰哥的{教学,运维,编程,调板子}小笔记
杰哥的{教学,运维,编程,调板子}小笔记
修复绿联 UG307-95348 HDMI 采集卡清晰度与颜色问题

source 修复绿联 UG307-95348 HDMI 采集卡清晰度与颜色问题 - 杰哥的{教学,运维,编程,调板子}小笔记
Daniel Lemire's blog
AI programming: a layered model

In the late 1960s and 1970s, people like David Parnas faced a problem. A decade earlier there were almost no programmers. Suddenly there were hordes of inexperienced ones. What could have been a golden era was turning into a mess: far more software, much of it falling apart.

It sent Edsger Dijkstra into a depression. Does this sound familiar?

AI-assisted coding is producing far more code. Whether the projects will work or crumble remains to be seen. There is a danger.

I’d like to propose the layered model.

Keep a small core that changes slowly and on purpose. For that part you actually read the code. You insist on tests. You can use AI assistance, but there is no vibe coding allowed.

Everything else can move fast. There will be bugs, but the AI fixes them quickly.

Dependencies should be one way: the outer layers depend on the core. The core cannot depend on the outer layers.

source
▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░ 67%
Back to Top