Skip Navigation

Posts
15
Comments
10
Joined
3 yr. ago

  • Yes, I am aware that is libmpdec code really.

    Also, I was a bit lazy myself and used the original buffer size. Even neater solution would allocate exactly the required memory space from heap instead.

  • Programming @fedia.io

    Having coded #C for a long time (and on platforms that are bit skimpier on resources) I have a special dislike for excessive stack space allocation. Stack space is precious, and gobbling it

  • So what was the bug I was looking for?

    We recently switched off_t from 32-bit to 64-bit. Once this change was made, suddenly the "ar" tool would start to generate corrupt archives when objects were deleted from the archive.

    It took quite a long time to find out that this snippet in the open function was the root cause:

    if (!error && (mode & O_TRUNC)) { syscall(SYS_ftruncate, fd, 0);

    Needless to say, ftruncate was getting a very large length argument passed to it, resulting in the underlying filesystem outright refusing to perform any action -> O_TRUNC would not truncate existing files -> ar generated a corrupt archive when the file shrank.

    It's obvious now, but believe me it wasn't easy to find it.

    #bugstories

  • Programming @fedia.io

    Deliberately not calling API functions that you're supposed to.

  • @Alexstarfire@lemmy.world I sure did. I also renamed the variable to a name that makes its existence obvious to anyone reading the code.

  • The code originally made a copy of a struct before modifying the copy. The original was then used afterwards. I entirely missed the later use and that it was critical that the original struct was used as is. So I passed a subtly modified struct to the later processing, which, in combination with a second bug I had introduced some time earlier, caused all kinds of havoc.

    There was another bug I also introduced, which funnily had similar effects. This bug was added months ago, and it affected only older OS versions. I typically only run the bleeding version during development (but I had tested the change with older versions, too). Unfortunately, this issue was random as it depended on stack contents to get triggered, and thus went unnoticed until the additional scrutiny introduced this intense debugging session.

    The combination of these factors made this highly frustrating thing to debug, as any kind of A-B testing fails when you have multiple or random issues.

    #bugstories

  • Programming @fedia.io

    I just spent untold hours debugging an issue I introduced myself by "removing an unnecessary variable".

  • Retro Gaming @fedia.io

    Game copy protection was an art form, as well as #cracking these protections. This cat and mouse game evolved over time, with protections including more and more complicated and well-hidden checks

  • Programming @fedia.io

    The feeling when you notice a bug in your binutils port that has been generating semi-randomly broken branch relaxation trampolines for decades.

  • Programming @fedia.io

    In my youth I wrote m68k assembly programs with tens of thousands of lines and speed optimized every section of the code, even initialization/cleanup executed exactly once. It was very very silly. It

  • Retro Gaming @fedia.io

  • Hacking @fedia.io

  • @jgrg Oops, it's u-z. Corrected the post now, thanks for pointing that out.

  • Some random notes after glancing over the G15D programmer’s reference manual:

    Bendix G-15 doesn't use hex, but sex: The notation is 0-9 u-z (sexadecimal).

    Section 3.2.3 goes into details on how to optimize performance: You need to carefully plan the order of instructions and data on the drums for optimal speed. The most optimal code will overlay computation and memory accesses. This reminds me of "the story of Mel". The optimization tricks done don't differ much from handcrafting optimal assembly code on more modern systems where external memory accesses are very expensive vs computation within registers.

    The addressing notation directly addresses line on the drum and offset of the word on that line. There are 20 lines with 108 29-bit words on each. Arithmetic operations operate on a separate short "register" lines that circulate much faster than the actual memory (27x speed vs memory drum).

    Considering how slow it's to process individual memory loads / stores, it makes perfect sense that the system has block copy instructions.

    Each instruction has offset within the line to the next instructions to execute. That is, there's always an explicit jump encoded in each instruction. Conditional code execution occurs by suppressing the jump when condition is met, in which case the jump is not taken and next instruction is executed instead. In modern architectures you generally execute next instructions address and there are dedicated branch instructions.

    Code execution can happen from 7 long lines (0, 1, 2, 3, 4, 5, 19) and one short line (23). Some lines have reserved roles and offsets, at least when using the libraries provided by Bendix.

    As there is no built-in stack register or stack a return address for subroutine calls must be handled manually. This is reminiscent to link register on some later platforms (such as PowerPC). It of course is entirely possible to manually maintain a stack on some line, dedicating some fixed address as stack pointer. All code must then agree on this decided calling convention.

    Punched (paper) tape and magnetic tape is available for input, as well as typewriter (console). Output can be (IBM) punch cards, magnetic tape or typewriter (console). The typewriter also has some switches for control.

    retrocomputing #programming #bendixg15

  • Programming @fedia.io

    I love the introductory chapter in the Bendix G15 Programmers's Reference Manual - when computers were still fresh enough that you had to start from the very basic concepts.

  • Hacking @fedia.io

    Cross-compiling anything depending on gnulib on a more exotic platform can be exercise of patience: gnulib will replace some perfectly working libc functions with its own replacement functions - which

  • Floating Is Fun @fedia.io

  • Hacking @fedia.io

    #lftkryo creating #SIDmusic from scratch at the #Commodore64 BASIC prompt:

  • Hacking @fedia.io

    Sometimes you write a quick, dirty & fugly thing and immediately feel disgusted by it. But it works, so does it matter in the end?