[syndicated profile] wingolog_feed

Posted by Andy Wingo

Let’s talk about memory management! Following up on my article about 5 years of developments in V8’s garbage collector, today I’d like to bring that up to date with what went down in V8’s GC over the last couple years.

methodololology

I selected all of the commits to src/heap since my previous roundup. There were 1600 of them, including reverts and relands. I read all of the commit logs, some of the changes, some of the linked bugs, and any design document I could get my hands on. From what I can tell, there have been about 4 FTE from Google over this period, and the commit rate is fairly constant. There are very occasional patches from Igalia, Cloudflare, Intel, and Red Hat, but it’s mostly a Google affair.

Then, by the very rigorous process of, um, just writing things down and thinking about it, I see three big stories for V8’s GC over this time, and I’m going to give them to you with some made-up numbers for how much of the effort was spent on them. Firstly, the effort to improve memory safety via the sandbox: this is around 20% of the time. Secondly, the Oilpan odyssey: maybe 40%. Third, preparation for multiple JavaScript and WebAssembly mutator threads: 20%. Then there are a number of lesser side quests: heuristics wrangling (10%!!!!), and a long list of miscellanea. Let’s take a deeper look at each of these in turn.

the sandbox

There was a nice blog post in June last year summarizing the sandbox effort: basically, the goal is to prevent user-controlled writes from corrupting memory outside the JavaScript heap. We start from the assumption that the user is somehow able to obtain a write-anywhere primitive, and we work to mitigate the effect of such writes. The most fundamental way is to reduce the range of addressable memory, notably by encoding pointers as 32-bit offsets and then ensuring that no host memory is within the addressable virtual memory that an attacker can write. The sandbox also uses some 40-bit offsets for references to larger objects, with similar guarantees. (Yes, a sandbox really does reserve a terabyte of virtual memory).

But there are many, many details. Access to external objects is intermediated via type-checked external pointer tables. Some objects that should never be directly referenced by user code go in a separate “trusted space”, which is outside the sandbox. Then you have read-only spaces, used to allocate data that might be shared between different isolates, you might want multiple cages, there are “shared” variants of the other spaces, for use in shared-memory multi-threading, executable code spaces with embedded object references, and so on and so on. Tweaking, elaborating, and maintaining all of these details has taken a lot of V8 GC developer time.

I think it has paid off, though, because the new development is that V8 has managed to turn on hardware memory protection for the sandbox: sandboxed code is prevented by the hardware from writing memory outside the sandbox.

Leaning into the “attacker can write anything in their address space” threat model has led to some funny patches. For example, sometimes code needs to check flags about the page that an object is on, as part of a write barrier. So some GC-managed metadata needs to be in the sandbox. However, the garbage collector itself, which is outside the sandbox, can’t trust that the metadata is valid. We end up having two copies of state in some cases: in the sandbox, for use by sandboxed code, and outside, for use by the collector.

The best and most amusing instance of this phenomenon is related to integers. Google’s style guide recommends signed integers by default, so you end up with on-heap data structures with int32_t len and such. But if an attacker overwrites a length with a negative number, there are a couple funny things that can happen. The first is a sign-extending conversion to size_t by run-time code, which can lead to sandbox escapes. The other is mistakenly concluding that an object is small, because its length is less than a limit, because it is unexpectedly negative. Good times!

oilpan

It took 10 years for Odysseus to get back from Troy, which is about as long as it has taken for conservative stack scanning to make it from Oilpan into V8 proper. Basically, Oilpan is garbage collection for C++ as used in Blink and Chromium. Sometimes it runs when the stack is empty; then it can be precise. But sometimes it runs when there might be references to GC-managed objects on the stack; in that case it runs conservatively.

Last time I described how V8 would like to add support for generational garbage collection to Oilpan, but that for that, you’d need a way to promote objects to the old generation that is compatible with the ambiguous references visited by conservative stack scanning. I thought V8 had a chance at success with their new mark-sweep nursery, but that seems to have turned out to be a lose relative to the copying nursery. They even tried sticky mark-bit generational collection, but it didn’t work out. Oh well; one good thing about Google is that they seem willing to try projects that have uncertain payoff, though I hope that the hackers involved came through their OKR reviews with their mental health intact.

