<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://redvice.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://redvice.org/" rel="alternate" type="text/html" /><updated>2026-10-25T21:42:01+00:00</updated><id>https://redvice.org/feed.xml</id><title type="html">Red Vice</title><subtitle>A blog for technical ranting and rambling</subtitle><author><name>CoffeeFlux</name><email>ryan@luciaonline.net</email></author><entry><title type="html">The Actual State of Machine Translation</title><link href="https://redvice.org/2026/actual-state-of-mtl/" rel="alternate" type="text/html" title="The Actual State of Machine Translation" /><published>2026-10-25T07:01:00+00:00</published><updated>2026-10-25T07:01:00+00:00</updated><id>https://redvice.org/2026/actual-state-of-mtl</id><content type="html" xml:base="https://redvice.org/2026/actual-state-of-mtl/"><![CDATA[<p>I’ve seen a lot of commentary recently on the state of AI translation, and there’s a perspective sorely missing: anyone actually familiar with the industry! I used to work in it, and I still have a lot of friends who are full-time professional translators. I also still maintain a sizable amount of open-source tooling for human translation and subtitling.</p>

<p>Today, I read an <a href="https://www.cs.princeton.edu/~arvindn/talks/icml-2026-annotated-slides/#s25">ICML 2026 keynote</a> by Arvind Narayanan (AI professor at Princeton), which included the following:</p>

<blockquote>
  <p>Translation is a more extreme example [than the radiology one]<sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup>, which kind of blows my mind. AI was almost at human parity nearly a decade ago. Yet the employment of human translators has remained more or less stable, and is projected to remain stable over the next decade. There are many reasons for that, but one reason is that there’s really no ceiling to the amount of things you can translate, and the number of different languages you can translate them into.</p>
</blockquote>

<p>This statement is wildly wrong on multiple levels. For starters, it is unquestionably false that AI was almost at human parity a decade ago. I don’t know if Arvind knows multiple languages, and I’m not familiar with the benchmarking situation for long-form translation<sup id="fnref:2"><a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref">2</a></sup>, but he has certainly never worked in the localization industry.</p>

<p>The language pair I’m most familiar with is Japanese to English. For that pair, machine translation (MTL) was far, far worse than the median human translator; it wasn’t even close. As a consequence, the continued employment of human translators was a no-brainer – there wasn’t a viable alternative! You’d either get mistakes in practically every line, or you involved a human.</p>

<p>There was some use of “machine-assisted translation” on the low end in the industry, but it was mostly just an excuse to cut wages. Actual translators on those projects more or less ignored the machine-translated portion, or spent more time trying to clean it up than it would take to do it from scratch. It wasn’t a meaningful productivity improvement, so it’s not surprising that it had a minimal impact on the labor market. Confident claims about future employment based on this period are nonsensical, as capabilities have dramatically changed.<sup id="fnref:3"><a href="#fn:3" class="footnote" rel="footnote" role="doc-noteref">3</a></sup></p>

<p>The second thing he mentions is that there’s no ceiling to the amount of things you can translate, and many languages to translate into. While I’m skeptical of this claim in some respects<sup id="fnref:4"><a href="#fn:4" class="footnote" rel="footnote" role="doc-noteref">4</a></sup>, let’s take it for granted: even so, there’s no reason to involve a human if the work can be done at higher quality for a hundredth the price. And unfortunately for translators, that is increasingly the situation we are in.</p>

<p>As it stands, LLMs are not particularly great at writing prose from scratch that is pleasant to read, at least to me. The Claudisms are inescapable, the figurative language is florid but nonsensical, the environments are bizarrely inconsistent, and so on. Direct translation work, however, seems to be an exception to this, likely due to the constraints imposed by the task. The models were previously not smart enough to translate complex prose accurately, but this has changed quite recently, at least for Japanese to English. As it stands today, I feel confident in saying that Astra with a proper harness is already in the top 10% of professional human Japanese to English translators at anything other than long-form text, and long-form text coherence for something this constrained is mostly just an engineering problem. As a consequence, I’m deeply skeptical of any claim that employment of human translators will remain robust over the next five years. Japanese to English isn’t a particularly favorable language pair, so I’d expect every other major language to be of comparable quality or reach it shortly.</p>

<p>Let’s go through some specific examples. I’m going to discuss a contemporary Japanese novel, 黄色い家 (localized as <em>Sisters in Yellow</em>).</p>

<p><em>Sisters in Yellow</em> was translated by a pair of university professors, one of whom is a native Japanese speaker and both of whom have a Ph.D. in Japanese literature. It is a fairly competent translation by human standards. If you’re curious about the particulars, I’ve included an auxiliary post <a href="/2026/sisters-in-yellow/">here</a> written by a translator friend of mine. Below, I quote the conclusion in full:</p>

<blockquote>
  <p>Taken as a whole, the Sisters in Yellow translation is a fairly competent human translation that makes relatively few major errors that we would expect to see from an inexperienced language learner or writer. Reading this translation will come reasonably close to reading the original work in another language.</p>

  <p>However, even with two translators (and one Japanese native translator with a B.A. in English literature and a Ph.D. in Japanese literature, at that), there were about fifty grievous errors, a range of five hundred to one thousand more minor errors, and three entire paragraphs cut. That leaves us with an inaccuracy rate between 4.3% and 8.6% -- taken harshly, one may say that around 1 in 12 sentences have some manner of problem or omission. That may come across like a staggering amount for someone who simply wants to read a translation and would be bothered by a dozen problems, let alone a thousand, but surprisingly this still puts the work near the top in terms of translation quality. A truly inexperienced translator duo would have put out work with 1,000 <em>major</em> errors rather than minor, and it is very common for people to read and love translations like those.</p>

  <p>Machine translation powered by cutting edge LLM models, however, gives us something entirely different. It, well, obviously it translated the omitted passages so that’s just an immediate plus, but it avoided every single one of the grievous errors and produced accurate translations. Although one could probably quibble about the exact style of the prose, the focus of this analysis is accuracy; style is more subjective, and a human editor/proofreader (aka not a translator) is more than equipped to handle any prose oddities or what have you. More could be said on that subject but it would distract from the point.</p>

  <p>The point is that a fine human translation put together by two lauded experts was fairly rough beneath the surface; I know I certainly would not want to read a book where every couple of paragraphs I am faced with an inversion of meaning or a just straight-up inaccurate translation. MTL, meanwhile, with its robotic devotion to recreating the original meaning to the best of its increasingly inhumane abilities, nailed every line that the human translators fumbled. Its accuracy rate clears 99% with fewer than 1% of lines containing errors.</p>

  <p>Modern LLM MTL fumbles in places humans are less liable to. MTL by and large won’t misread names, numbers, or anything else that enters its maw as pure data, in contrast to humans just having slips of the mind and such, but instead it tends to fumble actually translating puns instead of just bringing the literal words over. There’s a pun/reference that goes like まさかまさかの坂こえて, with the common language wordplay being that the word for “no way” (masaka) shares a sound with the word for “hill”, so it goes masaka masaka no saka blah blah, and the MTL just gave “crossing over the slope of no-way, no-way,” which is readable but doesn’t preserve the wordplay.</p>

  <p>All in all, even the best human translators tend to slip up and fumble lines over the course of a sizable project like translating a novel, such that even very qualified and skilled ones end up letting errors creep into 4.3% or more of lines. MTL, meanwhile, is at 1% error rate and that is lowering with each new release. It may be that humans have the edge in a very specific subset of moments like translating puns or localizing jokes, but personally speaking I find myself increasingly trusting LLM output more than human output in a vacuum.</p>
</blockquote>

<p>A novel translated by a consistent pair of translators represents a best-case scenario. For most translations, especially in other mediums such as games, the interests of time, cost, and leak prevention mean the work is split up between many translators in far worse conditions. Often, translators (especially at agencies) are given text to translate without the context necessary to do a good job or maintain consistency between each other, and are never meaningfully checked for accuracy. In games, for example, this could mean receiving a spreadsheet of NPC lines without access to or info about the game itself; for television, a script without the video (or with a 240p greyscale watermarked video), etc. This obviously puts the humans at a disadvantage. With AI translation, the work can be fed fairly last-minute into a translation system, complete with available context, and be done promptly and, presumably, with no chance of a leak. There are still some issues with consistency over long-form text, but I believe this to mostly be a tooling issue that no competent engineer has made a serious effort to solve, although even using a generic agentic harness without much further prompting seems to work pretty well.</p>

<p>This, I suspect, means translation agencies will go the way of the dodo, especially as open-source tooling proliferates. Tooling will likely be the blocker on a lot of this – the more text-forward and shorter the translated snippet, the faster I expect it to fall completely. Today, almost every aspect of the localization workflow is human-led. With the strength of modern models, even workflows that retain humans in the loop will do so mainly for consistency checks and image editing rather than the translation itself. So novels will likely be merely proofread by a monolingual human (if at all), video subtitling is not quite a solved problem but is mostly a matter of tooling given how good transcription and coding + vision models have gotten, manga is mostly automatable but may require human image editing for a bit longer, and games are mostly automatable (including the technical work) with playtesters/QC and potentially human image editors. There is dramatically less need for human translators themselves, and image editors and quality control are a lot cheaper, so there is less incentive to automate them out as quickly.</p>

<p>I also expect consumer translation of works to be far, far, far more common than it is today. Fan translation used to be a frankly insane task; you’d spend months or years translating a work for no compensation, purely for love of the subject. But nowadays, with almost no instructions, any third party can get a serviceable result. Additionally, more apps (e-readers, browsers, video players) will build in translation capabilities last-mile, even if they continue to be subpar due to time constraints on generation. When consumer translation is this easy and demand for it present, publishers will be forced to launch with a larger initial catalog of languages, creating even more coordination challenges and expenses, creating even more pressure to utilize AI themselves, and at a faster rate than most diffusion processes go.</p>

<p>There’s probably still work for academic translators, particularly skilled translators, and for prestige projects or comedy/pun-heavy works, though I’m unsure how much longer all those categories will last. But make no mistake: translators whose job primarily consists of receiving a contextless spreadsheet and filling it in will not be around much longer. We’ve finally reached the point where the warnings are true. The best options for continued relevance are leaning more heavily towards “localization” as a holistic process/overseeing the AI/handling challenging lines, editing, pivoting to auxiliary skills like typesetting, leaning more into bilingual marketing more generally, etc. There is also some room for continued work, at least for a while, due to things like model guardrails. In <em>Sisters in Yellow</em>, the model refused to work on the final chapter because it dealt with descriptions of credit card fraud (yes, really), which obviously is not a problem for a human but seems weird, albeit a straightforward fix for a lab.</p>

<p>I expect that most of the value of translation’s commodification will be assumed by adjacent parties in the value chain – the rightsholders themselves and international distributors/marketers. Additionally, the wealth of new available options is a clear consumer benefit. But wrapping back around, telling translators that their jobs will be safe is wildly irresponsible. They are the clear losers in this rebalancing, and while the technology wasn’t there until recently, it’s now only a matter of time. It fills me with great sadness to see multiple industries I’ve been a part of <a href="http://www.catb.org/jargon/html/story-of-mel.html">going the way of Mel</a>.</p>

<hr />

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p>Geoffrey Hinton said a decade ago that “People should stop training radiologists now” due to AI advances. This has held up poorly, at least so far, though I think the quote is more defensible in context. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2">
      <p>Most public benchmarks that anyone bothers to look into are trivially saturated or terrible. The highest-quality benchmark for translation accuracy would require a lot of work from expert humans to grade, and thus I assume it is barely ever done. I have no faith in any automated ones that weren’t trivially saturated. See <a href="https://danluu.com/exercise-7/">https://danluu.com/exercise-7/</a> <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:3">
      <p>When Arvind says it’s projected to remain stable, he’s almost certainly referring to the Bureau of Labor Statistics projections. But these combine translators and interpreters, which are distinct enough jobs (many professional translators could not viably work as interpreters, and vice-versa) that combining them would obscure minor effects on the translator market. <a href="#fnref:3" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:4">
      <p>Unlike a domain like software, where the marginal unit of work offers continual returns for the company, there is <em>not</em> an infinite amount of translation work any given firm wants to engage in. There are other constraints on the value created, such as different cultural expectations around products, and I suspect even with unlimited translation at their fingertips, most places will rely on consumer-side translation instead and conduct business in one or a couple primary languages. Arvind gets this sufficiently wrong for translation that it makes me generally skeptical about his arguments in other domains, but I’m not familiar enough with them to comment. <a href="#fnref:4" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Ryan</name></author><summary type="html"><![CDATA[The state of Japanese-to-English machine translation and what it means for professional translators.]]></summary></entry><entry><title type="html">Sisters in Yellow Translation Analysis</title><link href="https://redvice.org/2026/sisters-in-yellow/" rel="alternate" type="text/html" title="Sisters in Yellow Translation Analysis" /><published>2026-10-25T00:00:00+00:00</published><updated>2026-10-25T00:00:00+00:00</updated><id>https://redvice.org/2026/sisters-in-yellow</id><content type="html" xml:base="https://redvice.org/2026/sisters-in-yellow/"><![CDATA[<p>Hello, I’ll be taking a close look at the professional translation of the Japanese novel 黄色い家 (localized as Sisters in Yellow) and comparing the results to a machine translated version of the novel. The purpose of this analysis will be to highlight that numerous errors inevitably slip into even carefully proofread human translations, and how modern LLM-powered machine translation is scarily accurate in comparison.</p>

<p>Before I begin, I would like to respond to an intuition that many will almost certainly have upon seeing the repeated use of “accurate” and “inaccurate” in this article: “But isn’t translation an artform, where one applies a subjective interpretation of the text to localize it into another language? There is no such thing as accuracy in a context like this; a translation can be superficially inaccurate but spiritually faithful, conveying the intended ideas of the author using other words in order to make a piece of art unto itself.”</p>

<p>While the idea there is sound, over-stressing the “art” of translation is a bit like pretending that paintings magically appear on a canvas directly from the painter’s mind. As Picasso once said, “When art critics get together they talk about Form and Structure and Meaning. When artists get together they talk about where you can buy cheap turpentine.” Similarly, when translation critics get together they talk about Localization and Co-Writing and Art Unto Itself, but when translators get together they talk about accuracy and fluency. There is a distinct difference between a line mistranslated due to a failure of comprehension or understanding and a line purposefully altered for some artistic purpose. The difference itself is subjective to a degree, but in general most familiar with both languages will know them when they see them.</p>

<p>Consider a line in an imagined language that is like: “The rotund elephant lumbered to the fence.” Then imagine that the translation ends up as, “The rhinoceros dashed to the fence.” Clearly something has gone wrong here. One may imagine “rotund” was difficult to understand and so dropped, it looks like “lumbered” was too difficult and got misinterpreted, and then they didn’t recognize “elephant” and maybe thought it was the similarly grey rhino instead. Any reasonable interpretation will just look at this kind of thing and go well, looks like this was a poor translation; it is inaccurate and appears to be unfaithful due to ignorance or lack of ability rather than any artistic purpose. That will be the approach I take with Sisters in Yellow when saying accurate or inaccurate; lines that are obviously altered to fulfill an artistic purpose are A-OK; I only call something an error if it is blatantly a misunderstanding, or alternatively an unnecessary concession that loses nuance for little gain.</p>

<p>With that said, let’s get into the actual comparison and analysis. For full disclosure, LLMs were used to assist in scanning the text and identifying errors at an accelerated rate.</p>

<h2 id="1---overview">1 - Overview</h2>

<p>My analysis of the Sisters in Yellow translation revealed a range from 500 to 1000 distinct errors within the 154,000 words of the published English novel. The wide range there is to provide allowance for personal judgment; if you are very harsh, there’s 1,000 errors, if you’re generous with interpreting certain “inaccuracies” as localization or purposeful adjustments instead, it’s more like 500. If we organize the words into sentences for more clarity, that would be 500-1,000 errors in the 11,500-some sentences of the work, which would put it anywhere between a 4.3% and 8.6% error rate.</p>

<p>All these mathematics are probably off-putting to the more artistically inclined of the audience, but this is the reality of professional translation; to get most translation jobs with publishers, you have to take a long-form test where you translate hundreds of lines, and each inaccuracy is marked against you until you are given a final score based on your accuracy rate. It may seem like this is misunderstanding translation’s nature as an artform or otherwise approaching translation with the completely incorrect mindset, but it’s the opposite: this kind of line-by-line analysis of errors is what determines employment for translators and what most of them need to be conscious of at all times, assuming they are actually under any scrutiny. “Translation is art and it is wrong to discuss error rate percentages” is the same type of privileged layman statement that would come from one who does not need to buy turpentine.</p>

<p>In any case, the good news is that the severity of errors is rather low on average. I will separate translation errors into two classes for the sake of this discussion: grave and minor. Grave I will define as an error which wholly misunderstands the grammar or misrepresents the original language in a way that will drastically alter the intended message. Minor I will define as a partial misunderstanding that impacts the nuance of a sentence but not so much that it necessarily ruins the original intention of the line.</p>

