Today my colleague fixed one bug related to out-of-boundary access of array: a hash function returns the selected index of the array, but the hash function’s return value is int
, so in corner case, when the hash value is overflow, it can become negative, and this will cause access an invalid element of the array. The lessons I learnt from this bug:
(1) Review the return value of hash function;
(2) Pay attention to the index when accessing array, is it possible to cause out-of-boundary access?
Month: March 2025
How to obtain a big-endian CPU machine
Last week, I wanted to test whether a trivial function works OK on big-endian CPU. I have ARM
and X86_64
machines at hand, but both them are little-endian. After searching online, I come across Running a emulated SparcStation 20 with qemu-sparc, though I heard about qemu
before, but never used it, so wanted to give it a spin.
The installation of qemu
is straightforward, then I created a NetBSD-10.1-sparc
machine in just 3
steps (omit some configurations unneeded for me):
$ qemu-img create -f qcow2 ss20.image 4G
$ qemu-system-sparc -M SS-20 -m 256 -drive file=NetBSD-10.1-sparc.iso,bus=0,unit=2,media=cdrom,readonly=on -drive file=ss20.image,bus=0,unit=0,media=disk -full-screen -boot d
$ qemu-system-sparc -M SS-20 -m 256 -drive file=ss20.image,bus=0,unit=0,media=disk -full-screen -boot c
Then the machine booted successfully and met my requirement perfectly!
My telegram channel
I created a telegram channel: https://t.me/anoldprogrammer, and want to share following things:
(1) My experience as a software engineer;
(2) The tutorials, notes and tips about system programming, performance tuning and software engineering;
(3) Others, all related to software.
In summary, the channel will be a superset of my personal blog, and welcome to subscribe!
What is it like in my working day?
In the morning of every working day, the first thing I will do is synchronizing all the code repositories, and check the modifications committed by colleagues from other timezones when I was sleep, especially pay attention to the changes relevant to my work. At the same time, I also need to process the unread mails and slack messages.
After that, I will begin my daily work, mostly 3
kinds of tasks:
a) Develop new features;
b) Fix bugs;
c) Review other people’s PRs (Pull Requests). The reason that I list reviewing PRs separately is I find this task really costs significant time and energy since you need to understand how other people thought when coding.
Definitely, sometimes there will be an interrupt, e.g., someone asks me one question, and I need to pause current work and answer it. This is inevitable in a cooperated environment.
The above is my typical daily routine, and that’s it.