News for hackers. Stuff that matters.
Re:Shadow: New browser engine made almost entirely in JavaSc... by Terr_ on Friday October 27, 2023 @06:20PM (#38044756)
Speaking of Electron... when I start my Slack client for work, there are a series of processes where at least one reports 1.130 terabytes of virtual memory. (Shown in top as "VIRT".)

Now, maybe that's just a potential usage that trust-me-bro it'll never actually try to use or access in RAM or on disk... but how on earth is that number for a chat client so much bigger than either Firefox with 100+ tabs or even Java-based IDEs like Webstorm?

Re:Shadow: New browser engine made almost entirely in JavaSc... by cangeroo on Friday October 27, 2023 @06:34PM (#38044877)
Virtual memory is allocated for isolation reasons. See v8 isolates.
Re:Shadow: New browser engine made almost entirely in JavaSc... by Terr_ on Friday October 27, 2023 @07:04PM (#38045114)
> v8 isolates

Javascript engines aside, that sounds like a great sci-fi movie macguffin material.

Re:Shadow: New browser engine made almost entirely in JavaSc... by mananaysiempre on Friday October 27, 2023 @07:43PM (#38045405)
Sounds like somebody is playing tricks with virtual addressing, yeah. See BIBOP (1980) [1] for an example, though it is not used literally in current garbage collectors as far as I am aware. Or look at what AddressSanitizer does with its nominal terabytes of “shadow memory”[2]. Chrome has a bewildering variety of low-level stuff in it, to save memory among other things[3], so it wouldn’t surprise me in the least to learn there was virtual-memory tagging somewhere in there, too.

[1] https://foldoc.org/Big+bag+of+pages

[2] https://github.com/google/sanitizers/wiki/AddressSanitizerAl...

[3] https://v8.dev/blog/oilpan-pointer-compression

Re:Shadow: New browser engine made almost entirely in JavaSc... by frutiger on Friday October 27, 2023 @09:52PM (#38046331)
V8 allocates a “gigacage” around every wasm memory area on modern 64 bit processors and marks them so the OS will trap on an unexpected access. This is much more efficient than doing a bounds check on every access. These pages are not actually resident.

“Big number is scary” is not a good way to understand performance.

Re:Shadow: New browser engine made almost entirely in JavaSc... by iforgotpassword on Saturday October 28, 2023 @06:45AM (#38048743)
No, but it means there is one less thing we can rely on to identify "process gone whacky".

Plus, admittedly I didn't think about this thoroughly just now, this sounds like a cheap hack for speed. You could still have an OOB access that would land in some valid memory and thus lead to an exploit, right? It's just made very unlikely by making these areas very large and having ASLR. Proper bounds checks wouldn't have that problem.

Re:Shadow: New browser engine made almost entirely in JavaSc... by tatref on Saturday October 28, 2023 @08:16AM (#38049238)
The memory is still owned by the electron process, so ASLR is not involved here. Also in case of OOB, you still land into the electron process.

VIRT is not a good measure of actual memory usage because it includes shared pages like file cache and libraries, RES is better.

Shameless plug: I developed a tool that try to compute a better value for memory usage: https://github.com/tatref/linux-mem