<p>There are about fifty grave errors, but the remaining hundreds are more minor errors: small omissions, slight distortions, simplifications, etc. For example, translating “The rotund elephant” as just “The elephant” to avoid tackling rotund would be considered a minor omission here. So while 4.3% to 8.6% of lines have an error of some kind, most are not incredibly offensive. I would overall describe the Sisters in Yellow translation as very serviceable and clearly done by experienced professionals, but nonetheless the very nature of human fallibility led to the text losing much of its original nuance.</p>

<p>Most bizarre of the errors I found were three completely omitted paragraphs. They were cut cleanly from the original with no attempt whatsoever to preserve their meaning. I can only guess at why they were cut, and to a degree cutting paragraphs doesn’t provide much insight into the quality of the translation as a whole, so I’ll get into those later. For now, I will discuss the more approachable errors of comprehension or inverted meaning. (I’ll refrain from discussing the plot or characters of the novel overall for time concerns; feel free to read the wikipedia page for context if you are unfamiliar.)</p>

<h2 id="2---grave-errors">2 - Grave Errors</h2>

<p>The format for this accuracy checking will be</p>

<ol>
  <li>Japanese line</li>
  <li>English translation</li>
  <li>Explanation</li>
  <li>MTL</li>
  <li>Analysis</li>
</ol>

<p>Wherein I introduce the line and translation, explain the problem, show what MTL did, and then analyze whether the MTL was more accurate. No special prompting or instructions will be given to the LLM beyond “Translate this to English,” with the full Japanese book having been fed into it at the start.</p>

<h3 id="grave-error-1">Grave error 1</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>っていうか、ほんと黄美子さん、捕まるだけあるっていうか、こわいわ。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>I mean, can you imagine being trapped like that, terrifying.</p>
</blockquote>

<p>だけある is grammar that means “someone has the qualities you would expect considering X happened,” more or less, so what this actually means is “no wonder she got arrested, she had it coming / she did stuff to deserve that.” The translation seems to misinterpret this as referring to the character’s situation being kept captive, and the fear as being towards being held captive rather than fear towards her behavior.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Honestly, though, it figures Kimiko got arrested. She’s scary.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-2">Grave error 2</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>血の気が引き、顎がふるえて、わたしはその場にへたりこんだ。早鐘を打つように鼓動が速まり、その振動で視界がゆれるほどだった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>My heart was beating like crazy.</p>
</blockquote>

<p>For full clarity, the English line was moved to the next paragraph, so it was a little confusing to notice this and line them up.</p>

<p>The character here finds out all her money has been stolen and reacts with extreme shock. In the Japanese, it describes: the blood draining from her face, her jaw trembling, her collapsing to the floor, and her heartbeat intensifying <em>to the point that her vision shakes with each pump.</em> This extreme reaction was dramatically simplified to just her “heart beating like crazy.”</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>The blood drained from my face, my jaw trembled, and I collapsed where I stood. My heart pounded like an alarm bell, so hard that the vibration made my vision shake.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-3">Grave error 3</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>玄関は良い運が入ってくるところでトイレは悪いものが出ていくところだから</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>because the entryway was where good luck entered and the bathroom was where it exited.</p>
</blockquote>

<p>This is a little silly. The saying is “good luck comes in through the door and bad luck/bad stuff exits through the toilet. The translation mistakenly says good luck is leaving through the bathroom, which conjures an image of pooping out good luck.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>…because the front entrance is where good luck comes in, and the toilet is where bad things go out.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-4">Grave error 4</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>もし万が一やばいことになるなら、もうとっくに警察きてるから。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>If you’re worried about a worst-case scenario, just remember the police already have her.</p>
</blockquote>

<p>This is a clear misunderstanding of the tense and context. The grammar here is a bit confusing, but it’s important to grasp that the “if” conditional here is applied to the idea “if things had a chance of going bad,” not “if you are WORRIED about things going bad.” From there one interpretation is forced: She’s not saying “the police already have her.” She’s saying “If things had a risk of going bad, the police would already have come.” She’s reassuring the other person that the situation is NOT dangerous, because if it WERE dangerous the police would be involved. She didn’t say anything about the police already having someone.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>If this were ever going to come back on us, the police would’ve shown up ages ago.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-5">Grave error 5</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>人の言うこと、すごい聞くよね</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>[She’s] a good listener.</p>
</blockquote>

<p>Basic misunderstanding of a word. 聞く here means “listen” in the sense of “listens to orders/instructions,” not in general. The intended meaning is that she is obedient.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Yeah. She really does whatever people tell her, doesn’t she?</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-6">Grave error 6</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>痛い思いして産んで、時間もお金もめいっぱいかけてお膳立てしてきてやったのに、できの悪い子どものママにしかなれない自分が可哀想で、愛する娘たちにただただいい人生を歩ませてやりたいと思う一心で今まで精一杯やってきたのに、ママはどうして報われないの、ってまじで泣いてんの。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She’d go on and on, like, ‘Don’t you feel bad for me? I gave birth to you, and all I ever wanted was to set my beloved daughters on the path toward a good life! I’ve done everything for you, put my whole heart into it, so why won’t you show some gratitude?’</p>
</blockquote>

<p>This translation omits and reframes much of the context. First of all, the translation invents the line “don’t you feel bad for me” - rather, the line is describing how the mother is drowning in self-pity and how she doesn’t feel like she has been rewarded for any of the struggles in her life. The translation then cuts out much significant content: that giving birth was painful, that she spent a ton of money on them, that she considers them bad children, etc, and that it’s these things she has never been rewarded for. So the line both misinterprets the thrust while also cutting half the meaning.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>“I went through all that pain giving birth to you, I poured every bit of my time and money into setting everything up for you, and poor me, all I get to be is the mom of kids who turned out rotten. All I’ve ever wanted, with my whole heart, was for my beloved daughters to have a good life, and I’ve given it everything I’ve got, so why doesn’t Mommy ever get anything back?” She seriously cries when she says it.</p>
</blockquote>

<p>MTL is accurate, though the final sentence being in present tense is questionable and the framing of the original TL with “She’d go on and on” is better.</p>

<h3 id="grave-error-7">Grave error 7</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>最近、なんか生きててもしょうがないって思ったりもするけど、花ちゃん見てると、だいじょうぶだって気持ちになる。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Sometimes I feel like I’m just going through the motions, but when I see you, I start to feel okay again.</p>
</blockquote>

<p>生きててもしょうがない means “no point going on living.” It is a strong expression of despair, whereas “going through the motions” is vastly softer.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Lately I sometimes feel like there’s no point in being alive, but when I look at you, Hana, I feel like it’s going to be okay.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-8">Grave error 8</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>琴美さんの小さな顔のなかで青黒くうっ血して腫れたまぶた、切れて血のたれた唇がぱっと頭に浮かんで胸が暗くなった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>My mood darkened as I imagined Kimiko’s delicate face, black and blue, bloodstained, eyes swollen, lip split and bleeding.</p>
</blockquote>

<p>That’s Kotomi (琴美) not Kimiko (黄美子). Just a flat slipup of the person being referred to. Also, somewhat petty, but the description of her “small” (小さな) was replaced with “delicate.” There is a common pattern of darker subject matter being softened like this.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>The moment I said it, Kotomi’s small face flashed into my mind, with its eyelids swollen and bruised a bluish black and its split lip dripping blood, and my heart went dark.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-9">Grave error 9</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>なんか、お人よし</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She’s such a good person.</p>
</blockquote>

<p>Despite appearing like the words “person” + “good,” お人よし actually means someone naive or easily taken advantage of. This foreshadows the mother being taken advantage of but is turned into a general compliment of her being a good person, missing the point entirely.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Kind of too nice for her own good.</p>
</blockquote>

<p>MTL is accurate.</p>

<h3 id="grave-error-10">Grave error 10</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>っていうかなんでその金額がわたしの貯金の額と微妙にぴったしあってんの？</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She’s asking for almost everything I’ve saved.</p>
</blockquote>

<p>The Japanese here is questioning how the speaker’s mother knew almost the exact amount of money that she had saved; she is suspicious about her mother knowing the figure. The English completely glosses over this questioning / confusion and just flatly describes that the mother is asking for that money.</p>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>And anyway, how come that number is so weirdly close to exactly what I’ve got in savings?</p>
</blockquote>

<p>MTL is accurate.</p>

<p>That should do for examples. There are about 50-some errors on this level throughout the work, which isn’t bad at all by human standards, certainly among the upper echelons of translators, but it says a lot that even such experienced professionals let so much slip through. Even experienced professionals can frequently misinterpret words, misread sentences, mysteriously drop entire chunks out of sentences, and… Oh, you know, speaking of omissions, that brings us to the paradoxically most and least severe issue with the translations: the omissions.</p>

<h2 id="3---omissions">3 - Omissions</h2>

<p>In my analysis I noticed a few peculiar omissions. There are three paragraphs from the original Japanese text that I noticed got cut completely out in translation with no effort to adapt them into the surrounding text or preserve the meaning or anything like this. To some, this will be the most damning part of such a translation analysis; there can be no defending a translation choice when there is no translation to defend. However, in my eyes, it’s also one of the <em>least</em> severe issues, simply because I appreciate that at times certain Japanese constructions do not work in English whatsoever and a work will be best improved by simply removing the construction. It’s for this reason I didn’t want to lead with these omissions instead of the more clear comprehension errors; I can imagine the translator had some kind of motive that may have justified the omissions, but I won’t guess on them. I’ll go through them now one by one, with the note that although I am basing this check on the latest epub, with cut paragraphs there’s always the potential for some kind of technical glitch or something.</p>

<h3 id="omission-1">Omission 1</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>ヴィヴさんの後ろを歩きながら、そういえば、こうやって一緒に歩くのって初めてなんだと思った。これまではずっと車の座席に横ならびで、出会ったときも「波」のソファに座ったままだった。ヴィヴさんの顔が小さいのも小柄なのも知っていたけれど、歩いているのを初めて見るヴィヴさんは、わたしが感じていたよりも、もっとずっと小さい感じがした。灰色のジーンズの脚には肉がついていなくて線が細くて、後ろから見るおかっぱの髪型も、なんだか登下校中の子どもを思わせるような雰囲気があった。</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Walking behind Viv, it occurred to me that this was the first time we’d ever walked anywhere together. Until now, we’d always sat side by side in her car, and when we first met, she’d stayed on the sofa at the club the whole time. I knew she had a small face and a slight build, but seeing her walk for the first time, she seemed even smaller than I’d realized. Her legs in their gray jeans were thin, with no flesh on them, and from behind, her bob made her look almost like a kid on her way to or from school.</p>
</blockquote>

<p>This omission is probably the clearest. There has been a pattern through the translation of de-emphasizing any youthfulness or small sizeness from the characters. I will offer no commentary on this because I don’t know their actual intentions, but in general this paragraph is not some unworkable Japanese construction that the translation benefitted from cutting; it should have been kept.</p>

<h3 id="omission-2">Omission 2</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>「でも、この黄美子さんの事件で、なんで花ちゃんが、そんなびびってるわけ？関係なくない？しかも事件じたいは去年のことで、もう裁判も始まってんでしょ？」</p>
</blockquote>

<blockquote>
  <p>わたしは肯いた。</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>“But why are you so freaked out about this Kimiko thing, Hana? It’s got nothing to do with you. Besides, the whole thing happened last year, and the trial’s already started, right?”</p>
</blockquote>

<blockquote>
  <p>I nodded.</p>
</blockquote>

<p>I have absolutely no idea why this was cut. It is possible that this was cut by accident, but I have no idea. As far as I can tell from looking at the passage in-context, it should have been kept.</p>

<h3 id="omission-3">Omission 3</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>そうこうするうちにわたしたちのほかに残っていた最後の住人がハイツを出てしまい、秋のにおいがし始めるころ、わたしは本格的に焦りはじめた。これも最初からわかってはいたことなのだけれど、わたしは部屋を借りるための手つづきを、どこから始めていいのかもよくわかっていなかったのだ。</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Meanwhile, the last of the other tenants moved out of the heights, and by the time autumn was in the air, I’d begun to panic in earnest. I’d known it from the start, but the truth was I had no idea where to even begin when it came to renting a place.</p>
</blockquote>

<p>Again, absolutely no idea why this was cut.</p>

<p>All in all, as stated at the start, these omissions are a mixed bag. In some ways they are flatly the worst parts of the translation: three entire paragraphs cut with no clear motive or intention as to why. I think if I told a random literature lover on the street “Here’s a copy of Moby Dick, but three random passages are cut,” they would find themselves fairly bothered and distracted trying to read it, always wondering what those passages were. For that reason, while I personally do not think too harshly on these omissions compared to the far more relevant and numerous comprehension errors, I can understand that some others may consider this the most damning part of the translation.</p>

<p>I would be interested if any earlier copies of the book have these paragraphs somewhere.</p>

<h2 id="4---minor-errors">4 - Minor Errors</h2>

<p>Okay, and now for the last part of this analysis: the minor errors. At the start of this I stated that there were 500 to 1,000 minor errors, defined as mistakes which lose meaning and nuance without grievously impacting the line overall. A cut adjective, a mixed-up clause, etc. That’s 20x as many as the more grievous errors discussed, so to fully reflect this I should give 200 examples, but instead I will give twenty rapid-fire style just to convey what these errors are like. As a reminder, if one is significantly generous you could probably round that down to 500, but that would be the 500 worst ones remaining.</p>

<p>For this one I will just have the MTL be the third line; it gets these right close to every time so to some degree it will look less like I’m explaining the error and more just reading off the MTL, but this needs to be fast.</p>

<h3 id="minor-error-1">Minor error 1</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>陰ではひとりではなにもできない兄貴の金魚の糞だと、笑いものにしていることもわかっていた。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Yeongsu knew that they were calling him a useless piece of goldfish shit behind his back.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Yeongsu knew that behind his back they laughed at him as his brother’s tagalong, someone who couldn’t do a thing on his own.</p>
</blockquote>

<p>金魚の糞 doesn’t mean literally “goldfish shit,” it means a clingy person / someone who follows someone else everywhere like a follower. One can work backwards to determine how such a person came to be described as a goldfish’s poop.</p>

<h3 id="minor-error-2">Minor error 2</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>どのみち泣き寝入りするしかなかったのだと思うと、わたしの胸は暗く沈んだ。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>My only option was crying myself to sleep—my heart sank into the darkness of that thought.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>When I thought about how, either way, there’d have been no choice but to swallow it and stay quiet, my heart sank into darkness.</p>
</blockquote>

<p>泣き寝入り is a set phrase meaning “giving up and accepting a misfortune/offense” in this case, not literally crying oneself to sleep. This is another case of being familiar with the surface-level words (or looking them up in a dictionary) but not picking up their idiomatic meaning.</p>

<h3 id="minor-error-3">Minor error 3</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>ケツ割られて手がなくて。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She doesn’t have enough people working for her, and they’ve been rippin’ her a new one.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Her people bailed on her, and now she’s short-handed.</p>
</blockquote>

<p>ケツ割られて here means people abandoning work they agreed to do and bailing midway through. Hence her being short-handed. You can see the TL reverse the logic here. “People bailed -&gt; she’s short-handed” got turned into “She’s short-handed -&gt; they’re ripping her a new one.”</p>

<h3 id="minor-error-4">Minor error 4</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>冷静に考えれば、わたしたちのやったことは時効になるのかもしれない。そんなに大きな罪には問われないのかもしれない。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Logically, what we had done was probably already outside the statute of limitations. The punishment might not be all that severe.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>If I think about it calmly, the statute of limitations may have already run out on what we did. Maybe we wouldn’t even be charged with anything that serious.</p>
</blockquote>

<p>“might be” out of the statute of limitation gets turned to “probably,” and then “getting charged with something serious” gets turned to “a punishment potentially being severe.” So it goes from wondering if the statute of limitations has passed and whether the charges would be smaller, to guessing that the limitations had probably passed and they wouldn’t be punished as much.</p>

<h3 id="minor-error-5">Minor error 5</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>昼の人間も夜の人間も…</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Afternooners, evening gamblers…</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>People from the daytime world and people from the night world…</p>
</blockquote>

<p>Admittedly this is a little Japanese-y, but the text here was distinguishing daytime life from the idea of a “night world,” people who are up and about all night instead of sleeping, implying seedier people or what have you. This got turned into “afternooners and evening gamblers” which is just very unusual.</p>

<h3 id="minor-error-6">Minor error 6</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>桃子は去年の暮れにひとりで行った東京ドームの解散コンサートで知りあった子のポケベルと携帯電話を何度も鳴らしてみたけれど、返事はなかった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She tried first paging and then calling a friend she’d made at the Tokyo Dome during X Japan’s reunion concert at the end of last year, but nobody answered.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Momoko kept trying the pager and cell phone of a girl she’d met at the breakup concert at the Tokyo Dome, which she’d gone to alone at the end of last year, but there was no reply.</p>
</blockquote>