Instead, V8 added support for pinning to the Scavenger copying nursery implementation. If a page has incoming ambiguous edges, it will be placed in a kind of quarantine area for a while. I am not sure what the difference is between a quarantined page, which logically belongs to the nursery, and a pinned page from the mark-compact old-space; they seem to require similar treatment. In any case, we seem to have settled into a design that was mostly the same as before, but in which any given page can opt out of evacuation-based collection.

What do we get out of all of this? Well, not only can we get generational collection for Oilpan, but also we unlock cheaper, less bug-prone “direct handles” in V8 itself.

The funny thing is that I don’t think any of this is shipping yet; or, if it is, it’s only in a Finch trial to a minority of users or something. I am looking forward in interest to seeing a post from upstream V8 folks; whole doctoral theses have been written on this topic, and it would be a delight to see some actual numbers.

shared-memory multi-threading

JavaScript implementations have had the luxury of a single-threadedness: with just one mutator, garbage collection is a lot simpler. But this is ending. I don’t know what the state of shared-memory multi-threading is in JS, but in WebAssembly it seems to be moving apace, and Wasm uses the JS GC. Maybe I am overstating the effort here—probably it doesn’t come to 20%—but wiring this up has been a whole thing.

I will mention just one patch here that I found to be funny. So with pointer compression, an object’s fields are mostly 32-bit words, with the exception of 64-bit doubles, so we can reduce the alignment on most objects to 4 bytes. V8 has had a bug open forever about alignment of double-holding objects that it mostly ignores via unaligned loads.

Thing is, if you have an object visible to multiple threads, and that object might have a 64-bit field, then the field should be 64-bit aligned to prevent tearing during atomic access, which usually means the object should be 64-bit aligned. That is now the case for Wasm structs and arrays in the shared space.

side quests

Right, we’ve covered what to me are the main stories of V8’s GC over the past couple years. But let me mention a few funny side quests that I saw.

the heuristics two-step

This one I find to be hilariousad. Tragicomical. Anyway I am amused. So any real GC has a bunch of heuristics: when to promote an object or a page, when to kick off incremental marking, how to use background threads, when to grow the heap, how to choose whether to make a minor or major collection, when to aggressively reduce memory, how much virtual address space can you reasonably reserve, what to do on hard out-of-memory situations, how to account for off-heap mallocated memory, how to compute whether concurrent marking is going to finish in time or if you need to pause... and V8 needs to do this all in all its many configurations, with pointer compression off or on, on desktop, high-end Android, low-end Android, iOS where everything is weird, something called Starboard which is apparently part of Cobalt which is apparently a whole new platform that Youtube uses to show videos on set-top boxes, on machines with different memory models and operating systems with different interfaces, and on and on and on. Simply tuning the system appears to involve a dose of science, a dose of flailing around and trying things, and a whole cauldron of witchcraft. There appears to be one person whose full-time job it is to implement and monitor metrics on V8 memory performance and implement appropriate tweaks. Good grief!

mutex mayhem

Toon Verwaest noticed that V8 was exhibiting many more context switches on MacOS than Safari, and identified V8’s use of platform mutexes as the problem. So he rewrote them to use os_unfair_lock on MacOS. Then implemented adaptive locking on all platforms. Then... removed it all and switched to abseil.

Personally, I am delighted to see this patch series, I wouldn’t have thought that there was juice to squeeze in V8’s use of locking. It gives me hope that I will find a place to do the same in one of my projects :)

ta-ta, third-party heap

It used to be that MMTk was trying to get a number of production language virtual machines to support abstract APIs so that MMTk could slot in a garbage collector implementation. Though this seems to work with OpenJDK, with V8 I think the churn rate and laser-like focus on the browser use-case makes an interstitial API abstraction a lose. V8 removed it a little more than a year ago.

fin

