首页›发现›编程›research!rsc

research!rsc

Atom
访问网站
文章数24
更新频率近 8 周没有更新
最近抓取28分钟前
订阅方式Atom
订阅地址https://research.swtch.com/feed.atom

最近的文章

订阅后,这些文章和以后的新文章都会出现在你的阅读器里

Fast Unrounded Scaling: Proof by Ivy

AI 摘要This post proves the correctness of uscale, a fast unrounded scaling algorithm based on a 64×128-bit multiplication and floating-point approximation, which underlies the author's floating-point printing and parsing algorithms (FixedWidth, Short, and Parse). The proof proceeds through a series of lemmas handling exact results, small positive and negative powers, and finally the large-power cases, which cannot be exhaustively tested directly. For those large-power cases, the author uses the Ivy calculator—an APL-inspired language with arbitrary-precision rationals and right-to-left precedence—to implement a two-step approach, loosely following work by Vern Paxson and Tim Peters, that solves a 'modular search' problem to find the first satisfying value and a 'modular minimum' problem to verify all relevant inputs.

Floating-Point Printing and Parsing Can Be Simple And Fast

AI 摘要This article presents fast floating-point printing and parsing algorithms built on a new primitive called fast unrounded scaling, which approximates scaling by powers of ten, often in a single 64-bit multiplication. These simple algorithms reportedly outperform all prior known methods, including Dragon4, Grisu3, Ryū, Schubfach, and Dragonbox, and the author plans to include a Go implementation in Go 1.27. The post walks through the necessary concepts (fixed-point and floating-point numbers, unrounded numbers) and outlines implementations for fixed-width and shortest-width printing as well as decimal parsing.

Pulling a New Proof from Knuth’s Fixed-Point Printer

AI 摘要This article is a reply to Donald Knuth's 1989 paper on proving the correctness of a program that converts 16-bit fixed-point binary fractions to their shortest accurate decimal representations, written in honor of Knuth's 88th birthday. The author presents what they argue is a better proof of Knuth's program P2 by starting with a simpler program that has a trivial direct correctness proof—implemented in the APL-like Ivy language—and then transforming it into P2 step by step, proving each transformation correct. The post also explores alternative solutions and concludes with reflections on how language and notation shape programs and proofs.

Floating Point Formatting

AI 摘要The article introduces the 'Floating Point Formatting' blog series, which began in 2011 and continued with new posts in 2026. It lists four posts covering topics such as floating-point to decimal conversion, a proof inspired by Knuth's fixed-point printer, simple and fast floating-point printing and parsing, and a proof of fast unrounded scaling verified with Ivy.

Differential Coverage for Debugging

AI 摘要The article describes 'differential coverage', a debugging technique that compares the code coverage profile of a failing test with those of passing tests to isolate code blocks unique to the failing case. Demonstrating in Go, the author diffs two coverage profiles and views the result with go tool cover -html, successfully narrowing an injected bug down to 10 lines among over 15,000. While not foolproof (e.g., data-dependent bugs or insensitive tests can evade it), the technique is cheap to compute and can save considerable debugging time.

Hash-Based Bisect Debugging in Compilers and Runtimes

AI 摘要The article traces the history of debugging with binary search, from bisecting data (such as finding one bad punched card among a thousand) to bisecting version history, which was popularized by tools like git bisect that automatically pinpoint the commit that introduced a bug. It then introduces a new trick for debugging in a different dimension: hash-based bisecting of program locations, which selectively enables or disables subsets of program lines, call stacks, or code sequences to identify exactly which code causes a failure. Illustrated with a Go toolchain example, this technique is presented as a 'magic wand' for debugging large, opaque test failures in unfamiliar code bases, compilers, and runtimes.

The xz attack shell script

AI 摘要The article dissects the shell script component of the xz backdoor attack disclosed by Andres Freund in March 2024. It explains how a maliciously modified build-to-host.m4 file included in the xz 5.6.0 and 5.6.1 tarballs locates a hidden payload embedded in fake 'test files', decompresses it, and executes additional stages of the attack during the configure/build process. The ultimate goal is to install a nefarious ifunc resolver that replaces RSA_public_decrypt with a version running attacker code when a specific SSH certificate is presented.

Timeline of the xz open source attack

AI 摘要Over more than two years, an attacker using the alias "Jia Tan" earned trust within the xz compression library project through seemingly legitimate contributions and social engineering, ultimately gaining commit access and maintainership. They then installed a carefully hidden backdoor in liblzma that enabled unauthenticated, targeted remote code execution over SSH on affected systemd-based Linux distributions. Publicly disclosed on March 29, 2024, the attack is considered the first serious known supply chain attack on widely used open source software and a watershed moment for open source supply chain security.

Go Changes

AI 摘要In the GopherCon USA opening talk 'Go Changes', the author examined how the Go language evolves, stressing the importance of data in making shared decisions and arguing that opt-in telemetry in the Go toolchain is a useful, effective, and appropriate new data source. The re-recorded talk has been posted online with links to related resources. The author also issued an errata, correcting a probability mistake in the talk: (2/3)^100 is about 2.46×10^-18, not 1.94×10^-48, though the conclusion remains that the probability is vanishingly small.

Go Testing By Example

AI 摘要The author opened GopherCon Australia with a talk titled "Go Testing By Example", which was re-recorded at home due to A/V issues and posted online. The talk presents 20 tips for improving Go testing, covering practices like making test cases easy to add, using coverage wisely, separating test cases from test logic, and using tools such as txtar and rsc.io/script. The author concludes by encouraging developers to continually improve their tests and aim for continuous deployment.