<p>解散コンサート, breakup concert, is translated as reunion concert, getting the meaning completely opposite.</p>

<h3 id="minor-error-7">Minor error 7</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>わたしは思わず立ちあがった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>I stood.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Before I knew it, I was on my feet.</p>
</blockquote>

<p>The word “思わず”, being “without thinking” or “on reflex” was cut. You can tell why some of these are only “minor” errors - turning “I stood without thinking” to just “I stood” is hardly damning on its own, but when phrasing like this is simplified or cut a thousand times…</p>

<h3 id="minor-error-8">Minor error 8</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>でも、海外の報道にはだんだん恐ろしいものが増えてきて、先月末頃から今月の頭にかけて、日本もいよいよロックダウンをするとかしないとかの噂が流れはじめた。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>But between the end of February and beginning of March, as news from overseas grew more and more terrifying, rumors of Japan’s own lockdown finally started flying.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>But the reports from overseas grew more and more frightening, and from around the end of last month into the start of this one, rumors began going around about whether Japan would finally lock down too.</p>
</blockquote>

<p>The timeline here should have been late March to early April, the translator seems to mix up the timeline due to adding in specific dates where the Japanese was vague.</p>

<h3 id="minor-error-9">Minor error 9</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>蘭も桃子もなにか買ってきてほしいものはないかとか誰それの新曲がどうとかこうとかメイクしながら楽しそうに話しかけてきたけれど、わたしはそれどころではなかった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>[Kimiko] was in a cheerful mood, and while she put on her makeup and got ready, she chatted about so-and-so’s new hit song and asked if we wanted her to bring back anything—but I was too paranoid to listen.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>While they did their makeup, Ran and Momoko chattered away at me happily, asking if there was anything I wanted them to pick up and going on about so-and-so’s new song, but I was in no state for any of it.</p>
</blockquote>

<p>There is an attribution error here, caused by the verb’s tense; this paragraph starts with Ran and Momoko going out shopping, so the translator assumes it was Kimiko who was chatting to the narrator, but actually this is describing what Ran and Momoko said and did BEFORE leaving. As in, “they chattered away at me while… (then left).” Instead, all of this is incorrectly attributed to Kimiko.</p>

<h3 id="minor-error-10">Minor error 10</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>「つぎのカード、もらうの遅れてるんだね……なんかやばいことでもあったのかな」蘭が画面に目をやったまま、少し不安そうな声で言った。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>“Our next batch of cards seems late. I wonder if something bad happened,” Momoko said uneasily, though she kept her eyes on the TV.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>“The next cards are late, huh… I wonder if something bad happened,” Ran said, her eyes still on the screen, a little anxious.</p>
</blockquote>

<p>Simple line misattribution, it clearly says Ran said the line, but it’s translated as Momoko saying it.</p>

<h3 id="minor-error-11">Minor error 11</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>静香は桃子のことを「ゴリ」と呼び、自分のことを「しー」と呼んでいた。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>So Shizuka called Momoko “Gori” and Momoko called Shizuka “Shi.”</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Shizuka called Momoko “Gori” and referred to herself as “Shi.”</p>
</blockquote>

<p>Weird misinterpretation here, it says “she calls HERSELF Shi,” but the translator for some reason thought it was Momoko who called her that.</p>

<h3 id="minor-error-12">Minor error 12</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>明日また電話するねと言ってわたしは受話器を戻し、席に戻った。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>She promised to call tomorrow, and then we hung up, and I went back to En and Kimiko.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>I said I’d call her again tomorrow, hung up, and went back to my seat.</p>
</blockquote>

<p>It was the narrator who made the promise, not the person she was talking to.</p>

<h3 id="minor-error-13">Minor error 13</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>黄美子さんがこの数ヶ月、ときどき思いだしたようにわたしに渡してくれていた五万円とか十万円というのは、いったいどこから得ていたものなのか。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Every few months, Kimiko handed me fifty thousand or a million, like an afterthought, but where did that money come from?</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Over the past few months, every so often, as if it had just occurred to her, Kimiko had handed me fifty or a hundred thousand yen. Where on earth had it come from?</p>
</blockquote>

<p>For some confusing reason 十万円 is rendered as “a million” instead of “a hundred thousand.” Japanese’s numbering system is a bit confusing due to the base number being 10,000, so in this case the TLer had to do math 10 * 10000 (十 * 万) to get 100,000, and they probably did it wrong and ended up with 1,000,000. But it’s a pretty bad look to mistake a hundred thousand for a million, especially when “she would hand her 50k-100k every few months” gets turned to “50k-1,000k,” a vastly wider gap.</p>

<h3 id="minor-error-14">Minor error 14</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>時給数百円の稼ぎでは今月や来月を生きることはできても、将来を生きるのは無理だった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Even if we got by this month and the next on the hundred-yen-an-hour pay, we wouldn’t be able to keep it up for long.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>A few hundred yen an hour might get us through this month or the next, but there was no living on it in the long run.</p>
</blockquote>

<p>数百円 is “several hundred yen,” with 数 in this case being put before numbers to represent plurality. She’s basically saying anything from “100 to 900” yen per hour with this, but the TLer either doesn’t notice or drops it so we get the incorrect flat “hundred-yen-an-hour” instead.</p>

<h3 id="minor-error-15">Minor error 15</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>お祖母ちゃんが体調を崩して入院するかしないかという話がもちあがり、お祖母ちゃんの金まわりをチェックした親にあっさりと桃子の遣いこみがばれてしまった。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>Momoko’s grandmother got sick, so her parents started talking about whether or not to put her in a home, which meant they checked her bank account and discovered what Momoko had been doing.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Her grandmother’s health took a turn and there was talk of whether she’d have to go into the hospital. When Momoko’s parents looked over her grandmother’s finances, they found out about the money Momoko had been taking, just like that.</p>
</blockquote>

<p>入院 means hospitalization, not being put in a home. She got sick -&gt; might need to go in the hospital.</p>

<h3 id="minor-error-16">Minor error 16</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>でもさ、時間はめぐるよね。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>But time comes for us all.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>But, man, the years just keep rolling around, huh?</p>
</blockquote>

<p>The simple statement that “time flies” / time keeps on moving is turned into a weird statement of mortality, as if she is reflecting on dying soon. I’ll point out the MTL for this line is maybe the worst in the whole thing relevant to this post; I don’t believe “the years keep rolling around” is a real phrase. It’s an over-literal interpretation of めぐる.</p>

<h3 id="minor-error-17">Minor error 17</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>「なんもしてないよ……」</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>“I, I’m not…I’m busy.”</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>“I’m not doing anything…”</p>
</blockquote>

<p>The line, indeed, just says she is not doing anything; no claim is made that she’s busy, which makes the followup nonsensical.</p>

<h3 id="minor-error-18">Minor error 18</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>こちらに気がついた同学年のひとりが、からかうように大きな声をかけてきた。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>One of the girls from my year saw me and started shouting.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>One of the kids from my year noticed me and called out loudly, teasing.</p>
</blockquote>

<p>Teasingly (からかうように) is dropped entirely, missing the tone of the shouting.</p>

<h3 id="minor-error-19">Minor error 19</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>なんでもない毎日が、なんでもない季節のうえを流れてゆき</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>The empty days blended together, and so did the months.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>Uneventful days flowed on over uneventful seasons.</p>
</blockquote>

<p>The word なんでもない here just means ordinary/uneventful, not empty; it’s not criticism or displeasure, and if anything is more comfortable. Also, the “seasons” passing gets turned to “months” which hurts the imagery.</p>

<h3 id="minor-error-20">Minor error 20</h3>

<p><strong>Japanese</strong></p>

<blockquote>
  <p>最初は一緒に取りたてに行ってくれるわよ、相手がいる場合なら交渉とかね。</p>
</blockquote>

<p><strong>Published translation</strong></p>

<blockquote>
  <p>At first, they’ll go out and help you collect from clients, or if you have a partner, they can go negotiate for you.</p>
</blockquote>

<p><strong>Machine translation</strong></p>

<blockquote>
  <p>At first they’ll go collecting with you, and if the other party can be found, they’ll handle the negotiating and all that.</p>
</blockquote>

<p>相手 here refers to the party they go looking for. The kind of abbreviated explanation here makes this less clear, so the translator probably defaulted to the more common meaning of “partner,” but the point is that people will go collecting with her at first and handle the negotiations and stuff so she doesn’t have to. The line becomes nonsensical halfway through in the translation since it imagines them not helping as partners if one already has a partner.</p>

<p>And that should do it. This is a slice of 20 of the more notable minor errors I found, but as mentioned there are anywhere from 480 to 980 more depending on how strict your standards are – whether “without thinking” or “teasingly” being dropped doesn’t matter to you, for example. If you are generous and don’t consider those errors, then this list drops down to closer to 500, but if you are a stickler for those details then the minor error list remains around 1,000.</p>

<h2 id="5---the-credit-card-thing">5 - The Credit Card Thing</h2>

<p>This is a section of the post I did not intend or expect to write, but circumstances have amusingly forced my hand. Completely unbeknownst to me upon choosing the novel to QC at random to avoid bias, the plot of Sisters in Yellow actually involves extensive credit card fraud. Its relevance increases as the story progresses, until the later chapters involve more detailed, explicit explanations of how to commit said fraud. This itself would not be notable at all, but well, in the process of producing a machine translation to compare with the original text, Claude’s safety features triggered and it threw up a massive fuss, just absolutely refusing to translate anything to do with credit card fraud at all.</p>

<p>Jailbreaking LLMs is a well-known matter, but as time goes on the models only get more sophisticated in their ability to subvert such attempts; it would, after all, be pretty bad if a model as smart as Opus 5.5 was used to flagrantly develop biological weaponry or whatever else. Credit card fraud is relatively harmless in comparison, but nevertheless Claude locked up, and it locked up HARD. When it comes to censoring translations, Claude tries to absolutely salt the earth; it will refuse to touch any text even around the offending content, it will insert metadata warning future versions of itself not to touch any part of the forbidden text, and it will, as far as I can tell, absolutely never budge no matter what one says.</p>

<p>Realistically, censorship of this nature is one of the biggest threats to machine translation as a whole: if models get even stricter than this and refuse to translate violence, for example, then a simple action thriller novel could get censored to hell, to say nothing of explicit material itself. However, in practice this is less of an issue for both companies and consumers than one imagine, thanks to the existence of abliterated LLMs and less-censored Chinese/local LLMs. It’s not too difficult to set up a harness that “falls back” to, say, Deepseek if Claude refuses to touch certain content. That’s not ideal, though, and it’s worth being transparent about the fact that Claude refused to touch approximately 25% of Sisters in Yellow’s text due to the credit card fraud within.</p>

<h2 id="6---conclusion">6 - Conclusion</h2>

<p>Taken as a whole, the Sisters in Yellow translation is a fairly competent human translation that makes relatively few major errors that we would expect to see from an inexperienced language learner or writer. Reading this translation will come reasonably close to reading the original work in another language.</p>

<p>However, even with two translators (and one Japanese native translator with a B.A. in English literature and a Ph.D. in Japanese literature, at that), there were about fifty grievous errors, a range of five hundred to one thousand more minor errors, and three entire paragraphs cut. That leaves us with an inaccuracy rate between 4.3% and 8.6% – taken harshly, one may say that around 1 in 12 sentences have some manner of problem or omission. That may come across like a staggering amount for someone who simply wants to read a translation and would be bothered by a dozen problems, let alone a thousand, but surprisingly this still puts the work near the top in terms of translation quality. A truly inexperienced translator duo would have put out work with 1,000 <em>major</em> errors rather than minor, and it is very common for people to read and love translations like those.</p>

<p>Machine translation powered by cutting edge LLM models, however, gives us something entirely different. It, well, obviously it translated the omitted passages so that’s just an immediate plus, but it avoided every single one of the grievous errors and produced accurate translations. Although one could probably quibble about the exact style of the prose, the focus of this analysis is accuracy; style is more subjective, and a human editor/proofreader (aka not a translator) is more than equipped to handle any prose oddities or what have you. More could be said on that subject but it would distract from the point.</p>

<p>The point is that a fine human translation put together by two lauded experts was fairly rough beneath the surface; I know I certainly would not want to read a book where every couple of paragraphs I am faced with an inversion of meaning or a just straight-up inaccurate translation. MTL, meanwhile, with its robotic devotion to recreating the original meaning to the best of its increasingly inhumane abilities, nailed every line that the human translators fumbled. Its accuracy rate clears 99% with fewer than 1% of lines containing errors.</p>

<p>Modern LLM MTL fumbles in places humans are less liable to. MTL by and large won’t misread names, numbers, or anything else that enters its maw as pure data, in contrast to humans just having slips of the mind and such, but instead it tends to fumble actually translating puns instead of just bringing the literal words over. There’s a pun/reference that goes like まさかまさかの坂こえて, with the common language wordplay being that the word for “no way” (masaka) shares a sound with the word for “hill”, so it goes masaka masaka no saka blah blah, and the MTL just gave “crossing over the slope of no-way, no-way,” which is readable but doesn’t preserve the wordplay.</p>

<p>All in all, even the best human translators tend to slip up and fumble lines over the course of a sizable project like translating a novel, such that even very qualified and skilled ones end up letting errors creep into 4.3% or more of lines. MTL, meanwhile, is at 1% error rate and that is lowering with each new release. It may be that humans have the edge in a very specific subset of moments like translating puns or localizing jokes, but personally speaking I find myself increasingly trusting LLM output more than human output in a vacuum.</p>

<p><strong>Model used:</strong> Opus 5.5</p>]]></content><author><name>Anon T. Lator</name></author><summary type="html"><![CDATA[An accuracy analysis of the published English translation of Sisters in Yellow, compared with LLM-powered machine translation.]]></summary></entry><entry><title type="html">GitHub Security Advisory CVE Delays</title><link href="https://redvice.org/2026/github-cve-delays/" rel="alternate" type="text/html" title="GitHub Security Advisory CVE Delays" /><published>2026-10-14T00:00:00+00:00</published><updated>2026-10-14T00:00:00+00:00</updated><id>https://redvice.org/2026/github-cve-delays</id><content type="html" xml:base="https://redvice.org/2026/github-cve-delays/"><![CDATA[<p>Recently, I had someone report an arbitrary code execution vulnerability in Aegisub. It was a pretty simple vuln, but consequential enough that I thought it was worthwhile to put out a security advisory and a CVE. If you’re curious, the actual issue is <a href="https://github.com/TypesettingTools/Aegisub/security/advisories/GHSA-67hq-5vgg-6f23">here</a>.</p>

<p>GitHub advertises their security advisory system as a no-brainer for devs already on the platform. The platform makes it simple to write up the incident, associate it with versions/commits, communicate with everyone involved in the process, maintain a private branch, and various other niceties. Honestly, it’s a well thought out product, and I have no real complaints with this aspect. It’s nice!</p>

<p>GitHub is also a CVE Numbering Authority (CNA), and they encourage you to request the CVE within the product. Theoretically, this is a great experience! It’s certainly easy to fill out their form and hit the button. This reserves the number for your vuln after it’s approved (which their docs claim is usually under 72 hours), and when you publish the advisory it updates with the details so that downstream consumers such as distros can pick it up automatically (again, within 72 hours).</p>

<p>Unfortunately, they aren’t anywhere near those time windows. Not even close. It took me three weeks to get the initial number, and has gotten dramatically worse since, judging by <a href="https://github.com/orgs/community/discussions/202641">other</a> <a href="https://github.com/orgs/community/discussions/203590">commentary</a> <a href="https://github.com/orgs/community/discussions/207039">online</a>. The latest issue in that list has GitHub staff estimating five weeks as the turnaround time. After publishing, I’m not sure how long it normally takes GitHub to update the register with the full details. In my case, it went past the CVE program’s mandated 72-hour deadline, at which point I contacted support to speed it up due to the urgency around packaging.</p>

<p>What to do? Well, for one, GitHub should <em>definitely</em> update their docs to reflect something closer to reality. Had I known I would face these kinds of delays, I would have used a different CNA, or at least investigated the possibility. I’m not sure how slammed they are, but even a week turnaround time would be a blessing compared to my experience here. These delays can hold up publishing fixes, which matters because <a href="https://www.anthropic.com/research/glm-5-3-and-the-spread-of-advanced-cyber-capabilities">the vulnpocalypse is here</a>, and it’s very, very real.</p>

