25,686 karma · joined Dec 23, 2011 (14y ago) · 8,555 submissions
Working on OpenJDK at Oracle
comment 1d ago · link · parent
comment 1d ago · link · parent
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
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
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
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
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
comment 3d ago · link · parent
comment 3d ago · link · parent
> 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
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 4d ago · link · parent
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
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
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
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
comment 4d ago · link · parent
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
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
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 5d ago · link · parent
comment 5d ago · link · parent
comment 5d ago · link · parent
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
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.