HNHacker News
TopNewBestAskShowJobs

voidnullnil

-9 karma · joined July 3, 2021

submissionscomments
voidnullnil··on Updating the Go Memory Model
The slice is simply unsynchronized, so a user of the slice may pull out one array but a length that was for a different array.

https://blog.stalkr.net/2015/04/golang-data-races-to-break-m...

voidnullnil··on Updating the Go Memory Model
Disregarding memory models, OOPSLA is not a good source for PL research.
voidnullnil··on ; DROP TABLE "COMPANIES";-- LTD
What's wrong with my comment? Quite literally: Cloudflare has been adopted by 50% or whatever of the web and they run a rudimentary WAF type product that is IP block happy. This is a recipe to get every VPN and Tor node in the world blocked.

What confuses me is that in 2010 all devs were finally on the "don't block stuff based on regex" train, and now all a sudden nothing matters just Cloudflare is God with some handwavy explanation of how they "did a risk analysis".

voidnullnil··on ; DROP TABLE "COMPANIES";-- LTD
And it marks your IP some points toward "evil hacker" and now you know why Tor has been ruined for 10 years. Collary: CloudBleed.
voidnullnil··on Updating the Go Memory Model
It's a big problem in Java at least. In Go you have value types by default and they try to make zero a meaningful value.
voidnullnil··on Updating the Go Memory Model
Go's errors have basically all the problems of exception handling in previous generation languages (and a few novel ones).

This explains it (tl;dr nobody bothers to formally define what errors they return, and the blindly propagate such unspecified errors, and it leads to ambiguity and unintentional program behavior)

https://www.lainchan.org/%CE%BB/src/1612397614615.jpg

https://www.lainchan.org/%CE%BB/src/1612397701473.jpg

https://www.lainchan.org/%CE%BB/src/1612398029019.jpg

voidnullnil··on Updating the Go Memory Model
Channels and an alt operator are much more powerful than locks but eh I can't remember the edge cases in Go's channels so you might be right,
voidnullnil··on Updating the Go Memory Model
I've never bothered to look up the hoare thing, but null as a member of all types increases the amount of time spent studying any given API (and of course, there are lots of null pointer bugs from people who didn't bother to study the API sufficiently).
voidnullnil··on No sane compiler would optimize atomics (2015)
So what's the motivation for the article? Presumably someone complained that the compiler optimizing atomics broke their code.
voidnullnil··on Cheating in FPS by using a second computer to move mouse
>will inevitably lead to trampling the user's freedoms

People keep saying this but it happened 20 years ago. This reminds me of shit like the postal service requiring photo ID to receive a package and people complaining about NSA hundreds of years later. Now you need a phone to play a game and some of the most popular need literal photo ID checks. Imagine, sending your photo ID which if stolen people can steal your money, to a bunch of newgrads running a game studio. This is what people (kids and manchildren) accept to address the overstated problem of game cheating. I played thousands of hours of games for 20 years and the number of cheaters I ran into is around 10 or 20. Most players of games (including the ones who complain about "cheaters") do not even have a clue what a game cheat is. They think some guy has some cheat that only works in this weird scenario that happens 1/100 games. Yeah, can you guys stop making me need photo ID for to play some stupid game? This is no different than every obnoxious statist concern that gets addressed by some charlatan who purports to be saving the world by ruining everyone's day (almost any time I install or configure a game my day is ruined, imagine a typical dependency hell but 10x worse). And no, I haven't ran into little cheaters because of "sophisticated anticheat" (stuff like punkbuster is extremely incompetent), it's because public hacks simply get blacklisted once they become big enough to matter.

voidnullnil··on Cheating in FPS by using a second computer to move mouse
Aimbots were already using "smoothing" methods in the original CS. Snapping to headshot is more to piss people off.
voidnullnil··on Cheating in FPS by using a second computer to move mouse
You will see it after it's gone due to persistence of vision, even at <10ms (no idea what the actual number is). Mind 20FPS is longer than a frame on even a 60Hz monitor.
voidnullnil··on Programming Language Memory Models
Thinking on: "[data races] are straightforward to identify"

It's a the same as the problem of knowing what data is used in what thread, which is hard and unsolvable by automation, so I doubt it's an easy problem.

voidnullnil··on Programming Language Memory Models
Okay, well your (wrong) semantic argument that "GMM violation = UB" is irrelevant, so I'll stop arguing against it other than hinting that there is not one single mention of the word "undefined" in the GMM spec. Back on topic: Go is not memory-safe. Your belief that "GMM violation = UB", where UB = memory corruption literally and by definition implies that Go is not memory-safe. Java (which is where the term "memory model" comes from) is memory-safe, C# is memory-safe. Go is not.

Dilettante programmers certainly do not know the following:

1. Go slices, strings, and interface values are unsafely non-atomic. It's documented on some obscure page (even the spec does not document it AFAIK, which is also broken).

2. What a data race is

Even if they know #1, they will still write code like: modifying a slice within a structure and setting a thread-shared pointer to point to that structure.

Again, most programmers are taught "things need locks, for reasons". At best, they will pointlessly lock things, then another programmer will come "debunk" them and remove the lock because "the thing being locked is atomic". Note how none of this involves any thought of the memory model. That's because they do not know it exists.