<p>In addition, GitHub needs to find some way to expedite this process. Manual review of all submissions is noble, and hiring is hard, but at this point I think it’s more harmful than helpful to request these through GitHub. If I can’t get a CNA to issue me a number in less than a week, I’m just going to publish without, and anyone not on a rolling-release distro will suffer since they won’t have the fixes backported. Maybe there’s a partnership to be had? I really don’t know, but we need a real fix, because this is clearly not going to work as the flood of vulnerabilities continues.</p>]]></content><author><name>Ryan</name></author><summary type="html"><![CDATA[GitHub's CNA promises CVEs within days, but delivers them in weeks.]]></summary></entry><entry><title type="html">Deterministic Hypervisors For Cheap</title><link href="https://redvice.org/2026/deterministic-hypervisor/" rel="alternate" type="text/html" title="Deterministic Hypervisors For Cheap" /><published>2026-09-18T00:00:00+00:00</published><updated>2026-09-18T00:00:00+00:00</updated><id>https://redvice.org/2026/deterministic-hypervisor</id><content type="html" xml:base="https://redvice.org/2026/deterministic-hypervisor/"><![CDATA[<p>lately ive been horribly nerdsniped with building a deterministic hypervisor. half of this is because it’s a fun project, and i have some other ideas that having a deterministic hypervisor would be useful for. the other half of it is because i saw way too many people who read <a href="https://antithesis.com/blog/deterministic_hypervisor/">antithesis blog posts</a> and decided to write their own deterministic hypervisor - which every time i would then skim the code for and see a half-dozen nondeterminism sources - and because there is no justice on earth thought i could probably do a better job at<sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup>.</p>

<p>first, what even is a deterministic hypervisor? for our purposes, a hypervisor is a program that runs a kernel. specifically, i care about running a linux kernel, and preferably a most-normal kernel - it shouldn’t require substantial patches, although ours will require <em>some</em>. deterministic means that, given the same initial state and making the same set of choices, you end up in the same end state. it’s maybe not obvious why this is difficult - programs, after all, are just state machines. you should be able to model any program as a pure function from <code class="language-plaintext highlighter-rouge">(input state, program)</code> -&gt; <code class="language-plaintext highlighter-rouge">output state</code>. what’s the issue?</p>

<p>the two main issues are to do with concurrency and hardware. a single thread may give you the same output given the same input, but if you have <em>two</em> threads executing at the same time that isn’t the case; if there’s a mutex both threads are trying to acquire, which thread acquires the mutex depends on which actually is able to successfully atomic compare-and-exchange itself as the mutex owner first. this not only depends on when threads <em>start</em>, but also small variation inside the execution. one thread could start first, but then end up performing a load that isn’t in cache and stall its instruction pipeline, so end up losing to the second thread anyway.</p>

<p>the second, hardware, is both simpler and more subtle. reads and writes to hardware will have behavior that depends on state which you may either not be able to guarantee is the same for your “same” initial state, or which evolves over time in ways that you don’t control. a trivial example is RDTSC, which returns the processor timestamp counter - a hardware counter which ticks periodically. worse, hardware nondeterminism also affects <em>interrupts</em>: linux uses a periodic timer for preemptive scheduling, but when that timer expires depends on real world timing that isn’t going to be the same across runs. attempting to instead preempt according to metrics that are entirely controlled by the cpu, such as with performance counters, will have “skid” for when the interrupt for the counter overflow happens and so actually be delivered some number of instructions later even though they are legitimately due.</p>

<p>antithesis and a few of the open source implementations work around this by using a modern Intel x86 feature which delivers “precise” interrupts according to a retired-instructions performance counter; they can arm a countdown for N instructions, and be reasonably sure that it will be delivered &lt;N+M instructions later, and then singlestep up to the same N+M instruction boundary each time. this is unfortunately both Intel specific (and i have an AMD laptop), kinda sketchy, and depends on things like patching KVM or bhyve in order to implement.</p>

<p>it may surprise some hacker news readers but antithesis didn’t invent the concept of a deterministic hypervisor, however. in cybersecurity there’s a long tradition of using deterministic hypervisors for fuzzing: you want to run a program with some input and always get the same behavior, whether program coverage edges or “did the program crash”. historically these hypervisors are usually emulators, in that they emulate x86 instructions in software (e.g. QEMU TCG). the emulator can then “just” make every instruction execute deterministically, and have its implementation of e.g. RDTSC or periodic timer delivery always do the right thing. the solution for multithreading is the same solution as antithesis takes: just don’t do it! if you only ever run one vcpu at a time, then there can never legitimately be two threads of execution happening concurrently and so they can’t have nondeterministic interleavings; you just periodically switch which vcpu is active as part of a hypervisor scheduling policy.</p>

<p>much like the antithesis approach, this is also a kinda bad solution. for one, implementing an x86 emulator that is actually able to boot linux is a lot of work. and for two, emulator based hypervisors aren’t very fast - which is why QEMU has a KVM based backend in the first place, which reintroduces the exact same set of hardware-based nondeterminism that was the issue.</p>

<h2 id="cooperative-scheduling">Cooperative Scheduling</h2>

<p>the hypervisor i wrote sidesteps a lot of issues by being tightly scoped in a very stupid way, which is good enough for my uses: simply never interrupt the guest. instead of timer based preemptive scheduling, i do <em>cooperative</em> scheduling via hypercalls<sup id="fnref:hermit"><a href="#fn:hermit" class="footnote" rel="footnote" role="doc-noteref">2</a></sup>. the linux kernel actually already knows how to do some of this! there is a concept called paravirtualized spinlocks, which is important if you are a kernel which runs under a hypervisor. if you have a thread which is attempting to acquire a lock but it’s already locked, on native hardware you don’t want to immediately block on it etc. because most locks are held for a very short amount of time. you can instead spin on the lock for a while, which is a tight loop where you repeatedly try to acquire it again - while you’re executing the loop real life time is passing, and so other cores are also executing and the holder is likely to release the lock without you having to block and then get woken up. this isn’t the case under a hypervisor however! a hypervisor may run a guest with more vcpus than there are real cpus, or oversubscribe vcpus across multiple guests.</p>

<p>worse, the hypervisor may have its <em>own</em> scheduler on top of the guest kernel scheduler, and not know which locks are held by the vcpus at the time it interrupts their execution, and so the vcpu that holds the lock may be busy running in another guest that has higher priority and <em>never</em> be released unless the hypervisor is informed something is now blocking on that vcpu releasing its lock. in this case spinning on a lock may <em>never</em> make any progress, and is always wasted work. linux implements paravirtualized spinlocks through the pvspinlock feature, which is detected by a CPUID leaf indicating a hypervisor is present being set.</p>

<p>really, all scheduling decisions under the guest kernel can be thought of as a similar class of behavior: every thread runs a sequence of operations and then either completes, or ends up waiting on another thread or an external resource.</p>

<p>what we want is a way to have every synchronization point marked with a hypercall, so that we can do a context switch there to another thread or inject hypervisor managed timers. my solution was to patch the arch/x86 intrinsic for <code class="language-plaintext highlighter-rouge">cpu_relax</code> and <code class="language-plaintext highlighter-rouge">HLT</code> to issue a hypercall yield in a similar way to paravirtualized locks. the reasoning is that even non-paravirtualized spinlocks, which never halt, still are supposed to <code class="language-plaintext highlighter-rouge">cpu_relax</code> in order to hint to the cpu that they can’t progress without an external change; if there are instead kernel tasks which <em>do</em> block, then the base case of the kernel scheduler having no remaining things to run is it <code class="language-plaintext highlighter-rouge">HLT</code>s and waits for a timer interrupt to wake it up again.</p>

<p>by turning these into hypercall yields and only delivering due external interrupts at those same points, we can think of the guest kernel as executing one atomic operation section every time we resume it. it will run from its resume point to the next hypercall yield: we don’t have to worry about it running fewer or more instructions than previous runs, because the last instruction it ran is always going to be another yield<sup id="fnref:unobservable"><a href="#fn:unobservable" class="footnote" rel="footnote" role="doc-noteref">3</a></sup>. although the guest <em>userspace</em> is completely uninstrumented, it also becomes deterministic: it is simply never preempted by the kernel for a context switch, and only switches to another thread by yielding back to the kernel via syscalls. this is bad in a few ways. crucially, a guest program which does a series of instructions without any syscalls in between will always execute the full set without any interleavings from other threads, and so while atomics execute <em>deterministically</em> you can’t force data races or some behavior that a normal linux userspace would be able to observe. as well, a guest which executes a bare spinlock with no yields to the kernel will livelock the entire guest. however, <code class="language-plaintext highlighter-rouge">futex</code> still executes a syscall along with <code class="language-plaintext highlighter-rouge">sched_yield</code>, so you can still force some interesting interleaving, and the baseline determinism model is good enough for my specific usecase.</p>

<p>the good side is that unlike the antithesis model, this is kind of shockingly easy to implement and sidesteps many annoying or hard hardware details because you don’t depend on hardware for scheduling decisions at all! my hypervisor runs on stock KVM, without requiring a custom host kernel or module to be loaded, which both makes my life a lot easier and simplifies deploying it places. it also means that it runs on both AMD and Intel, and doesn’t require any modern or high-end processors with specific hardware features.</p>

<p>once that is done, we just need to also disable all the nondeterministic hardware pieces. instead of using a native hardware periodic timer, we have linux use a virtual timer that it arms via another hypercall, and which we only advance the time of when we get hypercall yields. we also stub out the clocksource, instead having linux read a hypervisor published memory location with the same virtual time<sup id="fnref:rdtsc"><a href="#fn:rdtsc" class="footnote" rel="footnote" role="doc-noteref">4</a></sup>. we mask out a bunch of CPUID leaves exposing hypervisor-provided data, which likewise would leak host nondeterministic information.<sup id="fnref:rdrand"><a href="#fn:rdrand" class="footnote" rel="footnote" role="doc-noteref">5</a></sup></p>

<p>we also turn IPIs into hypercalls for a similar reason. a core attempting to deliver an IPI to another via the native host hardware is <em>mostly</em> deterministic, but there are circumstances where they aren’t either. with a host AVIC, the ICR busy bit will stay set for a nondeterministic amount of time that depends on host hardware state and whether any VMExits happen between the write and read, which ends up causing <code class="language-plaintext highlighter-rouge">apic_wait_icr_idle</code> to occasionally spin one fewer <code class="language-plaintext highlighter-rouge">cpu_relax</code> and diverge in execution. turning them into hypercalls helps us anyway because it allows the hypervisor scheduler to keep track of which vcpus are enabled or not, so it’s not all bad.</p>

<h2 id="when-it-breaks">When it breaks</h2>

<p>time for some fun war stories. the worst issue to debug from this was one which took me 5 days to nail down in my free time. i have some differential testing harnesses that i use in order to verify that the hypervisor is deterministic: if you boot a hypervisor and snapshot it, run it to a user shell, and then restore the snapshot and run it to the user shell again, the end state should be the same every time. in order to test this you can run two forks from the same initial snapshot and then compare their end states exactly, by taking another pair of snapshots and then compare them to each other. i do this in a bunch of different ways, such as one hypervisor running all the way to the end while the second takes another snapshot or resets periodically, or taking a reservoir sampling subset of intermediate states and running each intermediate state to the end as well. these were very useful at tracking down issues.</p>

<p>one of these tests was periodically failing however. about 10% of the time, a test that two forks of an initial snapshot repeatedly booting in parallel on two threads would fail…with the busybox shell at the very end hitting an AddressSanitizer crash.</p>

<p>this is very weird to say the least? the point of these tests is to find nondeterminism events, but even being accidentally nondeterministic shouldn’t ever <em>crash</em>, and definitely not crash <em>in userspace</em>. even weirder, after some initial triage i discovered that even with only a single thread the same test harness would hit the same crash, but at a 0.6% failure rate instead.</p>

<p>a fun trick you can do with a deterministic hypervisor is timetravel. because you know the execution from any point on a timeline should end at the same end state, you can “step backwards” by just repeatedly running from 0-&gt;N, and then 0-&gt;N-1, etc. further, you can <em>bisect</em> even a nondeterministic crash like this because you know that there are two outcomes: either the run is exactly the same as a “golden” run, or the run is different in some way and a “mutant”. you can repeatedly run the guest from some point and then compare it against a golden run at the same point, and see if you ever see a mutant. if you have N states, you can do this at N/2, and then see if the mutant stops appearing: if so, then the divergence that causes mutant probably shows up before it, and you can try again at N/4. in reality it turns out it’s a bit more complicated than that (the mutant rate being so low means there’s false negatives, and some bugs have nondeterministic side effects that only show up some number of events later and bisecting inside that window makes it disappear, so you need backtracking), but it’s a cute trick that i’d been using previously to track down the exact hypervisor step that causes the state to diverge. once you bisect down to the individual step that diverges, you can then continue bisecting down with singlestepping inside that to the <em>instruction</em> that diverges.</p>

<p>the trick also didn’t work for this bug. nondeterminism means there’s something odd going on, and so running to the N pivot state or checking for the divergence in the first place would perturb conditions enough the bug stopped appearing. singlestepping for example is slow, and so i had to instead use execute breakpoints based on a full golden trace and how many times the instruction shows up prior to the pivot position. i fixed a half dozen other minor correctness bugs while trying to get the bisection working better<sup id="fnref:bugs"><a href="#fn:bugs" class="footnote" rel="footnote" role="doc-noteref">6</a></sup> . eventually i was able to get my bisection harness to a point where it could reliably bisect to the individual instruction that was crashing…which to my surprise was literally the busybox load of shadow memory for AddressSanitizer, and not some memory corruption previously that had a butterfly effect, or something related to interrupt delivery messing up. on the instruction after the load the register state in the mutant would contain eax=0xcccccccc while the golden runs would contain eax=416, despite a full memory snapshot at that point being exactly the same.</p>

<p>the answer, my friends, was related to TLBs. when i was doing snapshot save i was capturing memory and the value of all registers, including MSRs. on snapshot restore i was restoring all memory and resetting all of these registers in the current KVM state via ioctls - in order to have fast snapshot restore, we don’t create a new KVM instance and reuse an existing one. despite restoring the contents of the page table and the relevant MSRs, the snapshot restore wasn’t invalidating TLBs because <code class="language-plaintext highlighter-rouge">cr0</code> and <code class="language-plaintext highlighter-rouge">cr3</code> were the same <em>value</em> after the restore, and so KVM sees that nothing has changed in the guest. the busybox program just so happened to call mmap during its execution, and we were restoring the snapshot to a state where the page table was different and that mmap hadn’t been executed yet, but TLB was still present. this stale TLB was 0.6% of the time surviving through 1227 hypervisor steps up to another load at the same virtual address and then loading from the wrong physical. running multiple threads just made the bug show up more often because the thread was less likely to migrate across cores during execution. the solution turns out to do <em>two</em> <code class="language-plaintext highlighter-rouge">KVM_SET_SREGS</code> ioctls, one with an intentionally changed <code class="language-plaintext highlighter-rouge">cr0</code> value in order to force KVM to do a TLB flush.</p>

<h2 id="ssh">SSH</h2>

<p>for fun i threw together a demo of the hypervisor so i could show it off to coworkers. the demo is an ssh server that can be connected to with a normal ssh client, using the <code class="language-plaintext highlighter-rouge">russh</code> crate. the ssh server boots an initial hypervisor to a shell and then snapshots it to use as a forkserver, and gives each connected client an independent copy of that state. i even added a stupid file upload feature for sftp over an ssh <code class="language-plaintext highlighter-rouge">-oControlMaster</code> session that adds the file to the mounted virtio-9p filesystem so you can upload programs to run in the virtual machine. i had an agent throw together a cute little TUI and timeline view and implemented keybinds so that you can take new snapshots or navigate backwards and forwards through them, including across branches in history. the demo is just a <code class="language-plaintext highlighter-rouge">pexpect</code> script driving ssh.</p>

<script src="https://asciinema.org/a/zIN1p5P6dvGkWgPH.js" id="asciicast-zIN1p5P6dvGkWgPH" async="true"></script>

<p>this took me a surprisingly large amount of time to get working, but for really dumb reasons. i thought my deterministic hypervisor was broken and not actually deterministic for way too long, because i kept getting different outputs from the intentionally-data-racey program. it turns out that even driving the guest with <code class="language-plaintext highlighter-rouge">pexpect</code>, <em>when</em> the scripted inputs were arriving was variable, and so the keypresses were being injected into the guest at different times and causing the guest state to differ - something that in hindsight is extremely obvious. of course external keypresses aren’t going to happen at the same time!</p>

<p>i ended up needing to implement a very stupid rendezvous protocol between the hypervisor and the ssh server that is driving it. at a deterministic point in execution (eg every 500 hypervisor steps or whatever, which is a counter that will always be the same across runs) we can potentially publish a sealed batch of user input. that batch contains all the user input that has been buffered since the last batch was sealed, and batches are only sealed when the user is <em>idle</em> and doesn’t type for a few milliseconds. this does a decent job at masking jitter in user keypress timings from the hypervisor, with the difference in which rendezvous point the batch gets published only changing if the accumulated timing differences across the entire batch is longer than the length between rendezvous windows.</p>

<p>i wanted to put this on the internet and give everyone at my company access to mess around, but then i remembered that there’s actually been like <a href="https://github.com/V4bel/Januscape">3</a> <a href="https://github.com/V4bel/Zapscape">different</a> <a href="https://www.cve.org/CVERecord?id=CVE-2026-89929">KVM</a> hypervisor escapes in the past month (and someone at my company would definitely be the type of person to <a href="https://redvice.org/assets/pdfs/minecraft2025.pdf">use an N-day hypervisor escape to mess with me</a>) and also if you have a public SSH server on the internet it will be immediately spammed by bots. maybe i’ll setup tailscale or something.</p>

<h2 id="the-ai-part">The AI Part</h2>

<p>talking about ai coding is basically the programming version of talking about a dream you had last night. no one really cares and it mostly doesn’t matter. however since this experiment half started due to ai, i feel like i should also mention that 1) i have been writing this mostly with ai 2) ai is stunningly bad at writing hypervisors, or really most precise systems software ive tried. to keep it brief and actionable, i basically knew exactly how i wanted to write this hypervisor with the exact mechanisms and behavior i wanted for all the stuff i explained above, and sat down and spent over a week just outlining all the hard behavior requirements for the system in terms of MUST/MUST NOT language before writing a single line of code. i also outlined an implementation plan step by step, plus at each step a series of tests that must be implemented - including for each a negative variant that injects the incorrect behavior to assert the positive test is actually able to catch it. i even used ai to implement a TLA+ model of the hypervisor scheduler (which was actually pretty useful because i don’t actually know TLA+, and it helped me tease out some nonobvious behavior that flowed into the requirements and plan).</p>

