Better HN
topnewbestaskshowjobs
Log inSign up

pron

25,686 karma · joined Dec 23, 2011 (14y ago) · 8,555 submissions

https://pron.github.io/

Working on OpenJDK at Oracle

Submissions

comment 1d ago · link · parent

I won't comment on the rest of what you said here because it doesn't seem like you're a compiler engineer (JITs are vastly different from one another; e.g. HotSpot's C2 is more similar to LLVM than to V8's JIT), but I will just say that AOT compilers and C2 need to rely on intrinsics in exactly the same way, and it matters not a jot for security whether these intrinsics are emitted at runtime or build time (BTW, LLVM can be, and is, used as a JIT, and C2 can be, and is, used AOT).

comment 1d ago · link · parent

> The massively most popular implementations rely massively on JIT, even if they have varying levels of AOT support.

What does this have to do with what I said? A JIT compiler is a compiler.

> That's an empirical claim. You can go ahead and support it.

I don't need to convince you; I'm already convinced. If you don't think it's true, find out for yourself.

> No one uses Netty, right????? They had such an easy job ditching Unsafe, right??????

Pretty much they did, yes, once the right safe APIs were added.

> And I recognize your name well enough that you don't know much of anything.

Okay, but since I do work on the HotSpot JVM, and much of the world's most business-critical and performance-critical software relies on the code my colleagues and I write, the people who do need to trust that I know something about compilers and runtimes seem to already do, so it's okay if I lose a few commenters on HN.

comment 1d ago · link · parent

