HNHacker News
TopNewBestAskShowJobs

bugfix-66

501 karma · joined September 24, 2022

A debugging game for hackers: https://BUGFIX-66.com
submissionscomments
bugfix-66··on The ancient Finnish predictor data compressor. Smallest compressor ever?
This is a folk algorithm of unknown origin.

All I know is the original author was probably a hacker from Finland and it was originally written in x86 assembly. This is my modernized implementation of his algorithm.

As for solving the BUGFIX-66 puzzles, to fix the bug in the compressor, add

  to = append(to, 0)
on the line after

  loc = len(to)
The original code was not inserting a placeholder for every control byte.

To fix the decompressor, add

  at++
on the line after

  ctrl := int(from[at])
The original code was not stepping past a control byte after loading it.
bugfix-66··on A Tour of C++ (Third edition)
Thank you for being honest.

This safe, "no worries" C++ was segfaulting. You've managed to make it correct today but it's still unsafe.

Someday one of your coworkers is going to break it and this code will be trashing the heap. Mysterious memory corruption failures are your destiny.

That said, Happy Halloween!

bugfix-66··on A Tour of C++ (Third edition)
After giving your code a quick skim, I cannot see any mistakes in your vector indexing.

However, your code is full of vector accesses without bounds checking: vec[i] instead of vec.at(i).

That's just as "unsafe" as C, so I recommend not bragging about how far you've come.

Your code is full of what is essentially unprotected C-style

  *(addr + i) = ...

  ... = *(addr + i)
You've been writing C++ since the 1980's, but your code is full of raw pointer math, and yet... "No worries about memory safety"?

I have a feeling you'll be reaching for Valgrind or address sanitizer someday soon, just like the C programmers.

bugfix-66··on The ancient Finnish predictor data compressor. Smallest compressor ever?
And the corresponding decompressor:

https://bugfix-66.com/d548f3abf6faa823a829e4c770a8babca648a5...

Does a simpler compressor/decompressor exist with comparable bits-per-byte performance?

bugfix-66··on AI-generated art sparks backlash from Japan’s anime community
Systems like Copilot and Dall-E and so on turn their training data into anonymous common property. Your work becomes my work. This may appeal to naive people (students, hippies, etc.), for whom socialist/communist ideas are attractive, but it's poison in the real world.

These systems are a mechanism that can regurgitate (digest, remix, emit) without attribution all of the world's open code and all of the world's art.

With these systems, you're giving everyone the ability to plagiarize everything, effortlessly and unknowingly. No skill, no effort, no time required. No awareness of the sources of the derivative work.

My work is now your work. Everyone and his 10-year old brother can "write" my code (and derivatives), without ever knowing I wrote it, without ever knowing I existed. Everyone can use my hard work, regurgitated anonymously, stripped of all credit, stripped of all attribution, stripped of all identity and ancestry and citation.

It's a new kind of use not known (or imagined?) when the copyright laws were written.

Training must be opt in, not opt out.

Every artist, every creative individual, must EXPLICITLY OPT IN to having their hard work regurgitated anonymously by Copilot or Dall-E or whatever.

If you want to donate your code or your painting or your music so it can easily be "written" or "painted", in whole or in part, by everyone else, without attribution, then go ahead and opt in.

But if an author or artist does not EXPLICITLY OPT IN, you can't use their creative work to train these systems.

All these code/art washing systems, that absorb and mix and regurgitate the hard work of creative people must be strictly opt in.

If you don't care about this, it's naivete, or a lack of foresight, or apathy as these companies pillage the commons. Not something to be proud of.

Microsoft and OpenAI (and others) are robbing us and you should care.

bugfix-66··on Bit Twiddling Hacks (2005)
And you may enjoy the BUGFIX-66 puzzles, e.g.:

Upside-Down Arithmetic Shift: https://bugfix-66.com/76b563beb6f4e61801fce4e835be862fb3dbbe...

Too Much Padding: https://bugfix-66.com/4873075d23c096af3e6103b1b883f65a32f7b7...

XOR Swap Misguided By Mask: https://bugfix-66.com/762ee0db0776b3450e01cb05622d136db78554...

Fumbling Bit Fields: https://bugfix-66.com/014fee7b1b170fa85315640df44a1049af23a8...

The Bit That Decides It: https://bugfix-66.com/fdb8bb4fa84cf810aa25ff40c88a13c1874410...

Noncontiguous Subtraction (Not Quite): https://bugfix-66.com/adbc40fa7c8c838d8d34bcd35525313dc91dea...

