It's always great when you can start compiling on your own OS. It means it's close to being self-hosting.cloudapio wrote:[...]
Hello everyone! This is my first time posting on this forum, but I have been working on my OS for more than a year now. Today, I finally managed to make GCC work on my OS (after four months of it segfaulting every time I tried to run it).
Turns out the culprit was a bug in my memmove implementation, of all things:
[...]
The first i++ should have been i--. I have no idea how I managed to have a functioning OS for so long with that bug there, I fixed it after a GUI text editor I was working on started behaving a bit weirdly.
The memmove bug reminds me of a problem I had with Linux on PPC around 2005-2006. Where Linux on x86 was rock-solid, many of the same programs segfaulted randomly on PPC. I think it had to have been something as deep as memmove if not within the kernel itself. It got better, then 8-10 years later got bad again. I wasn't too surprised by it getting bad again because Linux is heavily optimized and changes frequently enough that it needs "many eyes" constantly on the lookout for bugs. Less popular platforms are going to have problems. There's a lot to be said for not optimizing or changing that which works well enough.
There's also a lot to be said for testing, but it's not always easy to test well and it's awfully tempting to just write code and only fix the most obvious problems.