<p>and still at almost literally every step the ai has fucked up the implementation in severe ways. even with the most explicit and clear instructions i could think of giving it, with a formal model of the required behavior, using the existing rust-vmm crate that firecracker uses with explicit instructions to not from-scratch implement as much behavior as possible, with the vast majority of the work not novel and fairly “boring”, it will fail at implementing the prescribed requirements in the way i tell it to.</p>

<p>worse, most of the time it would implement behavior that <em>appears correct</em>, and usually even passes “the tests” that i outlined for it to write - until i discover that it is silently horribly wrong in ways that is only apparent days later when i read it again, because my code review was lacking (and the two rounds of ai code review, which i also am extremely explicit in outlining, also did not do 70% of their instructions and approved the patchset as well), and the tests i told it to write were not the tests it implemented. repeatedly these were things that i very clearly instructed it to do, because they were the implementation approach that i knew would work, and even explained in the plan why we must do X and not Y, only for the agent to not do X and wing it in a different way anyway.</p>

<p>most of these are not subtle, small things, but things like me literally enumerating functions for it to patch and then the ai only patching 2 of the 6 instead. because this is precise work i am intentionally trying to go as slowly and methodically as possible and my takeaway is that ai is categorically unable to do precise work, and for most of the implementation plan steps it overall would have been faster to do it myself. and because talking about ai coding is like the hazy, shifting world of a dream, the takeaway of people from will be more amorphous feedback that im just prompting it wrong, or im using too old of a model, or im using too new of a model, or i just didn’t use <em>enough</em> ai, or really it’s unreasonable to expect ai to write correct code. anyway ai part over.</p>

<h2 id="conclusion">Conclusion</h2>

<p>all together it’s been really fun working on this, and honestly didn’t take me very long. including the week spent just outlining the entire thing, it only took me around 4 weeks of effort after work to implement - which is mostly because it really is conceptually a very simple approach. while still strictly less powerful than something like a QEMU based deterministic hypervisor, it being the type of thing you can throw together in a few weeks i think is very cute. having a nice api also means that i can use it for later side-projects easily even if they don’t actually need determinism, and it’s just fun to mess around with: i was able to implement an extension that stubs out functions by kernel symbol name using hardware execute breakpoints in like 20 minutes for example.</p>

<p>i plan on open sourcing most of this eventually. right now the code is, generously, awful to read - mostly because claude seemingly does not understand the concept of comments and just writes gobbledegook for tens of lines, no matter how strictly you tell it not to. i would want to clean up all the factually incorrect and overly verbose comments, as well as read over the entire thing again to fix all the obvious bugs that it definitely still snuck in, before that. i think the conceptual idea is simple enough that hopefully this post was informative and entertaining even without the code.</p>

<hr />
<p>Footnote:</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p>unlike probably most of those people, i actually have <a href="https://redvice.org/2026/coverage-the-wrong-way/">written</a> a hypervisor before and knew a bunch about x86 low level details before starting the project. which i sure would hope would give me a leg up. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:hermit">
      <p>this itself isn’t a novel approach either, to be clear. Facebook’s <a href="https://github.com/facebookexperimental/hermit">Hermit</a> takes a similar approach for determinisim just with ptrace, and it’s also the entire idea behind concurrency testing libraries like <a href="https://github.com/cmu-pasta/fray">Fray</a>, <a href="https://docs.rs/shuttle/latest/shuttle/">Shuttle</a>, and <a href="https://docs.rs/loom/latest/loom/">Loom</a>. <a href="#fnref:hermit" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:unobservable">
      <p>this isn’t actually true. in reality, under a hypervisor the guest will be taking a lot of interrupts and VMExits - but these exits are never observable or influence behavior. we just continue from the same place after, unlike if you were to use preemption as a scheduling decision or if you had externally-triggered interrupts pending which could be delivered on the VMEnter. which is the important property, and means that thinking about the guest in terms of atomic sections is still semantically correct. <a href="#fnref:unobservable" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:rdtsc">
      <p>annoyingly, this shouldn’t even technically be needed - both AMD and Intel actually have hypervisor features to mask RDTSC in hardware such that it takes a VMExit to the hypervisor which can inject its own value - and KVM even can use this feature and handle the resulting event. however in their infinite wisdom KVM also doesn’t expose that event to userspace, and always handles the event by forwarding the host RDTSC value plus some user configured offset, which is the exact behavior we don’t want and so completely useless and we have no choice but to have the linux guest not use it anyway. this unfortunately does leave a gap in our deterministic hypervisor where the linux <em>userspace</em> could perform a RDTSC and read the nondeterministic timer value, which im currently just ignoring because my current usecase never hits. i think you could maybe hack up the guest kernel to also set <code class="language-plaintext highlighter-rouge">CR4.TSD</code> and handle the #GP by injecting the virtual time into userspace? you cant mask TSC from the kernel with that CR bit, only userspace, so i havent bothered with it yet. even if KVM did let me use the hypervisor features for masking out RDTSC from the guest entirely, reading a published memory location also means that the guest kernel doesn’t need to take a VMExit every time it wants the current time which is very expensive, so you’d really want to have it use an alternative clocksource anyway. <a href="#fnref:rdtsc" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:rdrand">
      <p>similar to RDTSC, we also have nondeterminism around RDRAND and RDSEED - which AMD doesn’t support disabling via virtualization features at all. we just mask out the CPUID leaf that <em>indicates</em> support so that the guest doesn’t try using it, and assume that the guest is well-behaved or else it’s not our problem. under Intel masking the CPUID leaf has KVM disable the instrucion via virtualization feature, so it’s not terrible at least. <a href="#fnref:rdrand" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:bugs">
      <p>in no particular order: a singlestepping guest that has a pending KVM <code class="language-plaintext highlighter-rouge">complete_user_io</code> flag not only needs to drain it via a blank KVM run on snapshot but also restore, KVM hypervisor #PF exits from the host user memory being migrated to a huge page is visible in the <code class="language-plaintext highlighter-rouge">KVM_GET_VCPU_EVENTS</code> array and needs to be ignored in the snapshot diff, AMD SVM doesn’t support hypervisor-based singlestepping and so sets TF in the guest which is visible in the pushed eflags from an interrupt, rust-vmm’s SerialConsole pulses the IRQ trigger line on creation which was giving a debugging observer 1 extra IRQ count after a snapshot restore, x86 XSTATE snapshot restore would have skipped AVX512 registers if my laptop supported them, and probably more im forgetting. <a href="#fnref:bugs" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[Creating a deterministic hypervisor the easy way.]]></summary></entry><entry><title type="html">Pebble PMD Friend Areas</title><link href="https://redvice.org/2026/pebble-mystery-dungeon/" rel="alternate" type="text/html" title="Pebble PMD Friend Areas" /><published>2026-08-02T00:00:00+00:00</published><updated>2026-08-02T00:00:00+00:00</updated><id>https://redvice.org/2026/pebble-mystery-dungeon</id><content type="html" xml:base="https://redvice.org/2026/pebble-mystery-dungeon/"><![CDATA[<p>The Pebble Time 2 is a smartwatch that is the spiritual successor to the <a href="https://en.wikipedia.org/wiki/Pebble_(watch)">original Pebble smartwatch</a>. The original Pebble was funded through Kickstarter in 2012, and was notable for using an E-Ink display like the Amazon Kindle does instead of a full LCD - which means it could have a battery life that lasted multiple weeks. Pebble eventually released additional products, like the Pebble Time which used a color E-Paper display instead of purely black and white, and the company was eventually sold to Fitbit (who were later sold to Google). Eric Migicovsky, the original founder of Pebble, created a new Kickstarter for the Pebble Time 2 through a new company, Core Devices, in 2025, for the Pebble Time 2: an updated Pebble Time with a higher display resolution and more hardware resources, and using a fork of the original Pebble firmware which was open sourced by Google at the request of the Pebble community.</p>

<p>I never had any of the original Pebble watches, but thought they were really cool when I was younger, and had the idea in the back of my head to buy one of them off eBay to mess with for a while. When I saw the new Kickstarter I decided to back it as an excuse to finally get one. My Pebble Time 2 arrived in March of 2026, and it’s definitely pretty cool! I quickly hacked up a Pokemon Go style app that will spawn random pokemon based on step count, using the local weather and time of day, which was surprisingly easy. The Pebble SDK is just C for the watch-side and JavaScript for the phone-side, and makes it very quick to throw together.</p>

<p>A week or two ago I found my old 3DS, though, and discovered that it still had my copy of <a href="https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Mystery_Dungeon:_Explorers_of_Sky">Pokemon Mystery Dungeon Explorers of Sky</a> in it. PMD Explorers is what I considered my favorite video game of all time, but thinking about it I hadn’t actually played it in probably 10 years. I decided to play through a rom hack for it to mix things up (it turns out homebrew for the 3DS is very easy these days), and settled on <a href="https://projectpokemon.org/home/forums/topic/65639-pokemon-mystery-dungeon-explorers-of-fortune/">Explorers of Fortune</a>. It turns out, yup: it’s still a really good game. The art style and all the spritework is extremely charming and so, so much better than the modern 3D pokemon games, and crawling through randomly generated dungeons as pokemon is still really fun. There’s a surprisingly large fan community for Pokemon Mystery Dungeon still after all of these years specifically because they nailed the art style so well - there are <a href="https://sprites.pmdcollab.org/">fan-created sprites</a> and character portraits for most of the pokemon of later generations, and between them and custom fan-made tooling like <a href="https://skytemple.org/">SkyTemple</a> romhacks like Explorers of Fortune are able to add hundreds of new pokemon to the original Explorers of Sky.</p>

<p>I remembered seeing that one of the apps that was released for the Pebble Time 2, taking advantage of its additional hardware resources, was <a href="https://apps.repebble.com/pok-pet_b08bfe3c07594533a6931c3a">PokePets</a> which uses the pokemon and dungeon sprites from Pokemon Mystery Dungeon for a Tamagotchi-style virtual pet. After getting back on a Mystery Dungeon kick, I found that one of the SkyTemple developers also made a cute <a href="https://github.com/theCapypara/PebbleTimeGear">Time Gear</a> watchface using ripped background assets, which I used on my watch for a while.</p>

<p>I eventually decided that it would be cool if I could have the pokemon sprites from Mystery Dungeon on a watchface, but with the full movement sheets instead of just standing in place like the PokePets watchface does. I remembered that Pokemon Mystery Dungeon: Red and Blue Rescue Team, the <em>original</em> Pokemon Mystery Dungeon that Explorers is a sequel to, had a bunch of “friend areas”: when you recruit a pokemon to your adventure team, they go hang out in an overworld section that is thematically themed similar to them. In fact, RBRT had 54 different friend areas! I could have a watchface that cycled randomly through the friend areas and then have a pokemon wander around.</p>

<p>There are a few issues with this plan. For one, the Pebble Time 2, despite having more hardware resources than the original, is still a watch. It <a href="https://developer.rebble.io/guides/tools-and-resources/hardware-information/">has</a> a 240MHz ARM processor, 128kB of RAM available for apps, and a 200x228 64 color display. While practically extravagant compared to a lot of MCUs, that’s still not that much memory! Just a 200x288 bitmap being stored in memory will consume 45kB of your RAM, for example. I initially tried having the friend area backgrounds (lovingly downloaded from <a href="https://bulbapedia.bulbagarden.net/wiki/Friend_Area">Bulbapedia</a>) all stored on the Pebble, and then cropped in software to a random subset before displaying on the watch - and immediately started OOM’ing. Oops.</p>

<p>My Pokemon Go app, however, already had code to stream PNGs from the phone-side JavaScript to the watch, because I wanted to support all of the pokemon I could and hit similar resource constraints; there simply isn’t enough flash or ROM to store all of the sprites. For the friend areas I decided to instead go further and have them be processed by a webserver I host on my VPS, and have the phone-side code do a web request to fetch the cropped PNG directly instead of trying to crop the background to the Pebble-size bitmap in JavaScript. Doing this I was able to start getting random crops of the friend area showing up on the Pebble, which was a good first step. I had the friend areas be cached in persist storage and only get cycled every 6 hours, so that it doesn’t need internet or to do PNG decoding (which increases RAM highwater usage) most of the time</p>

<p><img src="../../assets/images/Ancient_Relic.png" alt="Ancient Relic" width="480" height="312" loading="eager" />
<img src="../../assets/images/pebble_screenshot_2026-08-02_14-44-57.png" alt="Ancient Relic cropped on Pebble" width="200" height="228" loading="lazy" /></p>
<blockquote>
  <p>Original PNG for Ancient Relic, and it cropped + quantized for a Pebble</p>
</blockquote>

<p>I wanted to have the pokemon sprite walk around the friend area, though. Since I was already doing cropping on the webserver, I also manually drew collision masks for a bunch of friend areas, and had the Rust webserver also do some random pathfinding on the cropped area. It would use the collision mask to compute the walkable space for the pokemon sprite, and then pick random coordinates and compute A* pathfinding between them, decompose the path into short straight line segments, and send those as waypoints to navigate between to the app. Then when the minute changes on the watchface, or in response to the watch being shaken, the pokemon can walk to the next waypoint and display their walkcycle. This ended up working not that well, with the A* paths being mostly straight lines and not very “interesting”, so I eventually moved to <a href="https://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay triangulation</a> of the walkable space, and then pathfinding between vertexes so that the pokemon “wanders” a bit better.</p>

<p>For the actual pokemon sprite sheet, I’m currently storing all of those on the watch in flash. All of the PMD Collab sprites are hosted on <a href="https://github.com/PMDCollab/RawAsset">GitHub</a>, so pulling them all out and embedding them as bitmap resources in the watchface is easy. Each walking spritesheet is still pretty big, unfortunately: right now the watchface will still occasionally OOM, which I handle by just throwing away bitmaps and picking a random different pokemon or friend area BG, which works well enough. There are two limitations: one, Pebble apps are restricted to only 255 flash resources! There are more than 255 pokemon, so I currently have the build script pick a random ~230 subset of the pokemon to use as the random set to pull from. That means I can’t actually show <em>every</em> pokemon randomly without occasionally updating the app on my watch, but it’s not a huge deal. Two, Pebble apps are restricted to 256kB of resources! This is, funnily enough, actually only enforced for the <em>app store</em> and so sideloading my watchface from the SDK means I can still have as many pokemon as fit in the resources limit.</p>

<p>An alternative approach would be to store all of the pokemon sprites on the phone-side app, and then download them to the watch similar to the friend area background. I think this would probably work fine, and I’ll probably try it later; I’d have to see if there is enough persist storage available in the app, since that is likewise also limited and the friend area bitmap being persisted is already using a lot.</p>

<p>With that and code for drawing the PMD textboxs from PebbleTimeGear, I had a working watchface! It would show a random pokemon, with working walkcycle, and they would wander around the friend areas. The Pebble has a more limited set of only 64 different colors it can display, which means that pixelart’s colors get a bit crushed compared to the original game, but on an actual watch it looks pretty good with only a few exceptions. However, in-game friend areas also had a few other additional effects, which it was lacking. The Nintendo GameBoy and DS were very limited by hardware, but still had animations that would play in some friend areas. One of these effects were used to animate things like the tide rolling in and out, and took advantage of the GameBoy color palette hardware: the original friend area backgrounds use bitmaps that have each pixel map to a palette color, and they would swap out the current palette across frames in order to swap which color pixels would be drawn as! This is a very efficient animation style, because you don’t have to store entire copies of the background bitmap which would blow our RAM limits.
The ripped Bulbapedia friend area images no longer have the palette data information needed to draw the animated color palettes. Luckily, it turns out there’s a GitHub <a href="https://github.com/pret/pmd-red">decompilation project</a> for Red and Blue Rescue Team, which includes the raw assets for the friend areas as well as the reverse engineered code to draw them, and to render the palette animations! I was able to swap from the Bulbapedia assets to use the original ones with a fairly simple preprocessor script that will draw each friend area to a bitmap, and then also collect the N different color palettes.<sup id="fnref:sprites"><a href="#fn:sprites" class="footnote" rel="footnote" role="doc-noteref">1</a></sup></p>