Running the “Reflections on Trusting Trust” Compiler

AI 摘要Marking the 40th anniversary of Ken Thompson's 1983 Turing Award lecture 'Reflections on Trusting Trust,' this article recaps the classic three-stage compiler backdoor attack: writing a self-reproducing quine, showing how compilers can 'learn' details that persist only in their binaries, and combining these to invisibly infect the login program. The author then obtained Thompson's actual original backdoor code (nih.a), which had never been requested or released before, and ran it in a V6 Unix emulator. The walkthrough demonstrates how the code modifies the C compiler to backdoor login and reproduce itself into newly compiled compilers, ending with the construction of both an 'evil' compiler and a clean one.

C and C++ Prioritize Performance over Correctness

AI 摘要This article argues that modern C and C++ prioritize performance over correctness by relying on undefined behavior, which lets compilers silently eliminate or rewrite code in ways that break programmers' expectations. Examples include Clang optimizing away loops that use uninitialized variables, deleting signed-integer overflow checks (with the committee rejecting a proposal to standardize two's-complement wraparound), assuming side-effect-free loops must terminate, and treating null pointer dereferences as undefined. The author contends that lumping buggy and non-portable code together under undefined behavior was a mistake that makes it increasingly difficult to know whether a compiled program preserves the meaning of its source.

The Magic of Sampling, and its Limitations

AI 摘要The article explains that random sampling allows surprisingly accurate estimates about very large populations from small samples, with accuracy depending only on the number of samples, not the population size—for example, 100 samples yield roughly 5% accuracy even when sampling just a tiny fraction of billions of items. It derives the margin of error mathematically using Go's standard math package, showing how to compute confidence intervals and required sample sizes. However, the technique has a key limitation: the sampling mechanism must align with the statistic being estimated (each item equally likely to be chosen), as skewed sampling causes systematic error that can only sometimes be corrected through weighting, as illustrated by M&M bag examples and Go's memory profiler.

Our Software Dependency Problem

AI 摘要The article examines how dependency managers have made fine-grained software reuse ubiquitous, allowing developers to easily depend on packages written by strangers on the internet, yet the trust mechanisms of the past—commercial, legal, and reputational support—have not carried over to this new model. The author argues that this shift introduces serious, often overlooked risks, especially for production software where dependency failures can be costly. To mitigate these risks, the article recommends carefully inspecting dependencies before adoption, evaluating factors such as API design, code quality, testing practices, and the state of the project's issue tracker.

What is Software Engineering?

AI 摘要The article defines software engineering as programming that must account for time and other programmers, requiring practices like version control, testing, and modularity to keep code maintainable. It argues that nearly all of Go's distinctive design decisions were motivated by software engineering concerns, citing examples such as gofmt enabling tools to edit source code without formatting changes, and URL-based import paths that eliminate ambiguity and simplify collaboration among programmers.

Go and Dogma

AI 摘要The author observes that discussions among language designers and implementers, including those about Go, are rarely dogmatic because they remember weighing good arguments on both sides of each decision. In contrast, language users sometimes argue zealously as if design choices were infallible, likely because they lack that experience of evaluating trade-offs. He urges the Go community to explain engineering reasons fairly—including the case for alternatives—and to avoid argument by authority, since no decision in Go is wisdom received on stone tablets.

A Tour of Acme

AI 摘要This article introduces acme, a text editor written by Rob Pike for Plan 9 in the early 1990s that is built entirely around the idea of text as the user interface, and presents a screencast demonstrating its basics during a short programming session. The author notes that the video only shows a subset of acme's capabilities and directs readers to Rob Pike's papers to learn more. It also explains how to obtain acme on various operating systems (Plan 9, Unix clones via Plan 9 from User Space, and Windows via acme stand alone complex) and includes a mini-FAQ covering scalable fonts and build requirements.

Minimal Boolean Formulas

AI 摘要The article describes how the author and Alex Healy computed that 28 AND/OR operators are the minimum needed to express any Boolean function of five variables, a previously unknown result. Starting from a brute-force algorithm adapted from the Floyd-Warshall shortest paths method, which could only handle up to four variables, they drastically reduced the search space by exploiting symmetries such as function negation, input permutation, and input inversion. Finally, they replaced the iterate-to-fixed-point loop with a methodical exploration that builds functions in order of complexity, considering each function pair at most once.

Zip Files All The Way Down

AI 摘要This article explains how to create a self-reproducing zip file—one that contains itself, echoing the 'turtles all the way down' idea—building on the classic computer science exercise of writing quines (self-reproducing programs). The author first derives a Python quine, then constructs a Lempel-Ziv compressed data stream that decompresses to itself using only literal and repeat opcodes, including a variant that reproduces itself with arbitrary prefixes and suffixes. Finally, the article addresses the practical challenge of translating this simplified program into the DEFLATE format used by gzip and zip, whose Huffman-coded variable-length opcodes break the fixed-size encoding assumption.

UTF-8: Bits, Bytes, and Benefits

AI 摘要The article explains that UTF-8 encodes Unicode code points (0 through 10FFFF) into byte streams and, by examining the encoding table directly, shows it is far simpler than many people assume. Its design yields convenient properties: full ASCII compatibility and self-representation of ASCII bytes, self-synchronization, byte-based substring search, code point ordering, and no byte-order issues—meaning most 8-bit-safe programs and Unix tools can handle UTF-8 without modification. The main trade-off is the loss of random access by code point index, but since UTF-8 is steadily becoming the standard encoding, the author encourages embracing its well-designed properties.