So what’s next? I don’t know; it’s been a while since I have been to Munich to drink from the source. That said, shared-memory multithreading and wasm effect handlers will extend the memory management hacker’s full employment act indefinitely, not to mention actually landing and shipping conservative stack scanning. There is a lot to be done in non-browser V8 environments, whether in Node or on the edge, but it is admittedly harder to read the future than the past.

In any case, it was fun taking this look back, and perhaps I will have the opportunity to do this again in a few years. Until then, happy hacking!

james_davis_nicoll: (Default)
[personal profile] james_davis_nicoll


Experience the trip of a lifetime — without having to deal with planes, passports, or other tourists...

RPG Tourism: Five Games To Help You Travel Vicariously

Classic Donnie

Nov. 13th, 2025 03:37 pm
luzribeiro: (Rabbit!)
[personal profile] luzribeiro posting in [community profile] talkpolitics
So, it turns out some freshly released emails from Epstein claim that Trump spent hours with one of the victims at Epstein's home, and that Trump "of course... knew about the girls", according to the financier:

https://www.aljazeera.com/news/2025/11/12/trump-spent-hours-with-victim-at-epsteins-house-email-alleges

Meanwhile, the White House's response? Well, the Press Secretary insisted the emails "prove absolutely nothing other than the fact that President Trump did nothing wrong".

What really takes the comedic cake: there's the unspoken claim (not exactly phrased this way, but implied) that the Trump who was allegedly involved is somehow "a different Donald Trump" than the one we know. Maybe one who accidentally walked into Epstein's house unawares? The actual statement was that the leaks are cherry-picked, part of a hoax, etc you know the drill - but the tone amounts to "not the Trump you know, folks!"

Of course, I'm not saying guilt or innocence here - the facts are still being debated, investigations are ongoing, lots of redactions and blacked-out names. For what it's worth, one of the victims named in other sources is Virginia Giuffre, though whether she's the one referenced in these specific emails is unverified.

And yes - the irony is thick: a man who once said "I've known Jeff [Epstein] for 15 years; terrific guy... it is even said that he likes beautiful women as much as I do, and many of them are on the younger side", is now being defended by his own administration with the "nothing to see here / different guy" approach. Classic Donnie, eh?

State of the Hobbies, Mark 2

Nov. 13th, 2025 08:07 am
osprey_archer: (art)
[personal profile] osprey_archer
It has been some time since I’ve given a hobby update! In the months since my previous post, you will be glad to know that I’ve kept cross-stitching.

In fact, I’ve been enjoying cross-stitching so much that I’ve finally managed to set up a morning tea routine: get up around 6:30, make tea, put one (1) chocolate-covered hobnob on my favorite little plate, and then cross-stitch till 7:15 when it’s time to get ready for work. Life is so much better when I get up in time for a gentle on-ramp to the morning, and yet until now I haven’t been able to convince myself to actually get out of bed in time.

I finished my Halloween cross-stitch in time for Halloween (want to find a better frame for it though), stitched a tremendously round little red Christmas bird as a break (amazing how fast you can cross stitch when the whole thing is just one color!), and am now working on a little Victorian Christmas tree which is for my ornament exchange with my friend Caitlin.

This little Christmas tree is WAY more involved than I expected, so I probably won’t finish my little cornucopia in time for Thanksgiving. But I have acquired the cornucopia pattern and will at any rate have it ready for NEXT year.

Other patterns on deck:

The absolutely adorable Puss in Boots from Veronique Enginger’s book of fairy tale cross stitch.

A Tiffany window inspired pattern of birds and bamboo and flowers from a book of Art Nouveau cross stitch. (I have the floss for this one but have been momentarily stymied in finding the right color fabric.)

And I’ve promised [personal profile] troisoiseaux a Nevermore, garnished with ravens…

I’m also taking a two-part embroidery class. On Monday I started my jellyfish, and next Monday I will hopefully finish the jellyfish. The backing fabric is a dark navy blue so the tentacles are pink floss, and the top is going to be gold and turquoise and dark royal blue beads.

Book projects: since the previous post, I finished the Newbery project, and then just this weekend finished the Postcard Book project! (Jules Verne was the last Famous Author postcard from the set.) Which means that I COULD start the E. M. Forster readthrough...