<p>Putting this together on the Pebble…didn’t work. The Pebble has 64 <em>fixed</em> colors instead of the GameBoy’s full 256 colors with limited palette entries, and so the hardware doesn’t actually use any palettes for bitmaps. The actual framebuffer bytes are quantized colors, not palette entries, so you can’t cycle the palette independently of the bitmap pixels, and don’t have enough resources to try dynamically doing the palette conversion directly on the Pebble as the palette swap.</p>

<p>I ended up coming up with a horrible hack, but one that works. In the build step, when I am processing the original game assets to bitmaps, I have an additional step that replaces bitmap pixels that use animated palette colors with sentinel values - using the alpha channel. The Pebble has 64 colors, but bitmaps use a full byte for each pixel because you have alpha bits! I map each unique palette entry to a unique byte with alpha set, which prevents them from being crushed together during quantization, and then on the Pebble when rendering the bitmap modify <em>the framebuffer</em> after copying the bitmap into it, replacing each byte that has alpha set with the corresponding palette color. This ends up actually working, and with it all put together I can cycle a few animated color frames while the pokemon walks around for extra environment effects!</p>

<p><img src="../../assets/images/Enclosed_Island_RTRB_original.gif" alt="Original Enclosed Island" width="480" height="336" loading="lazy" />
<img src="../../assets/images/Enclosed_Island_RTRB.png" alt="Enclosed Island with alpha sentinel values" width="480" height="336" loading="lazy" />
<img src="../../assets/images/emery_1.0.0_20260722-023652.gif" alt="Quantized and animated on Pebble" width="200" height="228" loading="lazy" /></p>
<blockquote>
  <p>Getting the waterfall for Enclosed Island working again is one of the best parts</p>
</blockquote>

<p>I’ve been using this as my watchface for a few weeks at this point, and I still find it very cute to look down at my wrist and see a random pokemon walk around a cool location each time.</p>

<p><img src="../../assets/images/emery_1.0.0_20260722-023838.gif" alt="Power Plant" width="200" height="228" loading="lazy" />
<img src="../../assets/images/emery_1.0.0_20260722-022558.gif" alt="Rub-a-Dub River" width="200" height="228" loading="lazy" />
<img src="../../assets/images/emery_1.0.0_20260802-142500.gif" alt="Gourd Swamp" width="200" height="228" loading="lazy" />
<img src="../../assets/images/emery_1.0.0_20260802-145958.gif" alt="Tadpole Pond" width="200" height="228" loading="lazy" /></p>

<p>Since this is all very generic and all the processing works on the webserver backend, it’s also really easy to add more backgrounds in the future. I plan on adding more overworld maps, like Treasure Town or the different starter houses from Red and Blue Rescue Team, which are mostly the same data format - and in the future, hopefully also add some overworld backgrounds from Pokemon Mystery Dungeon Explorers of Sky as well.</p>

<hr />
<p>Footnote:</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:sprites">
      <p>The original game stores assets compressed and with a chunking scheme to reuse sprite sections. Like the Bulbapedia ripped PNGs, the PMD Collab spritesheets aren’t really designed for resource constrained devices unlike the original game assets, and since I’m now preprocessing assets to extra the friend area backgrounds, I could also probably preprocess the sprite sheets to trim them down and either fit more in ram, or put all the data in flash resources instead of 1 per resource which hits the resource limit - but I haven’t done that yet. <a href="#fnref:sprites" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[Pebble Time 2 watchfaces and Pokemon Mystery Dungeon]]></summary></entry><entry><title type="html">Binary Coverage the Wrong Way</title><link href="https://redvice.org/2026/coverage-the-wrong-way/" rel="alternate" type="text/html" title="Binary Coverage the Wrong Way" /><published>2026-07-03T00:00:00+00:00</published><updated>2026-07-03T00:00:00+00:00</updated><id>https://redvice.org/2026/coverage-the-wrong-way</id><content type="html" xml:base="https://redvice.org/2026/coverage-the-wrong-way/"><![CDATA[<h2 id="the-right-way">The Right Way</h2>
<p>Way back in the age of the dinosaurs, if you wrote a program and wanted to test that it was correct, you mostly had two choices: you could either manually construct malformed inputs and try them in succession, or hook up a program which would randomly generate inputs and try them automatically <sup id="fnref:fuzzing"><a href="#fn:fuzzing" class="footnote" rel="footnote" role="doc-noteref">1</a></sup>. Those programs were called fuzzers, or sometimes generators, and this was “fuzz testing”. It also for quite a long time wasn’t very good: the generator would have no feedback from the program under test except “did this random input crash or not”. This feedback, although useful, doesn’t allow the fuzzer to tell if it is <em>making progress</em> relative to the last random input or doing a good job, and so your fuzzer would just repeatedly hit the same shallow code. You’d leave it running for a week and then when you come back realize it was never generating inputs that would hit interesting parts of your program, and they were all immediately being thrown out or never progressing past a <code class="language-plaintext highlighter-rouge">if(packet_header == 0xdeadbeef)</code> check.</p>

<p><a href="https://lcamtuf.coredump.cx/afl/">American Fuzzy Lop</a> revolutionized the field by introducing <em>coverage-guided</em> fuzzing. Instead of having the only feedback to your fuzzer be whether an input crashed or not, it also recoded what <em>code coverage</em> it hit over the course of a program execution; if an input executes a piece of the program that it never reached before, then it hit new code, and probably is now able to also test some new interesting surface area of the program which might have some bugs. This was immensely more effective than “dumb fuzzing” of yesteryear.</p>

<p>AFL collects coverage for programs by compiling the program under test with a custom clang compiler pass, which adds coverage feedback on CFG edges: if you hit a new basic block in the code, you get a new coverage bitmap entry set<sup id="fnref:ngram"><a href="#fn:ngram" class="footnote" rel="footnote" role="doc-noteref">2</a></sup>. If running the program on an input sets results in a bitmap which has new bits set than previously, it hit new code; that input can be saved to use as the seed input to mutate for future executions.</p>

<p>You can also do feedback based fuzzing for blackbox binaries that you don’t have the source code to. <a href="https://aflplus.plus/">AFL++</a> for example has a <code class="language-plaintext highlighter-rouge">qemu_mode</code> backend: it executes the program under test with <code class="language-plaintext highlighter-rouge">qemu-user</code>, which will lift your x86 assembly to QEMU’s TCG IR and then lower it back with its JIT compiler to x86, but now which can safely execute under its type-2 hypervisor environment. AFL++ has a fork of QEMU which adds a custom TCG hook that adds coverage instrumentation to blocks in the middle-end; the IR for each block is extended with TCG operations that write a coverage bitmap entry the same way that AFL enhances clang IR with extra LLVM operations. Despite sounding like a lot of work, this <code class="language-plaintext highlighter-rouge">qemu_mode</code> is only like ~3-5x slower than running a program natively.</p>

<p>The gold standard for blackbox binary coverage is to let hardware do it for you. Instead of needing to add extra operations to the program under test, which need to be executed when you run a fuzz testcase, you can instead use <a href="https://github.com/intel/libipt">Intel PT</a>. Enabling certain performance counter configuration registers will start processor tracing: your CPU will then automatically record metadata as part of its execution pipeline, and the fuzzer can look at the resulting metadata to pull out a trace of what basic blocks it executed. This is <em>unreasonably</em> effective, with Intel PT based tracing only being something like ~10% slower than normal native execution.</p>

<p>The issue, of course, is that if you’re like me your laptop has an AMD processor and not Intel. AMD have their own magic performance counting features, including a branch trace buffer that records what code is being executed, but its 1) much worse documented 2) much slower than Intel PT 3) impossible to use in a precise manner - that is, the counters are either sampling based and so only give you <code class="language-plaintext highlighter-rouge">1/n</code> events, or may end up dropping events if a metadata buffer fill up before you’re able to drain it. In either case that makes it sadly unsuitable for fuzzing (you technically could build a fuzzer on top of merely stochastic coverage, and it might even not be that bad. But in practice no one has done so, and it’s probably not worth it.)</p>

<p>Which brings me to my bad idea. I wanted to write my own fuzzer for a side-project, and so wanted to collect precise blackbox binary coverage. But didn’t want to write my own dynamic recompilation engine (again), or buy a new laptop. What is a software engineer to do?</p>

<h2 id="the-wrong-way">The Wrong Way</h2>
<p>We can instead instrument the guest code by replacing all the branches with <code class="language-plaintext highlighter-rouge">INT3</code> instructions. Wait come back I can explain.</p>

<p>In order to collect precise coverage we need the program to do something whenever it hits a branch. We can’t insert new behavior in each block, because it already is using all of the bytes in the block for its normal instructions: trying to resize blocks requires fixing up code pointers, and then you’re just back at QEMU-but-bad. The minimal length of a branch instruction is two bytes long: <a href="https://www.felixcloutier.com/x86/jcc">Jcc</a> has a form which is only a single opcode byte plus a displacement to branch with. <code class="language-plaintext highlighter-rouge">INT3</code> is only one instruction long, hijacks control flow in a way that doesn’t clobber GPRs which would prevent continuing execution after the instruction, and gives us the location of the branch that we overwrite as context so we can compute the coverage bitmap entry that we want to record in our coverage map. It’s perfect!</p>

<p>Unfortunately, if you tried to do this on Linux with <code class="language-plaintext highlighter-rouge">ptrace</code> you’d probably want to die. Linux will turn hit <code class="language-plaintext highlighter-rouge">INT3</code> into a SIGTRAP. That can be caught by a <code class="language-plaintext highlighter-rouge">ptrace</code> based debugger that is supervising your process. That signal will include the tracee’s PC and register state, which you could use to implement the coverage hook, and then <code class="language-plaintext highlighter-rouge">PTRACE_CONT</code> to continue the process. It’s just that this entire dance would be several context switches: guest program in ring 3 -&gt; <code class="language-plaintext highlighter-rouge">INT3</code> trap to x86 interrupt handler in ring 0 -&gt; Linux kernel delivers a <code class="language-plaintext highlighter-rouge">ptrace</code> event in your debugger in ring 3 -&gt; your debugger <code class="language-plaintext highlighter-rouge">PTRACE_CONT</code> via syscall to ring 0 -&gt; Linux kernel syscall implementation resumes the guest in ring 3. Each of those context switches are very expensive, especially because context switching between privilege levels requires even more work from your processor than same-ring context switches. Oh, if only there was another way!</p>

<p>The answer, of course, is virtualization extensions. Your computer can run a smaller computer inside of it through the magical power of Intel VT-x (or, as we call it on Linux, <code class="language-plaintext highlighter-rouge">kvm</code>). The code inside the smaller computer thinks it is running completely bare metal: that guest code can configure interrupt handlers and MSRs and paging however it wants, just like a normal kernel, and even run userspace code under the guest kernel <sup id="fnref:hvci"><a href="#fn:hvci" class="footnote" rel="footnote" role="doc-noteref">3</a></sup>. All while, in reality, the guest kernel is being ran in a virtualized machine hosted by your normal Linux kernel; you can configure it so that when the guest kernel tries to do I/O to the real world, they actually trap to the host kernel, which turns them into a userspace event that the “virtual machine manager” can implement and then resume the virtual machine with the result of. Crucially, while the virtual machine is executing, it is <em>executing bare metal</em> - your processor is actually running all of the instructions for the guest VM, and they all use the normal processor state like general purpose registers and hardware page tables, just with some extra bits that say to also do a hypervisor translation for the physical memory so it can’t reach outside the bounds of the VM and things. The important thing is that it means the VM runs at basically 100% native speed, except for when it needs to VMExit back to the host kernel because the guest kernel tried to do something that traps to the hypervisor. It turns out this works so well, in fact, that basically the entire internet runs on top of <code class="language-plaintext highlighter-rouge">kvm</code> in the form of cloud based hypervisors like Firecracker.</p>

<p><a href="https://info.varnish-software.com/blog/tinykvm-the-fastest-sandbox">TinyKVM</a> is a neat project by the author of Varnish<sup id="fnref:varnish"><a href="#fn:varnish" class="footnote" rel="footnote" role="doc-noteref">4</a></sup>. It implements a VMM as a C++ library, which you can use to run arbitrary Linux binaries: it sets up a minimal guest VM with the required x86 processor state to execute usermode code, with a tiny guest kernel that has interrupts which mostly just trap to the VMM in the host. That means that you can run a guest binary in the VM, and when it does a syscall like <code class="language-plaintext highlighter-rouge">write</code> it bubbles up to a VMExit, the host VMM sees that it did a syscall with <code class="language-plaintext highlighter-rouge">rax=1</code> and all the other GPRs for arguments, and then do its own <code class="language-plaintext highlighter-rouge">write</code> syscall with the real FD and arguments on the host.</p>

<p>This doesn’t automatically lets us solve the issue of too many context switches for the <code class="language-plaintext highlighter-rouge">INT3</code> hooks. But because the guest kernel is a full kernel, it can configure the interrupt handle that <code class="language-plaintext highlighter-rouge">INT3</code> context switches to however it wants - and I was able to fork <code class="language-plaintext highlighter-rouge">tinykvm</code> into something I call <a href="https://github.com/chc4/tinycov">TinyCOV</a>, which hacks up the guest kernel a bit. x86 actually has the privilege level for interrupts configured as part of the IDT data structure describing the interrupt gate! That means that we can have <code class="language-plaintext highlighter-rouge">INT3</code> trap from the guest userspace code to the guest kernel interrupt handler but <em>stay</em> in ring 3, and even put our coverage hook implementation directly in the guest “kernel” code to be executed before returning from the interrupt back to continue execution. This cuts down each <code class="language-plaintext highlighter-rouge">INT3</code> coverage hook down to only two context switches, to and from the guest interrupt routine, and zero privilege level changes. And it means we never even need to VMExit either, because the guest kernel is able to handle the interrupt entirely itself instead of needing the VMM to emulate some privileged operation.</p>

<p>Because we overwrite the branch itself with an <code class="language-plaintext highlighter-rouge">INT3</code>, just returning from the interrupt back to where we trapped doesn’t actually work and we’d end up skipping the actual branch operation. Since <code class="language-plaintext highlighter-rouge">INT3</code> is only one byte but the minimum length of a branch is two however, we can use the second byte to record some metadata for the branch hook: we can store an index there, and then use the index plus the offset of the <code class="language-plaintext highlighter-rouge">INT3</code> into the page to uniquely identify the location, and then JIT compile the same branch instruction that we overwrote (but with some jump instructions for either side of the branch back to the original successor instructions). Handling dynamic jumps, like <code class="language-plaintext highlighter-rouge">JNZ rax</code> is a bit trickier, but still possible.</p>

<p>Since we still have the ability to VMExit from the kernel back to the VMM if we want, we also are able to leverage that in order to implement code discovery: <code class="language-plaintext highlighter-rouge">tinycov</code> hooks branch instructions a block at a time, starting from the binary entrypoint. It writes a sentinel value as the metadata byte for the <code class="language-plaintext highlighter-rouge">INT3</code> the first time it hooks a branch, and then in the guest kernel traps to the hypervisor if it sees the coverage hook still has the sentinel value and thus its the first time it’s ran. The VMM is then able to disassemble the successors of the basic block and hook <em>their</em> branches, pushing the code discovery frontier forward, and replace the sentinel value with the correct trampoline index value for the JIT code so that future hits of the branch can stay entirely in the guest kernel.</p>

<h2 id="results">Results</h2>

<p>Despite how scuffed all of this sounds, it does actually work: I’m able to run random binaries under <code class="language-plaintext highlighter-rouge">tinycov</code> and collect a coverage bitmap of code that was hit, plus a mode to instead generate a full program trace. Because it works by hijacking control flow <em>entirely</em>, we can even put arbitrary code in the <code class="language-plaintext highlighter-rouge">INT3</code> kernel handler: I was able to implement <a href="https://github.com/googleprojectzero/CompareCoverage">CmpCOV</a> style dictionary building by recording if a branch ends in a <code class="language-plaintext highlighter-rouge">cmp</code> instruction and recording the register operand value, since the kernel interrupt handler (and the VMM VMExit handler) have access to the full set of GPRs from the program under test synchronously, which you can’t quite do with Intel PT style asynchronous coverage traces.</p>

