News for hackers. Stuff that matters.
Re:Show HN: A “living” Linux process with no memory by hsnewman on Thursday March 26, 2020 @10:57AM (#22694142)
Can this be implemented in Go?
Re:Show HN: A “living” Linux process with no memory by jerf on Thursday March 26, 2020 @12:02PM (#22694923)
I think so, but probably not reliably and/or for the long term.

In terms of the actual unmap call, the payload is in the munmap call, which is a syscall, and if you do have to set up the registers for that call, Go does have its assembler support which should be able to do that for you. You should be able to write Go source code that would perform that call, although you're going to be poking into some corners of Go most programmers never have to get into. You can also get to fuse, which in my experience is great at producing uninterruptible sleeps even when you're not trying to do it on purpose....

However, in terms of reliability and the long term, you have the problem that you're not the only thread in the program the way a C program can count on that, and if any of those other threads wake up and their memory is missing, it'll probably result in the process dying. You can do a couple things to try to avoid that a little, like pinning yourself to an OS thread and running the program in one CPU mode, but especially on the latest version of Go where they've implemented true pre-emption, you can't keep the runtime from running by just hogging the execution thread anymore.

So I suspect that as long as you win the race to unmap everything before the runtime wakes up (which may also require you to call sysmap through the assembly code directly, rather than using the syscall libraries as I'm pretty sure those notify the scheduler of what you're doing), you may be able to briefly be a process with no RAM mapped, but in human terms it won't be long before the runtime wakes up to do something, anything, and crash the process as a result. There's no way to avoid that in Go. You won't be able to have a process just sitting there indefinitely with no mapped RAM that you can admire and treasure and hand off to your children as part of their inheritance.

Re:Show HN: A “living” Linux process with no memory by saagarjha on Thursday March 26, 2020 @01:06PM (#22695626)
> you have the problem that you're not the only thread in the program the way a C program can count on that

Note that if you link against libc I think it would be legal for it to create a thread behind your back, so even in this case you're not quite safe.

Re:Show HN: A “living” Linux process with no memory by klyrs on Thursday March 26, 2020 @11:36AM (#22694576)
Normally I'm not a fan of people nitpicking language choices... but in this case I upvoted because this is a really weird "stupid program trick" and I'm curious what languages support such shenanigans.
Re:Show HN: A “living” Linux process with no memory by IT8z on Thursday March 26, 2020 @12:26PM (#22695205)
can a bf interpreter be written in sed?

https://github.com/izabera/bfsed

Re:Show HN: A “living” Linux process with no memory by stevemk14ebr on Thursday March 26, 2020 @11:06AM (#22694231)
we're programmers, anything can be done with enough time or money
Re:Show HN: A “living” Linux process with no memory by state_less on Thursday March 26, 2020 @11:25AM (#22694439)
Can you write a program to tell if any given program is going to halt?
Re:Show HN: A “living” Linux process with no memory by cwp on Thursday March 26, 2020 @11:35AM (#22694567)
Tell you what: you give me time and money, and I'll work on this program. Keep giving me time and money until I tell you I've succeeded.
Re:Show HN: A “living” Linux process with no memory by saagarjha on Thursday March 26, 2020 @12:04PM (#22694953)
Can someone write a program to tell me how much money I’d need to give you?
Re:Show HN: A “living” Linux process with no memory by kd22 on Thursday March 26, 2020 @12:12PM (#22695030)
Give me time and I'll tell you at the end how much money you need to give me.
Re:Show HN: A “living” Linux process with no memory by naniwaduni on Friday March 27, 2020 @12:22AM (#22700424)
Sounds like a good deal if we don't need to pay until you're done!
Re:Show HN: A “living” Linux process with no memory by state_less on Thursday March 26, 2020 @12:54PM (#22695478)
No need to be difficult, just give me an estimate. Is this going to be a small, medium or large t-shirt size task?
Re:Show HN: A “living” Linux process with no memory by necovek on Friday March 27, 2020 @01:30AM (#22700630)
Agreed, take all the time you need.
Re:Show HN: A “living” Linux process with no memory by enedil on Thursday March 26, 2020 @12:20PM (#22695131)
Sure, I'll just be giving you half your wage with each coming hour.
Re:Show HN: A “living” Linux process with no memory by Dylan16807 on Thursday March 26, 2020 @11:54AM (#22694818)
As long as linear execution time is acceptable, okay. Give me a couple million dollars and I'll have it to you in a week.
Re:Show HN: A “living” Linux process with no memory by yjftsjthsd-h on Thursday March 26, 2020 @11:36AM (#22694584)
With enough time, sure! [0][1]

[0] Disclaimer: may take slightly longer than heat death of current universe.

[1] Alternative solution: https://m.xkcd.com/1266/

[dead]
Re:Show HN: A “living” Linux process with no memory by yjftsjthsd-h on Thursday March 26, 2020 @11:34AM (#22694550)
Surely rust is the preferred option for that? Go hasn't been nearly as vocal in my experience.