by doix · 3y ago · 0 comments
I used to work for a company that had an internal tool. It wasn't used anymore, everyone that worked on it was long gone, the source code was "lost".
There was some emergency and someone needed to use the tool to look at some old data. Lots of panic and people claiming it was impossible.
I opened up the executable in ollydbg, patched the executable so it worked properly, and life went on.
I'm sure the source code wasn't lost, it would have been on a tape backup that people were too lazy to try and recover.
If the source code is available then it's even significantly easier. I don't buy this whole "nobody knows how to update the code" reasoning.
If the code can't be updated, it's a matter of incentives and prioritization.
Actually, in most cases - no, they can't. Or, rather, they can't figure it out as fast as they're "needed" to.
> if there's a real need with no alternative
What happens instead is that somebody with no real knowledge of software development says, "we need this change made in two weeks. We need this." That this might be impossible for any human being, living or dead, is completely ignored. If the programmer this is dumped on even suggests making any clarifying improvements to the code, even that is rejected because "we need" this.
And two weeks come and go, something was changed because there was a deadline, but the something that was changed broke a dozen other things nobody even remembers were there, and now there are bugs waiting to be discovered by unsuspecting users.
> it's a matter of incentives and prioritization
I know what you mean - it is, technically possible but it's never feasible because it's not predictable.
I've forensically self-onboarded a few times and yeah, it's at least 12x more expensive than well written docs + pairing.
It's economic for some projects but it's still crazy to do it if it's at all avoidable.
I see a lot of the time programmers doing the easy/fun thing rather than the hard beneficial to the business thing.
Loyalty gets you very little in today's climate. Why should I spend time understanding the current system that was developed on yesterdays hotness?
I need to spend my time here developing on the latest trends on a new solution (learning more from running into the same walls the current system did) - not learning the domain knowledge + old framework, so I can move on after a year and earn more at the next place.
Is this good for the world? No. But unless you want to swing the hammock and work at institions that value incumbents, the incentive is to do whatever work improves your resume, not what benefits the company.
I don't personally like it, and I often see old systems that are just fine get thrown out and replaced with the a less featured replacement that grow into the same kludge as the first, but I can't ignore that when you do that you learn way more and have better examples to point at in interviews.
Me too. At best, they would need the previous guys only in one condition: very short time constraint (have to figure it out "today"). Otherwise, it's not hard to figure out at all, even codes from a complete idiot. If he can code the program that worked, the code is very likely be figured out by experienced people very soon.
Sure, you can figure out how to change it to do some very specific thing that somebody identifies as needed. What you probably can't do (at least not in any reasonable amount of time) is figure out all the things you're going to break in making this change. If they followed good software development practices, left a good comprehensive set of unit tests and documentation then you could do that - but they didn't.
> even codes from a complete idiot
If I was wrong, there wouldn't be anything wrong with global variables or goto statements - any code that "works" would be isomorphic to any other code that "works".
Then you can start by writing the tests. That forces you to dig until you actually understand what's going on.
My "trick" is to write black box test without understanding the code. Like this:
1. Send in some data 2. Observe what data comes out. 3. Make a test asserting that! 4. Go back to 1.
That's how it works even with the same guys on projects. If you think it would break (no tests found), write the tests first. I don't believe someone would write a complete mess million line of codes that works without some tests and docs, that would make him kinda genius.
And global vars and goto is not hard to figure out, it's hairy for sure.
That makes you a great engineer that saved the day. Not all companies have great engineers that can save the day, or keep them, or even identify them.
Sometimes you also need to add features, which can be quite a task if you don't have the source code.
Other coworkers had interacted with the system a little, but not extensively. It was a bunch of C for (rock & ore) mining software. It was intimidating and it took time, but she cracked it, and then happily (& justifiably) bragged that she added features to code that had been written before she was born!
As an anecdote, your example demonstrates the truth of the reasoning. Absent extraordinary or unorthodox effort, such as patching the executable manually, programs do suffer from loss of understanding. Yes, you made it work, but can you really claim to understand the program and how it was written?
Of course, given enough time and effort, most code can be reverse engineered to a level of understanding good enough to work on it. In practice, most organizations are going to decide it's better to spend time and money on a replacement.
> I'm sure the source code wasn't lost, it would have been on a tape backup that people were too lazy to try and recover.
That's certainly one, rather uncharitable, way to look at it. But what constitutes sufficient effort, given time and money constraints in the real world? Unless that backup literally contained the only copy of information essential to the continued existence of the company, there's a limit. And what if they did find the backup, but it was on a magnetic medium that had degraded to unreadability?
I've made my career working on legacy code. There are definitely ways to understand systems even when nobody who originally worked on them is around, but business constraints have always determined whether or not the effort proceeds or is abandoned.
In my own experience, devs aren't often overworked and do have the time to do stuff like this. They just rather not spend the time on it for various reasons.
What incentives would get you to work on an old legacy project?
Maybe not, actually. Assuming that the code was written in the 90s, there probably wasn't any version control (only backups at specific milestones).
With no version control, there's a 50:50 chance that the source code you found for some deployed version is not the same as the code that was backed up.
Sure, I had source that I had written. In source control even, was using fossil. But I thought my binary might end up somewhere decoupled from that source, with some other engineer tasked to modify it, and I hope they find the dump source option listed under -help useful.
Well, by that logic, someone can build it from scratch.
I've done simple binary patching, and thank my lucky stars that:
1. The replacement configuration value strings were shorter than the original
2. It was written in C, using nul-terminated C strings
If this was almost any other language, I would have more work even if the replacement string was shorter, because I'd have to fix a bunch of offsets everywhere.
In my specific case, the tool had a whole bunch of hardcoded values. It checked authorization against an LDAP server, that all changed. Connected to a sql sever that moved + credentials changed. Assumed certain files existed on certain network drives which were moved.
Technically, it could have been solved by faking all the infrastructure. It also could have been solved by digging out the source code from tape drives. But everyone was running around saying it was "impossible". I was shocked how quickly people tossed out "impossible".
It could have been done with a simple hex editor, but the new values were longer than the old values, so the strings didn't fit. I put the new strings at the end of the .data section and then just changed a bunch of offsets.
I agree that if you're writing the next version of the software, you can't do that quickly when nobody knows how the current version works. But chances are, you're not writing the next version of the software quickly even without churn.