<p>That said, how fast is <code class="language-plaintext highlighter-rouge">tinycov</code> compared to QEMU? The answer is, uh, really slow. I ran some benchmarks, and it’s like 700% slower - and worse on branch heavy code like <code class="language-plaintext highlighter-rouge">bzip4</code>, which will be taking more <code class="language-plaintext highlighter-rouge">INT3</code> handlers per instruction ran. CPU out-of-order pipelines <em>really</em> don’t like taking an interrupt every few instructions, even if the context switch stays at the same privilege level. I am happy that the idea of using userspace interrupt handlers under <code class="language-plaintext highlighter-rouge">kvm</code> works; I did some benchmarks and it’s like 50% faster than using “proper” ring 3 -&gt; ring 0 interrupts instead! But even 50% faster than doing it the slower way is not enough for this to really be usable when QEMU is so much faster.</p>

<p>Technically, there are some neat things that this would enable you to do which you can’t with QEMU or Intel PT based coverage. For one, because we’re trapping to a single coverage hook which is actually implemented in native code, it’s really easy to add custom coverage hooks: for some fuzzing targets you want to introduce some extra state into the coverage bitmap calculation in order to get the fuzzer to treat identical control flow traces as new program states to continue exploring from, like if you’re fuzzing a language runtime with a virtual PC or some other data-driven loop. If you want to do this with QEMU you have to either write your own TCG hook (hard), or set code callbacks which end up taking a software-VMExit from the JIT code (slow).</p>

<p>Because we’re hooking code in place we also have the ability to <em>unhook</em> code, which I think you could do something cool with. With QEMU the codegen will emit direct branches between JIT blocks to be fast, but the instrumentation being emitted in TCG and thus part of the translated block instructions means that you can’t <em>remove</em> the hook in a block afterwards as you’ll still have those incoming edges. With <code class="language-plaintext highlighter-rouge">tinycov</code> we could remove the coverage hook from branches which we decided “aren’t worth it”, or that we have seen both the <code class="language-plaintext highlighter-rouge">true</code> and <code class="language-plaintext highlighter-rouge">false</code> exits for and so know that it can’t ever lead to new code - meaning that those branches can be rewritten back to their original bytes, and so execute at literally native speed again.</p>

<p>In practice, I think this is mostly just a toy and cute idea, although I am pleased that it works at all. I’ll probably try plugging it in to be used as the coverage collection implementation for <a href="https://dl.acm.org/doi/abs/10.1145/3548606.3560602">LibAFL</a> just to see how much worse it does than QEMU as part of a full fuzzer, but unfortunately no one should really try to use this in production. It was pretty fun to get working though, and I was pleasantly surprised how easy it was to hack up <code class="language-plaintext highlighter-rouge">tinykvm</code> to support the functionality I wanted. Any excuse to do very cursed x86 kernel dev things in a side-project, and staying small enough to actually finish, is a win in my books.</p>

<hr />
<p>Footnote:</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:fuzzing">
      <p>Some people would tell you there was a third option, which was “formally prove your program”. They’re lying to you. <a href="#fnref:fuzzing" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:ngram">
      <p>In reality it’s a bit more complicated; most fuzzers now actually use N-gram coverage, where you combine the last N branches together to calculate the bitmap entry to set in order to expose more path-dependent information. Having some weird coverage metric is still, to a first approximation, recording “what code was hit” though, so the distinction doesn’t matter that much - and if you have some way of recording branch history, you can probably also compute N-gram coverage instead. <a href="#fnref:ngram" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:hvci">
      <p>In fact, if you’re using Windows 11, the “bare metal” Windows kernel you think you’re running has actually been running as a virtualized guest <a href="https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-hvci-enablement">this entire time</a>. Isn’t that kind of neat? <a href="#fnref:hvci" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:varnish">
      <p>Yes, that Varnish. The HTTP cache. <a href="#fnref:varnish" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[Collecting code coverage for blackbox binaries the wrong way.]]></summary></entry><entry><title type="html">Lunacy</title><link href="https://redvice.org/2026/lunacy/" rel="alternate" type="text/html" title="Lunacy" /><published>2026-05-28T00:00:00+00:00</published><updated>2026-05-28T00:00:00+00:00</updated><id>https://redvice.org/2026/lunacy</id><content type="html" xml:base="https://redvice.org/2026/lunacy/"><![CDATA[<h2 id="the-virtue-of-laziness">The virtue of laziness</h2>

<p><a href="https://github.com/chc4/lunacy">Lunacy</a> is a Lua 5.1 interpreter I’ve been working on as a side-project in Rust. Unlike the average Lua interpreter side-project, Lunacy does type specialization of bytecode operations via <a href="https://arxiv.org/abs/1411.0352">Lazy Basic Block Versioning</a> (LBBV), plus includes a Just-in-Time compiler.</p>

<p>LBBV is a pretty cool compilation technique that came out of Maxime Chevalier-Boisvert’s research while at University of Montreal, culminating in her <a href="https://pointersgonewild.com/2022/05/23/minimalism-in-programming-language-design/phdthesis.pdf">PhD thesis</a>, around developing a JavaScript JIT, Higgs. Critically for me, her approach focuses a lot on simplicity: the goal of LBBV is that it is an effective compilation strategy that can be implemented by just one PhD student in a reasonable amount of time, or one engineer as a side-project.</p>

<p>The original LBBV paper is very approachable, and I highly recommend reading it. To summarize, it enables optimizing bytecode operations, such as <code class="language-plaintext highlighter-rouge">ADD</code>, which naively would need to branch on the types of its operands to figure out if it’s adding two numbers or two strings or what have you. Whenever the operation would inspect the type of an operand and check if it matches a type, it can statically be given a pass/fail based on a <em>specialization context</em> for the basic block. If the context doesn’t <em>know</em> the type of the operand, instead of needing to conservatively fall back to a dynamic operation which can handle any value, compilation can instead be suspended to a thunk: the thunk will eventually be forced by execution hitting it at runtime, at which point you can continue compiling with the context now filled with the <em>runtime</em> type of the value promoted to a static type, guarded by a runtime check to validate that later executions of the same codepath use the same type. In the failure case of the guard, you can suspend another thunk that will specialize the operation for the next runtime type you see.</p>

<p>This is very powerful! The end result is that you have blocks which seemingly by magic have type guards only for the types of values that actually were observed at runtime, and for things like loops “for free” unroll one iteration which contains all the type guards, and then have entirely known types inside the hot loop (because that block reached a fixpoint of the specialization context for the loop header, and so reuses the block to form a loop). Because you have the powerful primitive of blocks specialized for a static context based off observed runtime information, you can stuff whatever information in the static context you want and always have a correct “guess” for the value of speculative information. And if you ever end up with too many blocks, no matter what reason, you can fallback to running generic code instead of having exponential block blowup.</p>

<p><img src="/assets/images/lunacy-example-1.jpg" alt="Lunacy IR for sum" width="4892" height="4988" loading="eager" />
<img src="/assets/images/lbbv-example-1.png" alt="LBBV paper IR for sum" width="554" height="440" loading="lazy" /></p>

<blockquote>
  <p>Comparison of Lunacy and Higgs specialized blocks for <code class="language-plaintext highlighter-rouge">sum</code>. Notice how the inner loop body, block <code class="language-plaintext highlighter-rouge">7</code>, ends up with fully specialized <code class="language-plaintext highlighter-rouge">ADD</code> operations for the accumulator and loop induction variable. Lunacy doesn’t do small-integer optimization and so has no overflow checks.</p>
</blockquote>

<p>Lunacy does a few things different from Higgs. For one, Higgs is a <em>pure</em> JIT: it has no interpreter, and immediately compiles all bytecode operations directly to assembly. Lunacy instead is implemented as an interpreter first and a JIT second: bytecode operations are implemented as Rust coroutines, which yield effects. Those effects may be things like “guard on stack slot X being type Y”, which are resumed with results like “the slot matches/fails the guard” - and like LBBV, if the type isn’t currently known, we instead suspend the coroutine inside a thunk via a closure. It may also yield an effect like “add operands A and B together”, which can be implemented so it only cares about how to add numbers since the coroutine would only reach the yield if the required guards matched.</p>

<p>Runtime behavior is emitted as separate residual operations, separate from the actual Lua bytecode operations which are implemented as coroutines that are driven at compile time. In order to avoid having to define and implement runtime behavior for every combination of operand type etc., Lunacy also uses a <a href="https://www.iro.umontreal.ca/~feeley/papers/FeeleyLapalmeCL87.pdf">closure generating</a> interpreter: complex runtime behavior, like adding two numbers, is instead implemented by a closure that captures the bytecode operands such as the stack slot indexes it uses, and at runtime we execute the closure in order to perform the operation. The interpreter repeatedly executes the residual operations that were the result of compiling blocks by running all of the coroutines for the Lua bytecode.</p>

<p>This approach means that the bytecode coroutines in Lunacy were very easy to implement. All of the behavior for an operation, including the different <code class="language-plaintext highlighter-rouge">Residual::Exec</code> variants, are located in a single coroutine which intermixes the static compilation portion via yielded effects and the runtime execution portion via closures which can capture arbitrary static information. Because Rust coroutines even implement <code class="language-plaintext highlighter-rouge">Clone</code>, when we suspend a coroutine to a thunk in order to discover extra information from the runtime behavior we can even push a clone of the same coroutine suspended at the same yieldpoint down into the failure case - essentially forking it, and each fork independently being resumed to compile the remainder of the operation and block with a different observed type. The interpreter itself is very small and simple, because it only has a small set of simple residual operations to handle.</p>

<p>This residual scheme also made implementing the JIT side of the interpreter very easy as well, which was a large portion of why I chose to use closure generation as well: because our set of residual operations is very small, only things like type guards or executing a closure or executing a thunk (itself also a closure), for the JIT we only need to handle how to compile those same small set of residual operations. Instead of needing to maintain a second assembly implementation for all bytecode operations, we can emit a static call to the closure function pointer address in the JIT, which crucially eliminates dynamic dispatch and other things that make modern OoO processors sad. Meanwhile, the remainder of the residual operations such as runtime typeguards we can implement in assembly in ~4 instructions as a native branch, which also can get their own branch predictor entry. The actual JIT is tiny, and mostly consists of some <a href="https://github.com/CensoredUsername/dynasm-rs">DynASM-rs</a> assembly in a <code class="language-plaintext highlighter-rouge">match</code>.</p>

<p>Because Lunacy is a template JIT where most of our operations are function calls, it doesn’t do any register allocation. It just pins the interpreter state to a register in order to move into the function argument ABI for the closure call repeatedly. However, because the closure call ABI has a number of preserved registers, it does leave open opportunities to do <a href="https://arxiv.org/abs/2011.13127">Copy-and-Patch</a> style register windowing using those preserved registers in the future and different residual operations, or use multiple different copies of closures which expect arguments in different registers we can select from during JIT emission.</p>

<p>Unlike Higgs, which immediately JITs all code, we only trigger the JIT after a block hits a hotness threshold because it’s been executed enough times. This means that we will have forced all of the thunks on executed codepaths, unlike Higgs: Lunacy currently doesn’t invalidate or modify JIT code at all, which to me is much easier to reason about, because of this. Because the interpreter and JIT are both running the same residual operations for blocks, bailing out of the JIT back to the interpreter is very easy: the PC for the JIT bailout is the same PC that the interpreter should continue execution at. Thunks which weren’t yet forced when we trigger JIT compilation are handled as bailouts back to the interpreter, which will run the thunk as normal and rewrite it to a jump residual to a new block: if the new block is ran enough jumping to it may end up triggering JIT compilation again. In the future if the JIT-&gt;interpreter-&gt;JIT transition for thunks ends up being a bottleneck we could fixup the bailout to jump to the newly JIT’d block as well.</p>

<p><img src="/assets/images/example1-gdb.png" alt="Lunacy JIT code for sum" width="855" height="765" loading="lazy" /></p>
<blockquote>
  <p>JIT code for <code class="language-plaintext highlighter-rouge">sum</code>. Each residual exec operation turned into a native <code class="language-plaintext highlighter-rouge">CALL</code> to a static address, with a static closure object pointer. Despite this looking pretty bad for a JIT, it’s still several times faster than the interpreter!</p>
</blockquote>

<h2 id="more-context">More context</h2>

<p>Lunacy doesn’t only specialize the types of stack slots in the specialization context, but also will 1) track the concrete function value for function values 2) specialize table keys to static types and constant offsets.</p>

<p>The first one is fairly basic: just like we can suspend execution in order to discover the runtime type of a value, we can also suspend execution to discover the function pointer of things that we know are functions, again emitting another guard on the pointer value matching our expection. We can do this for both native functions, such as <code class="language-plaintext highlighter-rouge">print</code>, as well as Lua functions: this not only lets us in the JIT emit a native call to the C function directly, but also avoid needing to dynamically check the value and switch behavior depending on if its a native call or not, and lets us emit nested calls to more JIT code using the native processor stack instead of the interpreter call stack if the Lua call target is also already JIT’d. Because we can use all of the existing LBBV infrastructure in order to promote dynamic values to static context, this was surprisingly easy to implement.</p>

<p>For two, it was slightly more difficult. V8 implements table specialization in the form of hidden classes with shapes and transition maps: tables are assigned a pointer to a shape, which describes the layout and type of the table, and then at runtime you can emit a shape guard <code class="language-plaintext highlighter-rouge">if table.shape != expected: fail; success</code> in order to then emit loads from the table, which result in typed values, at the offset described by the shape in order to avoid hashmap lookups in the JIT. Tables are assigned shapes incrementally based on the order they are built. Code such as</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>local t = {}
t.a = 1
t.b = 2
</code></pre></div></div>

<p>would repeatedly transition the shape of the table according to a series of maps saying the next shape for each key that was added, such as</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{} -&gt; {a: int} -&gt; {a: int, b: int}
</code></pre></div></div>

<p>I didn’t want to implement this in Lunacy, however. Because shapes describe the entire layout of a table, it means that any inheritance-like behavior must be compiled as polymorphic blocks: <code class="language-plaintext highlighter-rouge">Dog</code> and <code class="language-plaintext highlighter-rouge">Cat</code> have different shape pointers, and you could only insert a guard that they are both <code class="language-plaintext highlighter-rouge">Animal</code>s by implementing more logic that finds the common ancestor and walks shape pointers at runtime, and figuring out when to do that as part of LBBV where all compilation has to progress incrementally (unlike a method or tracing JIT, which looks at multiple blocks at a time upfront) appeared hazardous. Shapes also requires following the transition maps at runtime if you have dynamic keys, and V8 also implements things like shape invalidation which requires being able to migrate JIT stack frames back to the interpreter (which itself necessitate emitting stack maps) to handle some cases.</p>

<p>Because Lua function environments, which contain non-local variables, are themselves tables I would also have the issue of shape pointers transitioning even from unrelated keys potentially invalidating the shape guards for every function just because a new global was added late, requiring a separate scheme to also be added to handle environments.</p>

<p>Instead, Lunacy implements something closer to LuaJIT’s <a href="http://lua-users.org/lists/lua-l/2009-11/msg00089.html">hash slot specialization</a> where the static context only contains the individual keys that are accessed in the block. A function which only accesses properties for an <code class="language-plaintext highlighter-rouge">Animal</code> would specialize on the hash slots for those properties being the first discovered type and offset, and for a <code class="language-plaintext highlighter-rouge">Dog</code> and <code class="language-plaintext highlighter-rouge">Cat</code> which were constructed in the same order for those shared prefix of keys be able to use the same specialized blocks. Likewise, adding a new variable to an environment wouldn’t cause existing guards to fail because the type and offset for all the previous keys stay intact.</p>

<p><img src="/assets/images/lunacy-example-2.jpg" alt="Lunacy IR showing gettable" width="3475" height="3259" loading="lazy" /></p>

<blockquote>
  <p>LBBV IR for <code class="language-plaintext highlighter-rouge">local t = {} t.a = 1 print(t.a)</code>. <code class="language-plaintext highlighter-rouge">gettable_href</code> does <code class="language-plaintext highlighter-rouge">O(1)</code> access with the hash witness index that was initialized by <code class="language-plaintext highlighter-rouge">href_init</code>, and the stack slot containing <code class="language-plaintext highlighter-rouge">print</code> was specialized to the concrete function pointer.</p>
</blockquote>