But I’ve decided to hold off until after Christmas, because I just had a brilliant idea for a Christmas project: a picture book Advent calendar! I have MANY Christmas picture books on my list this year, so I’ll get them from the library, wrap them up in brown paper (or newspaper or whatever paper I have available), and then select a surprise book each night to read.

I probably won’t end up posting about most of them because I often don’t have a lot to say about picture books. Although maybe a weekly round-up with a line or two about each book?

At the moment I’m actually a bit short of books (I thought the list was AMPLY long, but some of the books are only available in the archives etc.), so I may have to poke around to find a few more. We shall see!

And of course I AM planning some December archive visits to enjoy those Christmas books! In fact, I believe I can schedule an archive visit next week (not for Christmas books of course; a firm believer in saving Christmas season till after Thanksgiving), as registration is at long last winding up. Perhaps it’s time to begin A. A. Milne’s The Princess and the Apple Tree.

Fandom Trees 2025

Nov. 13th, 2025 08:05 am
spikedluv: (summer: sunflowers by candi)
[personal profile] spikedluv
[community profile] fandomtrees is open for sign-ups!!

Sign-Up Post | Sticky Post (includes Schedule, FAQ and Rules)

Book Review: The Business of Secrets

Nov. 13th, 2025 12:09 pm
[syndicated profile] bruce_schneier_feed

Posted by Bruce Schneier

The Business of Secrets: Adventures in Selling Encryption Around the World by Fred Kinch (May 24, 2004)

From the vantage point of today, it’s surreal reading about the commercial cryptography business in the 1970s. Nobody knew anything. The manufacturers didn’t know whether the cryptography they sold was any good. The customers didn’t know whether the crypto they bought was any good. Everyone pretended to know, thought they knew, or knew better than to even try to know.

The Business of Secrets is the self-published memoirs of Fred Kinch. He was founder and vice president of—mostly sales—at a US cryptographic hardware company called Datotek, from company’s founding in 1969 until 1982. It’s mostly a disjointed collection of stories about the difficulties of selling to governments worldwide, along with descriptions of the highs and (mostly) lows of foreign airlines, foreign hotels, and foreign travel in general. But it’s also about encryption.

Datotek sold cryptographic equipment in the era after rotor machines and before modern academic cryptography. The company initially marketed computer-file encryption, but pivoted o link encryption – low-speed data, voice, fax – because that’s what the market wanted.

These were the years where the NSA hired anyone promising in the field, and routinely classified – and thereby blocked – publication of academic mathematics papers of those they didn’t hire. They controlled the fielding of strong cryptography by aggressively using the International Traffic in Arms regulation. Kinch talks about the difficulties in getting an expert license for Datotek’s products; he didn’t know that the only reason he ever got that license was because the NSA was able to break his company’s stuff. He had no idea that his largest competitor, the Swiss company Crypto AG, was owned and controlled by the CIA and its West German equivalent. “Wouldn’t that have made our life easier if we had known that back in the 1970s?” Yes, it would. But no one knew.

Glimmers of the clandestine world peek out of the book. Countries like France ask detailed tech questions, borrow or buy a couple of units for “evaluation,” and then disappear again. Did they break the encryption? Did they just want to see what their adversaries were using? No one at Datotek knew.

Kinch “carried the key generator logic diagrams and schematics” with him – even today it’s good practice not to rely on their secrecy for security—but the details seem laughably insecure: four linear shift registers of 29, 23, 13, and 7 bits, variable stepping, and a small nonlinear final transformation. The NSA probably used this as a challenge to its new hires. But Datotek didn’t know that, at the time.

Kinch writes: “The strength of the cryptography had to be accepted on trust and only on trust.” Yes, but it’s so, so weird to read about it in practice. Kinch demonstrated the security of his telephone encryptors by hooking a pair of them up and having people listen to the encrypted voice. It’s rather like demonstrating the safety of a food additive by showing that someone doesn’t immediately fall over dead after eating it. (In one absolutely bizarre anecdote, an Argentine sergeant with a “hearing defect” could understand the scrambled analog voice. Datotek fixed its security, but only offered the upgrade to the Argentines, because no one else complained. As I said, no one knew anything.)