And so on...

bugfix-66··on Column Vectors vs. Row Vectors
Fix the bug:

Is the matrix row major or column major?

https://bugfix-66.com/e74dcfb6a10cb71404f495922533d947e39fd7...

bugfix-66··on Rarely used shortest path algorithm simpler and more powerful than Dijkstra's
Wikipedia:

https://en.m.wikipedia.org/wiki/Shortest_Path_Faster_Algorit...

Spoiler:

To fix the bug, change

  dist[to] = dist2
to

  dist[to] = dist3
bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
People like you can EXPLICITLY OPT IN to being used by Copilot or Dall-E.

The rest of us aren't so selfless.

bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
With open source software you receive something very valuable: social capital, credit, respect.

Communism is where you do the work (or don't) and everybody is rewarded equally.

That's the Copilot model: you work hard to write the code, and receive nothing in return, because now everyone and their 10-year old brother can write it simply by asking for it... and your name never appears.

You were robbed.

bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
I guess every generation has to rediscover why communism doesn't work.
bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
Follow the rules of the license. If the author wants credit for his work, you give credit. Period.
bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
Here is the MIT License. Note the very important requirement for attribution ("you must give me credit for my hard work") italicized below:

Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bugfix-66··on Ask HN: Am I the only one not caring about GitHub Copilot?
Systems like Copilot and Dall-E and so on turn their training data into anonymous common property. Your work becomes my work. This may appeal to naive people (students, hippies, etc.), for whom socialist/communist ideas are attractive, but it's poison in the real world.

These systems are a mechanism that can regurgitate (digest, remix, emit) without attribution all of the world's open code and all of the world's art.

With these systems, you're giving everyone the ability to plagiarize everything, effortlessly and unknowingly. No skill, no effort, no time required. No awareness of the sources of the derivative work.

My work is now your work. Everyone and his 10-year old brother can "write" my code (and derivatives), without ever knowing I wrote it, without ever knowing I existed. Everyone can use my hard work, regurgitated anonymously, stripped of all credit, stripped of all attribution, stripped of all identity and ancestry and citation.

It's a new kind of use not known (or imagined?) when the copyright laws were written.

Training must be opt in, not opt out.

Every artist, every creative individual, must EXPLICITLY OPT IN to having their hard work regurgitated anonymously by Copilot or Dall-E or whatever.

If you want to donate your code or your painting or your music so it can easily be "written" or "painted", in whole or in part, by everyone else, without attribution, then go ahead and opt in.

But if an author or artist does not EXPLICITLY OPT IN, you can't use their creative work to train these systems.

All these code/art washing systems, that absorb and mix and regurgitate the hard work of creative people must be strictly opt in.

If you don't care about this, it's naivete, or a lack of foresight, or apathy as these companies pillage the commons. Not something to be proud of.

Microsoft and OpenAI (and others) are robbing us and you should care.

bugfix-66··on Ray tracing Voxels made out of Glass
The fix for the noncontiguous addition puzzle is to change

  filled = to & mask
to

  filled = to | ^mask
In other words, to OR in 1-bits so the carry can travel across the irrelevant part of the register.

Subtraction is similar:

https://bugfix-66.com/adbc40fa7c8c838d8d34bcd35525313dc91dea...

But for subtraction you want to AND in 0-bits so the borrow can travel.

bugfix-66··on Ray tracing Voxels made out of Glass
I take it you didn't "read or see" anything I wrote above.

But thanks for taking the time to post a comment!

bugfix-66··on Ray tracing Voxels made out of Glass
I used this technique commercially (about 5 years ago) to build voxel representations of the world in real-time from lidar data (Velodyne VLP-32C).

Each lidar return (a 3D point) provides a line of empty voxels from the lidar origin to the location where the laser hit a surface. Because you know the light followed that line uninterrupted, you know all the voxels on the line are empty.

The lidar is giving you thousands of points per second and the lines (derived from the points) carve the voxel space. The voxel space is rendered continuously. It's very satisfying to watch the space being carved out.

I don't know of anyone else using this technique before me, and I don't know of anyone doing it now.

bugfix-66··on Ray tracing Voxels made out of Glass
If you're ray-tracing voxels on a GPU, one technique is to use a single bit per voxel (so 32 voxels per uint32_t: a 0 bit means empty, a 1-bit means filled) and then put the whole voxel space into a Morton space-filling curve like this:

https://bugfix-66.com/e2d9aaf5b7f285b4d35c46e87fcf6f7e25d338...

You can then cast rays through 3D space mapped onto 1D space, with one ray per GPU thread.

The space-filling curve gives you locality of reference (just like an octree), and the simple linear nature of the data means you can use a sparse bit vector to represent it. Huge regions without voxels are represented implicitly:

https://bugfix-66.com/7256e0772dc3b02d72abf15b171731c933fd44...

Of course, you want a much larger branching factor (to get a shallower tree) for rendering.

You can step your ray through the space without deinterleaving the bits, like this:

https://bugfix-66.com/d6907b4d3eb6330241128ffbaeef6194ddeecc...

This technique allows extremely detailed (and real-time editable!) voxel worlds with tiny code.

bugfix-66··on Incremental Parsing in Go
Correct, Go is fast, very close to C.

And just like in C, if you want to avoid memory management overhead you can use a slice of structs, integers instead of pointers, and a freelist (if needed). For example, here is a pointerless sparse bit vector:

https://bugfix-66.com/7256e0772dc3b02d72abf15b171731c933fd44...

The article is storing parses in a balanced binary tree, like a packrat memoizing parser.

Here is the fastest balanced search tree in Go. It allocates (and uses Go's garbage collector) but you can easily use a slice of structs with integer index pointers and a freelist instead:

https://bugfix-66.com/c93e950965804eba90a34e0055985b1c42d5a1...

The above code will perform very similarly to C.

bugfix-66··on 5 Years of Pop _OS
I've owned three System76 desktops.

Highly recommended if you want a Linux desktop computer.

bugfix-66··on Teach Yourself Programming in Ten Years (1998)
The server is checking the output of the function.

Here is an example of what's running behind the scenes, to help you understand:

https://bugfix-66.com/contribute

The above code is what's being used for Bug #1:

https://bugfix-66.com/a6cb1e062ae0fdc47b43ec489aa40a958db728...

Is that pretty clear?

bugfix-66··on Teach Yourself Programming in Ten Years (1998)
Please, can we not be so uptight and formal in an informal discussion forum?
bugfix-66··on Teach Yourself Programming in Ten Years (1998)
When your code is wrong, the server gives you a clue hinting at what's wrong in the original code.

It doesn't know what's wrong in the code you submitted... it is not understanding deeply what's wrong with your code. It's not some huge multi-terabyte language model analyzing arbitrary code, or whatever.

It just knows your code is wrong and gives you a clue so you can try again.

bugfix-66··on Teach Yourself Programming in Ten Years (1998)
You're using a signed integer.
bugfix-66··on Teach Yourself Programming in Ten Years (1998)
Show me your code, that you think is correct, and the server rejects.

I'll tell you what's wrong with your code.

bugfix-66··on Teach Yourself Programming in Ten Years (1998)
The above code is correct, and of course it is accepted.
bugfix-66··on Teach Yourself Programming in Ten Years (1998)
Yes, the code you enter is compiled and run against a suite of tests. Any change that fixes the function will be accepted.

Any change that doesn't compile (bad syntax) or fails the tests is rejected. Code that produces deadlock or panic or timeout is also rejected.

If you give me an example of a rejected solution, I'll show you why the solution wrong.

bugfix-66··on Teach Yourself Programming in Ten Years (1998)
Go is very close to C.

A C programmer who understands a for loop should be able to fix this, despite the fact it's Go:

  // We are generating n-1, n-2, ..., 1, 0

  func below(n uint64, to chan uint64) {
      for n--; n >= 0; n-- {
          to <- n
      }
      close(to)
  }
Maybe you're right: It could be that C programmers don't understand Go syntax and Go programmers tend to be less experienced.
bugfix-66··on Teach Yourself Programming in Ten Years (1998)
There is evidence that a large fraction of Hacker News readers are early in their programming journey. Presumably people migrate elsewhere as they mature? I don't know of another forum like Hacker News, so where are they going?

To understand the level of programming skill on Hacker News, consider that less than 5% of Hacker News readers succeed in adjusting a loop iteration variable to avoid unsigned overflow (despite repeatedly attempting to do so):

https://bugfix-66.com/8617f16fa68e021b656b1856f94afebf7a3117...

This is an empirical observation and not an attack (please don't flag/downvote this comment). It tells us something about the population of users on the forum, and where they are on the developmental timeline as programmers.

It seems like more senior programmers move on, maybe.

bugfix-66··on SHA-3 Buffer Overflow
I read the code carefully, both yesterday and today, and it's correct.

Read it yourself here:

https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.1.0:...

There's obviously no problem.

← PreviousPage 5 of 7Next →