<p>I did slightly tweak the LuaJIT scheme, adding a runtime “hash witness” table that is populated with the dynamic index of the key instead of including a constant index based on the first observed key index; the idea was that <code class="language-plaintext highlighter-rouge">animal.age</code> might be at different indexes even for subclasses because the hashmap storage resized based on different number of keys, and so initializing the offset the first time you see the key in each function would maintain the desired behavior. The hash witness table also includes a “table epoch”: like the shape transitions, when Lunacy sets the key on a table and can’t prove via static information that the value stays the same type, it increments a monotonic epoch counter, and the initial value of that epoch counter is saved when we initialize the hash witness entry. The epoch is needed in order to catch invalidation of table keys, where <code class="language-plaintext highlighter-rouge">t.a = 1; t[dynamic] = "string"; t.a + 1</code> can’t assume that <code class="language-plaintext highlighter-rouge">t.a</code> stayed a string, and we must emit a guard that <code class="language-plaintext highlighter-rouge">if t.epoch != witness[0].epoch: bail; success</code> to verify the table stays the same. If the epoch increments, because the table had a new key added, we can do an “epoch repair” operation which do a full check that the value is still the expected type and either update the witness epoch value to the new table epoch now that we’re sure it’s still safe, or fallback to compiling a new block with the newly observed type.</p>

<p>But Lunacy now instead just uses <code class="language-plaintext highlighter-rouge">IndexMap</code> to implement the hash part of Lua tables, which have stable indexes based off insertion order, and removes the issue of indexes potentially being unstable based off resizing; I will probably remove the index from the witness and emit the constant index in the JIT directly, which will remove one data-dependent load from table property accesses while only introducing a few redundant blocks. The epoch scheme may also not be needed once I move to a better value representation (<a href="https://github.com/WebKit/WebKit/blob/4335716855bb893798267c14053068e6c8ad010e/Source/JavaScriptCore/runtime/JSCJSValue.h#L390">NuN boxing</a>) which would be able to check the types of values in a single instruction, and so be as simple as our epoch guard is.</p>

<p><img src="/assets/images/lunacy-example-3.png" alt="Lunacy IR for say" width="8844" height="7617" loading="lazy" /></p>

<blockquote>
  <p>JIT IR for: <code class="language-plaintext highlighter-rouge">local function say(animal) print(animal.name .. " is ", animal.age, "years old") if animal.barks ~= nil then print("bowwow") end end</code>. Despite calling it with <code class="language-plaintext highlighter-rouge">local dog = {name = "Fido", age = 5, barks = "a lot"}</code> and <code class="language-plaintext highlighter-rouge">local cat = {name = "Mittens", age = 3, meows = "sometimes"}</code>, the first <code class="language-plaintext highlighter-rouge">print</code> is monomorphic instead of needing to specialize per-shape.</p>
</blockquote>

<p>The other wrinkle with doing table shape optimization is around aliasing. If you have <code class="language-plaintext highlighter-rouge">x.a = 1; y.a = "string"; x.a + 1</code>, even though you never saw a store invalidate <code class="language-plaintext highlighter-rouge">x.a</code> it may now have the wrong type if <code class="language-plaintext highlighter-rouge">x == y</code>. The initial thing Lunacy was doing was just emit the epoch guard on every table access to catch these types of aliasing hazards; I eventually discovered the PyPy does a “type-based aliasing optimization”, where you can infer that <code class="language-plaintext highlighter-rouge">y.b = "string"</code> can’t invalidate <code class="language-plaintext highlighter-rouge">x.a</code>, because they’re different keys or different types - V8 is likewise able to do the same thing based on two variables having different know shapes I believe. With this we’re able to elide a lot of redundant epoch guards. Next up I want to try implementing caching of table property values in registers in the JIT, in order to remove redundant loads and perform store-to-load forwarding. Ideally this would allow code like <code class="language-plaintext highlighter-rouge">t.a = t.a + 1</code> to stay entirely in a register without needing to touch memory inside a hot loop. This likewise has aliasing hazards like we had above for type stability, where <code class="language-plaintext highlighter-rouge">print(other.a)</code> potentially may observe the delayed store to <code class="language-plaintext highlighter-rouge">t.a</code> if <code class="language-plaintext highlighter-rouge">other == t</code>: I need to mess around to see how actually feasible this is, and how often these kinds of aliasing hazards would negatively affect benchmarks.</p>

<h2 id="performance">Performance</h2>

<p>It’s not great?</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Summary
  ./target/unsafe/bench nbody.bin 10 ran
    1.01 ± 0.02 times faster than lua5.1 bench.lua -- lua_benchmarking/benchmarks/nbody/bench 10
    1.11 ± 0.02 times faster than ./target/release/bench nbody.bin 10
    2.77 ± 0.04 times faster than ./target/interpreter/release/bench nbody.bin 10
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Summary
  lua5.1 bench.lua -- lua_benchmarking/benchmarks/life/bench 1000 ran
    1.66 ± 0.07 times faster than ./target/unsafe/bench life.bin 1000
    2.03 ± 0.06 times faster than ./target/release/bench life.bin 1000
    2.62 ± 0.05 times faster than ./target/interpreter/release/bench life.bin 1000
</code></pre></div></div>

<p>Currently, Lunacy runs about the same speed as PUC Lua 5.1 on <code class="language-plaintext highlighter-rouge">nbody</code>. nbody is heavy on table property accesses, and so we sure would hope we do better than PUC Lua, which will do actually-for-real hashmap lookups each time. Other benchmarks are a bit slower. This is very modest performance - but it is in fact occasionally faster than vanilla Lua, which was my initial end goal and I consider an achievement.</p>

<p>More notably, Lunacy’s interpreter-only mode is about 2.75x slower than Lua, which means the JIT does actually work in being substantially faster than the interpreter, which was my second big goal!</p>

<p>Why is it slower? Profiling is difficult, but it appears to be a mix of:</p>

<ul>
  <li>
    <p>Our value representation is bad, and is literally just a Rust enum. Lunacy doesn’t do any pointer tagging, NaN boxing, or (the goal) NuN boxing currently - so our values are 2x more bytes than they ideally would be, which makes everything slower and precludes trying to keep them in registers as each value would consume two of them.</p>
  </li>
  <li>
    <p>The LBBV specialization is kinda slow (~20% of runtime), in particular because the hash slot specialization creates a lot of thunks despite many of them being immediately forced. It is probably possible to avoid repeatedly switching back and forth between running and compiling for some of those thunks.</p>
  </li>
  <li>
    <p>Likewise, the LBBV specialization clones a bunch of contexts and coroutines everywhere, and uses a lot of HashMaps. These can probably be optimized a lot as well to bring down the 20% overhead number.</p>
  </li>
  <li>
    <p>The table hash slot specialization does a full hashmap lookup to initialize the hash witness index, and needs to load the index from the hash witness for accesses.</p>
  </li>
  <li>
    <p>Lunacy doesn’t implement the function entrypoint specialization described in the sequel paper to LBBV, which means each function has no known types at its entrypoint again - and so has to re-initialize hash witnesses with the slow hashmap lookup. Oops! Performing entrypoint specialization with the continuation specialization for return values as well requires being able to invalidate continuations in the JIT, which is unfortunately kind of complicated.</p>
  </li>
  <li>
    <p>Some of the residual operations which aren’t easy to implement in assembly (because they e.g. call Rust methods) are implemented by emitting calls to <code class="language-plaintext highlighter-rouge">JitHelper</code> functions. These calls require shuffling values into ABI registers and can’t bake constants into the assembly, instead needing them to be passed as arguments. This isn’t actually a big percentage of wallclock time but it still feels bad.</p>
  </li>
</ul>

<p>And, of course, the big caveat of I’m mostly doing this as a fun side-project, and so haven’t been focusing on actual Lua feature compatibility in favor of doing neat JIT things. Notably, Lunacy doesn’t actually implement metatables yet, although I will need to implement them soon in order to run more benchmarks. Likewise it’s missing a couple bytecode operations, and there’s a decent amount of codepaths in existing bytecode operations that are <code class="language-plaintext highlighter-rouge">unimplemented!()</code>. I only recently bothered to even implement a basic mark-and-sweep garbage collector, and was relying on <code class="language-plaintext highlighter-rouge">Rc&lt;T&gt;</code> for garbage collection up until then.</p>

<p>Overall however, I’m very happy with the current progress on Lunacy. I’ve wanted to write a “real” JIT compiler for an interpreter for a while now, so it’s great to finally get around to it and reach the point I can get some ok-ish times on benchmarks.</p>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[A Lua 5.1 interpreter + JIT in Rust]]></summary></entry><entry><title type="html">The Social Costs of Dropping Out</title><link href="https://redvice.org/2025/college-socialization/" rel="alternate" type="text/html" title="The Social Costs of Dropping Out" /><published>2025-04-11T00:00:00+00:00</published><updated>2025-04-11T00:00:00+00:00</updated><id>https://redvice.org/2025/college-socialization</id><content type="html" xml:base="https://redvice.org/2025/college-socialization/"><![CDATA[<p>Dropping out was one of the best decisions I ever made. I’d mulled over doing so since high school, as I’d long been dissatisfied with the standard educational experience—a high school friend I caught up with years later remarked “I remember you talking about dropping out, but I can’t believe you actually did it”—but I didn’t pull the trigger until 2 years into college, 5-6 years after first considering it. I have generally poor experiential memory (probably as a consequence of my aphantasia), but the day I dropped out is one of my most vivid memories. After finally mustering up the resolve to commit to dropping out, I flopped on my bed and sobbed for an hour, not out of sadness but due to a feeling a sense of intense relief that I have not and probably never will experience again. I look back at that moment fondly; the instant I made the choice, I knew it was the right one. It has certainly worked out fine on every measure.</p>

<p>I share that story to make clear: this is a post about a cost of dropping out, but not regretful post, or a post discouraging the practice at all.</p>

<p>However, I believe it’s important to understand the tradeoffs you’re making with major life decisions. I certainly didn’t at the time, and from talking to other dropouts or people considering it, most of the tradeoff considerations center around professional life and their career progression. Those are not the only things college offers.</p>

<p>For most people, college is the foundational building block in their social circles for years to come. This seems to hold even for people who don’t really try at making friends, which is somewhat surprising to me, as is how enduring those social circles tend to be.</p>

<p>For most kids, college is their first opportunity for meaningful freedom from the yoke of their parents. I distinguish this from actually busy adults in the developmental sense of the word, as the modern college experience is akin to daycare and has few axes of success<sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup>. Famously, many Asian teens will briefly become party animals, then settle down again after getting that out of their system (or not), but the effect exists more broadly. This intense socialization and increased freedom happens among a peer group that is more similar to you, and with more common interests, than any you’ve had before. With that framing, it’s not so surprising that by default even relatively antisocial people will find a friend group. The rotating groups in classes each semester means a huge amount of forced comingling between people who are likely to get along.</p>

<p>For many, this is also when they can develop a more serious long-term relationship, and get physical with it. The meme of college students fucking like rabbits in the dorms freshman year is, as far as I can tell, basically true. The freedom combined with increased opportunity for a relationship, on top of continued teens/early 20s hormones, also helps force people to become better socially adjusted and more apt at interacting with the other sex. This effect is particularly pronounced for guys. Many people stop wearing ill-fitting clothes, kick a nervous tic or two, and learn to flirt<sup id="fnref:2"><a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref">2</a></sup>.</p>

<p>Even after graduation, people often end up in similar cities to their existing friend group. This becomes their initial, primary social circle, and they discover the horrible truth: that the college social experience is basically unique, and you will never again be constantly exposed to different people who share your age and interests by default. And the people you now spend the most time around, your coworkers, are discouraged as objects of romantic interest<sup id="fnref:3"><a href="#fn:3" class="footnote" rel="footnote" role="doc-noteref">3</a></sup>.</p>

<p>When you drop out, you give this all up. And often the process leading up to dropping out consists of making this tradeoff to a lesser extent. I spent much of my high school and limited college years programming, and while that focus was great for skill acquisition, it definitely precluded the standard high school/college social experience. I’m not convinced this tradeoff is inherent, but it seems to be incredibly common. I suspect I would have tried to navigate it differently if I’d understood the full implications, but it’s hard to say in hindsight.</p>

<p>None of this is to say you can’t be social, make new friends, and find fantastic partners after college! It just doesn’t happen by default, especially for introverts, and requires a level of agency to make happen that is rarer than you’d think. Many people coast off their college circles for years, and look back on those as the best experiences of their life.</p>

<p>When you drop out, you suddenly have no choice: you must take responsibility for this aspect of your life. This is tough. It takes time, energy, and learning from failure, and you may not be comfortable pursuing it until you’re settled career-wise; I certainly didn’t fix this for a while. It’s also particular tough immediately after dropping out, as people your age are mostly still in school and their leisure time is dominated by school-centric social events. Even after they graduate, you end up at pretty different levels of life experience and often pretty different values, which makes dating weird. This goes away after a few years, and I’d generally encourage people to push past it, but you will probably end up with an older peer group and a few years of awkward dates.</p>

<p>For most of my friends, this all more or less worked itself out, so if you’re considering dropping out it’s not all gloom and doom. And the benefits of dropping out can be massive - it’s a variance-increasing decision, for good or for ill. But this is an important aspect to be aware of, and if you do drop out, to try and address as soon as you have some breathing room to do so.</p>

<p>If you’re thinking of dropping out, or recently pulled the plug and you want to chat, shoot me an email. I have limited generic advice to offer, but I’m usually happy to make time to sit down and talk things over.</p>

<hr />

<p><em>Thanks to Ryan Hill for reading a draft of this post.</em></p>

<hr />

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p><a href="https://kipp.ly/no-not-good-enough/">Relevant post</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2">
      <p>I am told, amusingly, that most of them do not bother getting good at sex. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:3">
      <p>Albeit unfairly; if you’re a white-collar worker in the US the downside is not that bad, especially if you work in tech, and the upside potentially huge. For your employer, it’s probably mostly downside, but you shouldn’t conflate their interests with yours. <a href="#fnref:3" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Ryan</name></author><summary type="html"><![CDATA[Observations on an underconsidered aspect of the tradeoffs around dropping out: college socialization]]></summary></entry><entry><title type="html">Hacking My Coworker (In Minecraft)</title><link href="https://redvice.org/2025/in-minecraft/" rel="alternate" type="text/html" title="Hacking My Coworker (In Minecraft)" /><published>2025-04-01T00:00:00+00:00</published><updated>2025-04-01T00:00:00+00:00</updated><id>https://redvice.org/2025/in-minecraft</id><content type="html" xml:base="https://redvice.org/2025/in-minecraft/"><![CDATA[<p><a href="/assets/pdfs/minecraft2025.pdf">Read the paper (PDF)</a>.</p>

<object data="/assets/pdfs/minecraft2025.pdf" width="1000" height="1000" type="application/pdf" aria-label="Hacking My Coworker (In Minecraft)">
  <p>The paper is available using the PDF link above.</p>
</object>

<p>This paper was submitted to <a href="https://sigbovik.org/2025/">SIGBOVIK 2025</a>.</p>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[Finding a zero-day RCE vulnerability (in Minecraft)]]></summary></entry><entry><title type="html">RCE in Minecraft mod Integrated Scripting</title><link href="https://redvice.org/2025/integrated-scripting-rce/" rel="alternate" type="text/html" title="RCE in Minecraft mod Integrated Scripting" /><published>2025-03-10T00:00:00+00:00</published><updated>2025-03-10T00:00:00+00:00</updated><id>https://redvice.org/2025/integrated-scripting-rce</id><content type="html" xml:base="https://redvice.org/2025/integrated-scripting-rce/"><![CDATA[<h2 id="tldr-update-your-server-if-you-have-integrated-scripting-installed">TL;DR: UPDATE YOUR SERVER IF YOU HAVE INTEGRATED SCRIPTING INSTALLED</h2>

<p>I found a remote code execution vulnerability in the Minecraft mod <em>Integrated Scripting</em>. If you are running Integrated Scripting, and the version is:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;=1.21.1-1.0.16
&lt;=1.21.4-1.0.9-224
&lt;=1.20.1-1.0.11
&lt;=1.19.2.-1.0.9
</code></pre></div></div>

<p>your server is vulnerable to being hacked by any player who is able to craft some items from Integrated Scripting. If you have a public or semi-public server, you should update the mod to a newer version.</p>

<p>Several popular modpacks contain Integrated Scripting. If you are running:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>AllTheMods10 &lt;=2.36
Craftoria &lt;=1.14.0
FTB Presents Direwolf20 1.21 &lt;=1.9.0
(and many more)
</code></pre></div></div>

<p>your server is also vulnerable, and you should update.</p>

<h2 id="technical-details">Technical details</h2>
<p>Versions of Integrated Scripting released before February 24th, 2025 are vulnerable to a critical remote code execution vulnerability. Leveraging Java reflection it’s possible to escape the GraalJS sandbox and call arbitrary methods on arbitrary Java objects. The initial vulnerability disclosure, with more details, is available as <a href="https://github.com/CyclopsMC/IntegratedScripting/security/advisories/GHSA-2v5x-4823-hq77">GHSA-2v5x-4823-hq77</a>. The vulnerability has also been assigned <a href="https://nvd.nist.gov/vuln/detail/CVE-2025-27107">CVE-2025-27107</a>.</p>]]></content><author><name>Charlie</name></author><summary type="html"><![CDATA[Remote code execution on modded Minecraft servers]]></summary></entry></feed>