In his postscript, he writes that even if the NSA could break Datotek’s products, they were “vastly superior to what [his customers] had used previously.” Given that the previous devices were electromechanical rotor machines, and that his primary competition was a CIA-run operation, he’s probably right. But even today, we know nothing about any other country’s cryptanalytic capabilities during those decades.

A lot of this book has a “you had to be there” vibe. And it’s mostly tone-deaf. There is no real acknowledgment of the human-rights-abusing countries on Datotek’s customer list, and how their products might have assisted those governments. But it’s a fascinating artifact of an era before commercial cryptography went mainstream, before academic cryptography became approved for US classified data, before those of us outside the triple fences of the NSA understood the mathematics of cryptography.

This book review originally appeared in AFIO.

Book Review: The Business of Secrets

Nov. 13th, 2025 12:09 pm
[syndicated profile] schneier_no_tracking_feed

Posted by Bruce Schneier

The Business of Secrets: Adventures in Selling Encryption Around the World by Fred Kinch (May 24, 2004)

From the vantage point of today, it’s surreal reading about the commercial cryptography business in the 1970s. Nobody knew anything. The manufacturers didn’t know whether the cryptography they sold was any good. The customers didn’t know whether the crypto they bought was any good. Everyone pretended to know, thought they knew, or knew better than to even try to know.

The Business of Secrets is the self-published memoirs of Fred Kinch. He was founder and vice president of—mostly sales—at a US cryptographic hardware company called Datotek, from company’s founding in 1969 until 1982. It’s mostly a disjointed collection of stories about the difficulties of selling to governments worldwide, along with descriptions of the highs and (mostly) lows of foreign airlines, foreign hotels, and foreign travel in general. But it’s also about encryption.

Datotek sold cryptographic equipment in the era after rotor machines and before modern academic cryptography. The company initially marketed computer-file encryption, but pivoted o link encryption – low-speed data, voice, fax – because that’s what the market wanted.

These were the years where the NSA hired anyone promising in the field, and routinely classified – and thereby blocked – publication of academic mathematics papers of those they didn’t hire. They controlled the fielding of strong cryptography by aggressively using the International Traffic in Arms regulation. Kinch talks about the difficulties in getting an expert license for Datotek’s products; he didn’t know that the only reason he ever got that license was because the NSA was able to break his company’s stuff. He had no idea that his largest competitor, the Swiss company Crypto AG, was owned and controlled by the CIA and its West German equivalent. “Wouldn’t that have made our life easier if we had known that back in the 1970s?” Yes, it would. But no one knew.

Glimmers of the clandestine world peek out of the book. Countries like France ask detailed tech questions, borrow or buy a couple of units for “evaluation,” and then disappear again. Did they break the encryption? Did they just want to see what their adversaries were using? No one at Datotek knew.

Kinch “carried the key generator logic diagrams and schematics” with him – even today it’s good practice not to rely on their secrecy for security—but the details seem laughably insecure: four linear shift registers of 29, 23, 13, and 7 bits, variable stepping, and a small nonlinear final transformation. The NSA probably used this as a challenge to its new hires. But Datotek didn’t know that, at the time.

Kinch writes: “The strength of the cryptography had to be accepted on trust and only on trust.” Yes, but it’s so, so weird to read about it in practice. Kinch demonstrated the security of his telephone encryptors by hooking a pair of them up and having people listen to the encrypted voice. It’s rather like demonstrating the safety of a food additive by showing that someone doesn’t immediately fall over dead after eating it. (In one absolutely bizarre anecdote, an Argentine sergeant with a “hearing defect” could understand the scrambled analog voice. Datotek fixed its security, but only offered the upgrade to the Argentines, because no one else complained. As I said, no one knew anything.)

In his postscript, he writes that even if the NSA could break Datotek’s products, they were “vastly superior to what [his customers] had used previously.” Given that the previous devices were electromechanical rotor machines, and that his primary competition was a CIA-run operation, he’s probably right. But even today, we know nothing about any other country’s cryptanalytic capabilities during those decades.

