News for hackers. Stuff that matters.
Re:Mio – Cross-platform header-only C++11 library for memory... by osivertsson on Saturday October 20, 2018 @01:07PM (#18264208)
Another problem with mmap is that there is no good way to handle I/O errors.

The application will get a signal (SIGSEGV/SIGBUS, can't remember), and no information about what the problem could possibly be. Most applications do not catch these signals and will instead just terminate.

Even if you do catch the signal there is a real challenge to know what caused the signal and to keep consistent book-keeping to be able to perform any sane action in response.

At a previous employer we started seeing this problem when scaling things in production which was no fun.

Re:Mio – Cross-platform header-only C++11 library for memory... by __sr__ on Sunday October 21, 2018 @02:57AM (#18267013)
I was burnt by a third party application using mmap over NFS recently. Definitely not fun by any definition of it.

And it gets a SIGSEGV and segfaults.

Re:Mio – Cross-platform header-only C++11 library for memory... by pradn on Saturday October 20, 2018 @01:53PM (#18264481)
A library that helped manage MMAP errors would be extremely helpful.
Re:Mio – Cross-platform header-only C++11 library for memory... by quotemstr on Saturday October 20, 2018 @03:07PM (#18264876)
I wanted to help address this problem with my signal sharing API proposal. Unfortunately, the glibc people have the attitude that nobody should be using signals, and so they refuse to improve the signals API at all. I strongly disagree.

https://www.facebook.com/notes/daniel-colascione/toward-shar...

Re:Mio – Cross-platform header-only C++11 library for memory... by spc476 on Saturday October 20, 2018 @05:46PM (#18265667)
There's a reason for that---signals are horribly abused as a general purpose signaling mechanism. Originally they were for signaling of actual problems in the code (SIGSEGV, SIGILL) but later signals were not (SIGWINCH I'm looking at you!).

I read the page you linked to, and just off the top of my head, trying to manage paging by catching SIGSEGV is how do you determine that it's in response to a real bug (say, dereferencing an undefined pointer)? In my opinion, by the time you get a SIGSEGV, you can't trust the program at all. While it might be nice to have a process handle page faults itself, I think a better API than signal() is required.

Re:Mio – Cross-platform header-only C++11 library for memory... by quotemstr on Saturday October 20, 2018 @07:23PM (#18265996)
To distinguish the SIGSEGVs that represent crashes from ones representing faults you care about, you look at the fault address. It works perfectly well: every high performance Java or C# runtime on Linux (e.g., HotSpot, ART) does it. You can trust the program, because SIGSEGV delivery isn't magic.

As I detailed in the doc and on libc-alpha, you really do need some kind of synchronous exception mechanism to match how real hardware behaves, and it would behoove libc authors to make this mechanism not suck instead of pretending that synchronous faults would just go away.

Re:Mio – Cross-platform header-only C++11 library for memory... by mcguire on Saturday October 20, 2018 @10:26PM (#18266470)
Aaaaah. Memories.

If you caught SIGSEGV on AIX 3.2.5 to manage a mapped NFS file, you deadlocked that filesystem. Great fun!

Thanks for the flashback!