News for hackers. Stuff that matters.

7197ghr918hf

Re:Simple, Fast and Safe Manual Memory Management [pdf] on Wednesday September 27, 2017 @11:51PM (#15354413)
> We guarantee type and memory safety by introducing a new exception (DanglingReferenceException) with the following semantics: a dereference to a deleted object will either succeed as if that very object was not yet deleted, or result in a DanglingReferenceException.

I would worry about what might happen in a variable-sized object reuse/freelist type scheme combined with this allocator. A dangling reference might not contain garbage that allows an attacker to control program flow, while still containing data that is exploitable in other ways.

So this is not an entirely safe way to do things. Arguably it would be worth the speedup. But many of the techniques for making this approach safe . . .

> such exceptions can be detected with the combination of rigorous testing and support in the allocator for a debug mode that enforces stronger semantics (i.e. exceptions on every dereference to a deleted object) at a higher cost

. . . can also be used to test C++. For example, we use https://github.com/google/sanitizers a lot at the office to detect these sorts of errors.

Still, an interesting and clever result. Nicely done!

Re:Abseil: C++ Common Libraries on Wednesday September 27, 2017 @11:08PM (#15354250)
To my eyes, this code is much less clear than code that uses absl mutexes. Also, to my understanding, reentrant mutexes are much slower than ordinary mutexes, and are never necessary.

But, I have been using absl mutexes for more than ten years, so I'm a bit biased.

Re:Abseil: C++ Common Libraries on Tuesday September 26, 2017 @10:40PM (#15344490)
A couple of my favorite types and functions in absl:

- Span

For when you want to take an array or a vector.

- string_view

Avoids string copies. Makes your program faster. Its creation was a reaction to situations like https://news.ycombinator.com/item?id=8704318. (It predates that revelation, but internally the plague of string copies has been known for some time.)

- Mutex

A better mutex with deadlock detection.

- Substitute

A string formatting function between 5 and 1000s of times faster than snprintf. Profile your code some time. If it's anything like mine, you might be surprised at how much this matters.

- base::Time and base::Duration

Excellent wall time utilities, similar to Go's wall clock time libraries.

Re:Abseil: C++ Common Libraries on Tuesday September 26, 2017 @10:31PM (#15344437)
Googler-on-googler trolling. The internal version of the build rule they're discussing has some busted dependencies. Because of historical cruft, it brings in a lot of unrelated crap. For example, building a C++ binary might build bring in Haskell dependencies because of a protocol buffer. This is being fixed, but it's been a thorn in our sides for years.