A lot of this book has a “you had to be there” vibe. And it’s mostly tone-deaf. There is no real acknowledgment of the human-rights-abusing countries on Datotek’s customer list, and how their products might have assisted those governments. But it’s a fascinating artifact of an era before commercial cryptography went mainstream, before academic cryptography became approved for US classified data, before those of us outside the triple fences of the NSA understood the mathematics of cryptography.

This book review originally appeared in AFIO.

spikedluv: (summer: sunflowers by candi)
[personal profile] spikedluv
This was another off-duty day for me, as sister S was once again taking mom to her appointment. I hit the Pharmacy while I was downtown and dropped off a car insurance payment to State Farm. (Convenient, as they’re located in the same ‘mall’.) I stopped at the bank drive-thru on the way home and Stewart’s (for gas and milk) on the way to pick up the dogs. At home I did a load of laundry, hand-washed dishes, went for several walks with Pip and the dogs, cut up chicken for the dogs' meals, and scooped kitty litter. We had hot dogs for supper. I have a feeling there won't be very much grilling going on from here on out (although the temps are supposed to hit the 40s next week, so maybe . . .)

I had breakfast at Burger King this morning. I was talking to myself as if explaining the process as I was opening the ketchup packets because I often get ketchup on my fingers. So I’m on the last one and I’m like, push the ketchup away from the arrow thingy so when you rip it open you don’t get ketchup all over your fingers. Yes, success! And then I immediately dropped the ketchup packet into the pile of ketchup already on the tray. I clean up the mess that results from me having to pick up the ketchup-covered packet and then shake my OJ, only to get it all over because I hadn’t put the cap back on tightly. I was like, what even is this morning?!!

I typed in all of the transcript notes I’d taken for Top Gun: Maverick, and watched a Hallmark Christmas movie and some HGTV programs.

Temps started out at 32.4(F) and reached 41.2. Both temps again higher than forecasted by a few degrees; it’s not much, but I’ll take it. At one point we even had a little sun.


Mom Update:

Mom sounded good when I talked to her. more )

More evidence of causation

Nov. 13th, 2025 07:20 pm
fred_mouse: bright red 'love' heart with stethoscope (health)
[personal profile] fred_mouse

a follow up to my october 14th post, where I reported having forgotten all my morning meds. I have, in the interim, been prescribed a new medication that has to be taken half an hour before breakfast, and also worked out that if I put all but one medication on the bedside table, I can take them when I first wake. Which has the added advantage of meaning that the paracetamol has kicked in by the time I try and get out of bed, and lo! but it is easier to get out of bed.

Sadly, the one that can't be taken at that point -- because it has to be taken after eating -- is the anti-inflammatory. And today, I gave up and came home after lunch, because making it to 2pm when the next paracetamol was due was too much (I actually took said paracetamol at 1pm, which is the absolute earliest it was allowed, on the 6 hour interval, which meant it kicked in enough for the drive home to be possible). And found the anti-inflammatory still in its little bowl, waiting to be taken. Which might mean I also forgot my asthma preventer, which might also be associated with my chest being a little unhappy (also, I have some kind of reaction to being in a specific room in the library -- the last two times I've developed one of those biting coughs)

Which says that the anti-inflammatory is doing amazing things, and I'm going to keep taking it. Sadly, the new med is because it is possible that some of the other symptoms are a side effect of taking it daily, rather than the 'max 5 days in 7' I was allowed with the stronger dose (that was once daily, the lower dose is twice daily).

tamaranth: me, in the sun (Default)
[personal profile] tamaranth
2025/181: Murder Most Foul — Guy Jenkin
Even in Deptford, you can’t carry bodies far in daylight... [loc. 1402]

In which William Shakespeare is suspected of the murder of Christopher Marlowe, and makes common cause with Marlowe's sister Ann (formerly Will's lover) to find out who really killed Marlowe, and why. Well-researched, witty historical whodunnit with a credible denouement and some excellent dialogue (Jenkin is an award-winning scriptwriter) and lots of period detail. Also, set in my neck of the woods...

The premise sounded excellent, but didn't quite ring true for me.Read more... )