As for people who know #2, yes that is enough to avoid memory corruption without needing to know #1, however, they are not sufficiently informed how much data races matter (as executing shellcode is not an expected outcome of writes to your data being non observable).

voidnullnil··on Programming Language Memory Models
> because if you violate the memory model, literally any consequence is fair game.

Any consequence is _not_ fair game. "Memory Models" only involve stuff like tossing out sequential consistency [1]. They never say or imply something like "if you have a data race, anything can happen [including executing code on the stack]". Go slices exposing implementation details in a way that makes the language memory-unsafe is a completely different issue. If Go was sequentially consistent (so it had no "Memory Model" to violate), it would still not make the language memory-safe, because it would still write the array pointer and be pre-empted before writing the length.

> And that's not interesting

It matters because all programs have bugs (apparently), and so we'd like them to fail in a less harmful way than executing shellcode submitted by a client.

> it's easy to spot and fix data races, and Go provides plenty of tooling for that purpose.

Never used the data race detector but it probably can only identify low hanging fruit, and is not a substitute for the developer education problem.

Okay I think I see your confusion: You can actually avoid slices causing buffer overflows because the language requires you to have a happens-before relationship for all data shared across threads in the first place. That is, even if you share a boolean or across threads, you would be sure to establish a happens-before relationship if you are in the know. However, this does not rebuke my original argument, which assumes that most devs are not in the know. They do not know about slices being unsafe, nor do they know about happens-before. So they are not educated to prevent this mistake. Also, avoiding data races is hard.

1. https://en.wikipedia.org/wiki/Sequential_consistency

voidnullnil··on Programming Language Memory Models
> Like, all of that code violates the memory model,

and?

> so whatever it accomplishes is irrelevant.

I have no idea what point you are making. _Of course_ there has to be a bug in the code for there to be a buffer overflow vuln. Or are you objecting that they put contrived code to make the race work better (this is the concept of a PoC)? None of the patterns in that code are unlikely in practice.

voidnullnil··on Programming Language Memory Models
Not sure why people keep deducing this point I have not made. I said Go markets to dilletante programmers, which is a reason to make it simpler, not more complex. Any language with "the memory model" is complex. I do not fully grasp the memory model, either, as it requires full time investment.
voidnullnil··on Programming Language Memory Models
https://blog.stalkr.net/2015/04/golang-data-races-to-break-m...

The "Exploiting the slice type" section.

voidnullnil··on Tencent deploys facial recognition to detect minors gaming at night
As usual good advice but shouldn't be law.
voidnullnil··on A new brain implant automatically detects and kills pain in real time
Guess how can I tell this thread is bait without even opening it.
voidnullnil··on Programming Language Memory Models
> To solve that problem, the practitioner only needs to know that "mutex.lock()"

This is true, but they do not know that. If you do not give some kind of substantiation, they will shrug it off and go back to "nah this thing doesn't need a mutex", like with a polling variable (contrived example).

voidnullnil··on Programming Language Memory Models
How many programmers do you know put locks around polling varibles for seemingly no reason (as they are not cognizant of the memory model)?
voidnullnil··on Programming Language Memory Models
> This "Memory Model" discussion is only for people who want to build faster systems: for people searching for a "better spinlock", or for writing lock-free algorithms / lock-free data structures.

Actually, most practitioner code has bugs from their implicit assumptions that shared variable writes are visible or ordered the way they think they are.

voidnullnil··on Programming Language Memory Models
These "memory models" are too complex for languages intended for dilettante developers. It was a disaster in Java/C#. Not even more than a handful of programmers in existence know in depth how it works, as in, can they understand any given trivial program in their language. At best they only know some vague stuff like that locking prevents any non visibility issues. It goes far deeper than that though (which is also the fault of complex language designs like Java and C#).

The common programmer does not understand that you've just transformed their program - for which they were taught merely that multiple threads needs synchronization - into a new game, which has an entire separate specification, where every shared variable obeys a set of abstruse rules revolving around the happens-before relationship. Locks, mutexes, atomic variables are all one thing. Fences are a completely different thing. At least in the way most people intuit programs to work.

Go tries to appeal to programmers as consumers (that is, when given a choice between cleaner design and pleasing the user who just wants to "get stuff done", they choose the latter), but yet also adds in traditional complexities like this. Yes, there is performance trade off to having shared memory behave intuitively, but that's much better than bugs that 99% of your CHOSEN userbase do not know how to avoid. Also remember Go has lots of weird edge cases, like sharing a slice across threads can lead to memory corruption (in the C / assembly sense, not merely within that array) despite the rest of the language being memory-safe. Multiply that by the "memory model".

Edit: forgot spaces between paragraphs.

voidnullnil··on I do not agree with Github's use of copyrighted code as training for Copilot
Coming up with this "return $this" pattern to emulate a composition operator seems like a very AI thing to do.
voidnullnil··on In JS functions, the ‘last’ return wins
Blogs about "return" inside "finally" in Java and the likes were common in the 2000s. The fact that languages have so many simple things like this that surprise people indicates that there is a problem somewhere. I'm sure some of the older school languages (like VB maybe) had some insane semantics like an interrupted return will return null, I can't remember them in that much detail.
← PreviousPage 2 of 2