Not quite. Vec in Rust is more similar to ArrayList in Java, which is written in pure safe Java. Mutex is more similar to j.u.c.Lock in Java, which is also written in safe Java (actually, there is some use of Unsafe there, but it's purely because of initialisation considerations, as some j.u.c classes are used internally before the safe constructs are initialised; you can implement this in a 3rd-party library outside the JDK without Unsafe and with the same performance). Strings are also written in Java (although some of their operations have intrinsics).

As for arrays in Java, they're implemented in machine code emitted by the compiler, just as in Rust. It's true that allocation depends on a GC written in C++, but Rust similarly depends on malloc/free runtimes written in C.

That Rust relies on unsafe more than Java, both in the standard library and in applications, is too obvious to argue against.

comment 2d ago · link · parent

> But, still, I know that "crash" is enough reason for emergency release, even, I think, it is pretty default behavior in open software world. And in this case fixing crash would be one 0 day less.

It really isn't. An emergency release places a burden on your users, and unless they know there's a significant risk, they just won't upgrade. On the fix side, this took some investigation, and while a crash is very serious, there was no reason to drop everything else and focus on this (there are other serious things to work on).

> But if security problems was known or probable 3 months erlier

It was neither known nor even suspected three months earlier. It was only one month earlier, when the cause of the crash was discovered, that things seemed like this could be a serious vulnerability.

comment 2d ago · link · parent

> Because your industrial and official protocol is deeply flawed, change it.

No, it isn't. This is how security is (and has to be) done in critical products.

If something isn't a vulnerability then 1. we might not need to backport at all or not to many versions (although crashes usually are backported), and 2. we definitely not issue an emergency update. The fix goes into either the next major release (twice a year) or the next regular update (every quarter).

So there may be a few months between the time something is merged and the time it reaches users. But if it's a vulnerability you may want to do an emergency release, depending on the severity. If you don't know it's a vulnerability (let alone its severity) you really don't want the code sitting out there until you figure out.

> Let's repeat: procedure that extends critical bug from 2 months into half a year should be changed.

What happened on 16 June was a report of a crash in the GC. There was no reproducer, the cause wasn't known, and there wasn't a special reason to believe it had anything to do with a compiler intrinsic, let alone a serious vulnerability (a potential attacker also couldn't do something with that report, as the crash happened nowhere near the cause).

From the time the cause was discovered in September (which started the investigation into a vulnerability) to the time an emergency patch was released, it was a little over two months, and less than one month from the time Calif shared an exploit (which may have helped the decision to make an emergency release; don't know, I'm not on the security team).

comment 3d ago · link · parent

You're talking about arenas that you implement manually in ordinary objects. I'm talking about arenas managed by the language/runtime.

comment 3d ago · link · parent

> Arenas avoid most of the performance problems of malloc/free.

Sure, but they're not fully general, which is why you also need malloc/free for things that don't work well in arenas (or write the equivalent of malloc/free on top of arenas, which is what you need to do in Goose: https://github.com/aardappel/goose/blob/master/bench/kostya/...).

Also, arenas can be an even better fit for languages with good GCs than languages without a GC.

comment 3d ago · link · parent

I'm not sure what you mean exactly because there can be pointers in the heap (although work on compile-time GC based on arena-like "regions" has been around for decades), but there are plenty more optimisations that generational moving collectors can do, and we're working on them. But no matter what you do, once you can move objects you need an FFI layer between the "movable stack" and the hardware/OS, which is not something you want in a low-level language (because once you need an FFI layer, you might as well use a more high level language for the parts above it).

comment 3d ago · link · parent

Generational moving GCs work much like arenas, and they work without the limitations of arenas and without the performance hit of malloc/free. That's not to say arenas aren't very efficient and useful, but few languages make them convenient and composable enough (Zig), and even then they need to be used with care.

comment 3d ago · link · parent

First, you need to know that the original reporter is a former Oracle employee who is a committer on the project and has direct, non-public access to Oracle.

> No idea why anyone need to wait for anyone and especially on any corporation to apply the available patch !

Because as soon as it was suspected to be a security risk we could not apply it. This is how security is done in critical products.

When you say "accept the PR", understand that we're not talking about applying it to mainline, but backporting it to all affected and supported versions. That is something that immediately draws attention. Then, a vulnerability is closed not when it reaches the codebase, but when it's deployed by the users to production, and users have the means to apply the regular quarterly updates, but not necessarily emergency ones (because there can always be other emergencies that occupy them). So what you need to do is investigate the risk and then decide whether to issue an emergency update or wait for the regular quarterly release.

The JDK is critical infrastructure, we simply cannot take cavalier, irresponsible actions of the kind you suggest; I would say insane, but I realise you're just unfamiliar with critical software security (I know you have good intentions and think it's fast, but we've been doing this for thirty years and know it's anything but). Think what would happen if every critical product would issue an emergency release with the maximal urgency advisory whenever any bug is thought to might be a vulnerability of an unknown severity.

Sorry, but we must take security matters extremely seriously, and handle them the right way (which is also the fastest way).

comment 3d ago · link · parent

It is true that if the size of your RAM is close to the size of your live set, a moving GC isn't the best choice, but this doesn't happen for most software on machines that we would call computers these days.

As for performance differences in practice, it is easy to encounter Java programs, typically either large ones or very concurrent ones, that easily outperform C++ programs by a factor of two or more, just as it's easy to see examples of the opposite, typically in smaller or less concurrent programs. This is what we would expect.

As experienced low-level programmers know, it is quite easy to avoid the operations that are slow in C++ or other low-level languages - heap allocations and dynamic dispatch - when programs are relatively small and/or young. As programs grow larger, it gets more and more expensive to do this because these operations offer high abstraction, the ability to keep changes local. And it is these two operations that the HotSpot JVM was built to optimise.

I gave a talk about exactly that at the last Devoxx: https://youtu.be/vhDwy1eCXbs

comment 3d ago · link · parent

Yes, I'm aware that the title of that paper isn't actually a true statement.

comment 4d ago · link · parent

Even ZGC now offers better predictablity than malloc/free allocators (which are a long way from predictable as far latency goes). But some hard-realtime software uses (or at least used to) RTSJ, a hard-realtime version of Java, that separates the heap to a part that uses a GC and a part that uses nested arenas. It was a big deal twenty years ago, when I worked on such software. I don't know how much it's still used. Probably not much. C is still king in that world, and Ada too, to some extent.

It's important to know that for hard realtime, even C alone isn't enough, though, and you need special kernels. Ordinary OS schedulers aren't predictable enough for hard realtime.

comment 4d ago · link · parent

That is just wrong. Moving GCs were invented because they're more efficient than manual memory management. In fact, in his famous 1986 paper, Garbage Collection Can Be Faster Than Stack Allocation, Andrew Appel wrote: "It is easy to believe that one must pay a price in efficiency for this ease in programming… But this is simply not true."

Moving GCs free you from the high overhead of malloc/free runtimes, something that us old C and C++ programmers have had decades of experience with, and why our colleagues developed large, complex runtimes such as TCMalloc and jemalloc to remove some of that overhead, even though not nearly as much as moving GCs do.

The reason low-level languages don't use moving collectors despite their superior efficiency is because they must give up on some performance optimisations for the abillity to interact with the hardware or OS directly, and that means that pointers must be stable machine addresses (this is why you need a richer FFI layer in Java). Moving collectors work in many ways like arenas. They don't need to maintain free lists whenever an object is allocated or freed (in fact, they never free any object at all), and memory is freed in bulk. This is not the only performance that low-level languages leave on the table because above everything else they must be low level.

Every single language that can use moving collectors does (it's also a matter of resources; moving collectors are hard to implement, especially the modern pauseless ones).

Sadly, people who are not compiler or memory allocator engineers don't know that, so they believe "popular wisdom" disseminated by other non-experts.

P.S.

Re AI: It's certainly possible that AI will be able to write good, efficient, large software some day, perhaps soon, but if it's able to perform the global program transformations required to replicate the optimisations of a moving collector without one, it won't need the simpler and more local optimisations done by a compiler, and will be able to work better without one, directly in machine code, in which case all compilers and programming languages are also done. In other words, moving GCs will not be a relic of the past before compilers are (or maybe roughly around the same time).

comment 4d ago · link · parent

That is not so simple. First, the differences among different GCs are bigger than between some GCs and no GC. Second, moving GCs - of the kind used in HotSpot (as well as V8 and .NET), but not Go or Python (which are as different from each other as they are from moving GCs) - do, indeed have a higher memory utilisation, but it's not necessarily inefficient, because most of it comes into effect when CPU is under higher pressure than RAM (that's when you get a larger young-gen, as the heap overhead is a function of the allocation rate, not of the live set which, in turn, means a high CPU usage). RAM and CPU are not independent resources; the most basic way to think about this is that your machine is exhausted when the first of CPU and RAM is exhausted. For example, I can take your car battery or I can take your petrol, but if I take your car battery when you don't have petrol, I'm not impacting your use of the car, so I'm not really creating any "inefficiency".

You are right, though, that in a very memory-constrained environment, usually embedded devices, you may want to lower memory consumption regardless of anything else, and in such environments moving GCs are probably not what you want (although other kinds of GC could be).

More here: https://youtu.be/xr73mR7ii9M

comment 4d ago · link · parent

> When a security vulnerability becomes public like this (regardless of why or by whom), that should have impact on timeline for fix, and maybe also communications. The cat's out of the bag already and no amount of silence will put it back in.

Not all vulnerabilities are created equal, and they don't all justify an emergency release (the JDK has regular quarterly releases for security patches). Until you know the impact, disrupting your users is not the best path to security (just as you don't want to police to respond to every suspicious occurrence).

> I don't think 1 month is reasonable timeline for a publicly known vulnerability like this.

It wasn't a publicly known vulnerability; it was a publicly known bug. If the original reporter had thought this to be a vulnerability he wouldn't have reported it like that (he's a former colleague who's familiar with project policies).

comment 4d ago · link · parent

That would be the wrong thing to do. You don't know how severe the problem is and what to advise your users. Important products like this have regular quarterly updates, where the less risky vulnerabilities are patched. You can't just cut an emergency release that your users may not be prepared to apply before you know what the risk is.

comment 4d ago · link · parent

That would be irresponsible. A vulnerability isn't closed once you merge a fix, and not once you release builds. It's closed when users apply the patch in production. That takes time no matter how quickly you release, and could come at the expense of other things your users may want to do, including addressing other vulnerabilities. Turning a bug into an exploit can also take time, even with the help of AI.

So until you know how dangerous the bug is and have a plan for release (does it go in the next quarterly patch, which users are ready for, or are you making a special release?) you shouldn't do anything public because you don't yet know what to advise your users to do.

comment 4d ago · link · parent

When your product runs the world, you need to coordinate exactly how a patch is released across multiple versions and when, and you don't want to tip your hand before everything is ready. A lot is riding on doing this right.

comment 4d ago · link · parent

> This is nonsense. Java doesn't "compile like C or C++ or Rust or Zig" any more than Python does.

It really does, though. Perhaps you're unfamiliar?

> Unsafe is still plenty prevalent in Java, nor is the use of C++ libraries.

My statement was that unsafe is much more prevalent in Rust than in Java, and that is true.

> Yes, well, that's some handwaving.

I'm sorry that I can't teach you principles of compilation here, but feel free to dig deeper.

> Yes. It is still very prevelant.

Much less than in Rust.

> Ridiculous... A ridiculous comparison.

You don't sound like either a runtime or compiler engineer at all, or you wouldn't have found any of this ridiculous in the least (or news). In that case, I hope that telling you that what I wrote was true might enrage you enough to learn more about these subjects, and perhaps our community will have grown by another member.

comment 4d ago · link · parent

We did know it was a potential security risk, and that is why it was handled exactly how security-sensitive issues are supposed to be handled (not to mention that the reporter is a well-respected OpenJDK contributor and former Oracle colleague).

I don't know if people here understand how these things need to be done in the most important and critical open source projects, such as Linux or OpenJDK, but there are two things you must not do when an issue is suspected to be a risk until you've researched the matter and decided on a backport and release strategy: You shouldn't communicate publicly, and you absolutely shouldn't merge a patch.

comment 4d ago · link · parent

He's listed as the fix's co-author (and he's a friend; he's a regular contributor and a former Oracle employee).

comment 5d ago · link · parent

I know that you can write slow data structures in safe Rust, but the standard library's data structures are supposed to be efficient. Anyway, a quick look at how common unsafe is in Rust vs Java, both in the standard library and in applications, and you'll see that it's much more common in Rust.

comment 5d ago · link · parent

Then you're in for a surprise. Take a look at TCMalloc and jemalloc. They're almost the size of HotSpot's most complex GC, then non-pause ZGC.

comment 5d ago · link · parent

There were no public comments precisely because it was immediately identified as a potential security risk! The JDK is so critical and sensitive (probably the most important open source project after Linux) that we have policies that are more carefully considered than your average open source project (including most language compiler/runtime projects). We can allow no public comments and no public merges of code on anything that could be a security risk before the security research team studies it.

comment 5d ago · link · parent

That is precisely why it wasn't dismissed and why there were no public activity on this issue.

comment 5d ago · link · parent

You could certainly require parentheses, but it's not a "just", because infix operators are desirable in the first place for readability, and requiring to write something like `((((((a + b) + (c * d)) + e) + f) + g)` significantly reduces that advantage.

comment 5d ago · link · parent

Because it runs so much of the world's most important software, the JDK is heavily watched, and removing a PR would only draw attention to it.

Also, it's not really a leaked 0-day because there's ways to go from a bug to an exploit (even going from Calif's detailed public report to an exploit is not trivial, because exploits depend on the particular application; there has been no disclosed exploit that requires only the JDK).

comment 5d ago · link · parent

I work on the JDK, and while I have no involvement with this issue, knowing how we work, what has likely happened is quite the opposite. Bugs don't slip through our triage, and every bug that leads to a VM crash, especially in the compiler backend, is flagged for security review by the security research team; once that happens, no public communication is done. I don't know this is what happened here, but it is the most likely thing to have happened.

We're not talking any large open source project here. We're talking about a project that, like Linux, runs much of the world's software infrastructure, and even bugs that could potentially be vulnerabilities need to be handled with great care.

12345
286