11 ms·
Compiling an application for use in highly radio-active environments
- dkopi 11y agoThese type of posts are what bring me to hacker-news.
- sickbeard 11y agoisn't this like trying to do numerical analysis while having alzheimer's? if the hardware is bad, your software will be bad.
- Swizec 11y agoYes. But what if you have to make a reliable system for, say, cleaning nuclear reactors? Or flying between planets? Sometimes software needs to be able to work around bad hardware.
- Normal_gaussian 11y agoFor the former you use mechanical manipulators and sensors and keep as far away as possible.
- raverbashing 11y agoYes, that's why it's called rocket science The answers there are very insightful
- ams6110 11y agoYeah, naively the answer seems like "more shielding, Mr. Scott."
- baq 11y agoyou're pessimistic. the optimist would say 'how much numerical analysis can i do at varying levels of alzheimer?' and responses to the question are very well worth reading.
- sickbeard 11y agoAll good, except most of your mitigating code/tricks cannot be tested reliable to know they actually work.
- vinceguidry 11y agoThat's still unnecessarily pessimistic. You can examine the various types of unreliability you're getting from your test techniques to try to drive an understanding about the operating environment. If you have something in front of you, there's really no reason you can't at least try to come to some kind of understanding of it. Then do your best to communicate your findings.
- VLM 11y agoLiberal arts types say engineers are not creative, but they're wrong. Find some creative engineers, it won't be much of a challenge. Write 5 lines of perl that run logical AND and logical OR on a randomly generated bitmap emulating flash memory error rates at 1e-3, 1e-5, 1e-7, then run a billion emulation cycles (depending on code complexity this might take a long time, or maybe not). If you're doing it right, you have the code for the emulator, never use closed source for this kind of work unless you trust it with your life (LOL) so implement statistical error injection in your emulator. Guess what, your CPU adder now has a 1e-5 bit error rate. This is before the dreaded "programmer with a soldering iron" is unleashed. A white noise source is attached to pin D0 of the CPU and levels are increased while behavior of the system is analyzed in the test jig. Simplistically, radiation is linear, so running at 100x intensity for a month is the same as running at design intensity for 100 months. Talk to your local nuclear physicist or radiologist. Especially about neutron activated decay products, LOL. In more detail, if it takes xenon 12 hours to build up to a problem level, you can't just test at 100x intensity for an hour and call it good because 11 hours after the test ends you'll finally have 100x the xenon decay product as a contaminant, but that's a weird situation.
- pdabbadabba 11y ago> Liberal arts types say engineers are not creative, but they're wrong. I take your basic point--and it's a good one--that engineering is actually a very creative pursuit, when done well. But like any other high-expertise field, it's difficult for people on the outside to understand how engineers solve problems and, thus, to appreciate the sorts of skills required to do it well. But isn't one of the lessons here that it's probably not a good idea to make gross generalizations about the attitudes and dispositions of people in other disciplines? :) I think "Liberal arts types say engineers are not creative" is probably about as true as "engineers are not creative." There may be some kernel of truth to each, but neither is especially accurate. (The kernel of truth may be that each statement could often be true when relativised to dumb liberal arts types and dumb engineers.)
- 0xcde4c3db 11y agoEven with more robust hardware (and the question says that their hardware is designed for this environment), software redundancy and error checking can still be worthwhile, even when it only means that you catch the hardware malfunctioning rather than being able to fix the error. Still, for things that are really mission-critical, I'm not sure there's any substitute for full-blown hardware redundancy, e.g. having 3 computers and requiring 2 of them to agree on an action (via an interlock mechanism that is itself robust and redundant, which is a whole other can of worms...).
- deleted 11y ago[deleted]
- JabavuAdams 11y agoThere are many cases where we accept that some component of a system will be faulty and then design a system around it that neutralizes or mitigates those faults. Think of COTS servers, space-craft, or various people-management processes.
- technion 11y agoI appreciate it may not be the right tool in an extremely resource constrained embedded environment, but the "my hardware can't be relied on" on problem is almost exactly what's described several Erlang guides. http://learnyousomeerlang.com/the-hitchhikers-guide-to-concurrency http://learnyousomeerlang.com/the-hitchhikers-guide-to-concu...
- brillenfux 11y agoIs it concerning, that I see a question like that on Stack Overflow or am I too pessimistic?
- danesparza 11y agoI'd personally rather it get asked in a transparent way (like this) vs some programmer making some stupid assumptions in some cube somewhere.
- MichaelGG 11y agoI think the implication was "why is it possible for a programmer to make a stupid assumption". In such a critical environment, one would hope there's oversight and understanding of all of this, eliminating the need to ask on SO.
- dkopi 11y agoThere are lots of high radiation environments people have to deal with. Satellites, Medical Devices, Nuclear power plants, Particle accelerators, and even the type of robots sent in to nuclear disaster areas: http://www.sciencealert.com/the-robots-sent-into-fukushima-have-died http://www.sciencealert.com/the-robots-sent-into-fukushima-h...
- nxzero 11y agoWhy? Where & how would be the right way to ask a question like this?
- dkopi 11y agoInterestingly - A lot of the advice here (such as having an "Active" module and a "Standby" module with a heartbeat between them, Watchdogs, reducing single points of failure, error detection codes) is applicable to a lot of other High Availability scenarios. Think load balancers, databases, routers and high scalability networking devices for example.
- Unklejoe 11y agoI write code that is executed in rad environments. The fist thing I learned is that any plan that I come up with to help mitigate risks always ends up being proven less effective than I initially thought. The idea that the hardware can flip bits or latch up behind your back is rarely a consideration for most software design work, so it really requires an entire new way of thinking. In the end, it's all about reducing probabilities, but sometimes your mitigation techniques can be borderline useless. This could be because of my relative lack of experience though. I'm sure there are people who have been doing this a while and have converged on a design process that works well. Couple this with the fact that code in the failure path very rarely gets actually tested with _real_ failures during design, and you end up with situations where your entire test/precaution/recovery technique is rendered useless by a single oversight. It kind of reminds me of how some bootloaders perform a DRAM test during power up. The only problem is that these tests are usually executing after the bootloader is already running from RAM itself. Sure, it's better than nothing and may help to find some obscure errors like a bad address line pin or something, but the issue here should be obvious - if there was a real problem with the DRAM, it's likely you wouldn't even get to that test, so now what? Another example: suppose you have a PI bus connecting to an FPGA, and you are relying on the PI_done line to pace transfers. Now, a common test to verify the bus is working would be to read some magic word from the FPGA or maybe use an XOR test register, but what happens when there's an actual failure like a bad connection to the bus or bad power to the FPGA? Well, the CPU throws an exception and resets because the timeout for the PI_done expires. This all happens before your test has a change to even print anything to the console. I run into these kinds of issues all the time when designing software routines to self-test the hardware on our devices. Everything is all good when the hardware works, but as soon as hardware starts actually failing, all of those diagnostic tests are suddenly useless. I've gotten kind of off topic here, but the thought process is what I'm getting at. It usually goes a little something like this: Possible solution: Always have a backup OS image. Caveat: There's only one copy of the bootloader, so if that area of the flash gets screwed, we're done. Possible solution: Scrub the contents of RAM to check for errors. Caveat: The scrub routine is running from RAM. Possible solution: Use a watchdog timer to force a reset if the CPU runs away. Caveat: What if the watchdog timer latches up and the CPU hard locks? (Unlikely, I know). In the end, you can do a lot in SW to make a system more rubust, but the ultimate solution is probably on the mechanical side. You're better off spending your efforts modifying the enclosure and submerging the thing under water than you are spending hours designing in software techniques to try to recover from HW errors. TLDR: Most people agree that software techniques for mitigating risks in a rad environment are all about reducing probabilities, but I feel that such techniques have a good chance of being less effective in practice than people may think. I don't know what the point of this comment really was though, other than being negative. :)
- Normal_gaussian 11y agoSo the use case here is particularly interesting. Most of the answers are talking about spaceflight, because it is one of the only radioactive environments that has a particle distribution that can be effectively fought. Most earthbound environments have particle distributions that are practically unsolvable in software, and should instead be solved by using mechanical and noise tolerant analogue methods of sensing and manipulating and then massively shielding your computation (normally by controlling from a different building). *Note. By particle distribution I am refferring to both rate and charge
- phkahler 11y ago>> Most of the answers are talking about spaceflight... Another place to look is in safety critical systems. IEC 61508 in general and the automotive variant xxx26262. There are several dual core processors available now that run two copies of the code and check for any errors. That doesn't tell you which one failed, but it does catch the error. There are methods defined for creating fault tolerant systems too. We've been doing this shit for years - your electric steering system, brakes, even throttle control (with certain exceptions of course ;-) The funny thing in cars is that most of those systems have mechanical backups or consider "shut down" an undesirable but reasonable failure (vs steering left or dumping brake fluid). Your car can coast to the side of the road under driver control without any power. All this self driving stuff will require fully redundant components for some of these systems (including LIDAR or cameras) to really be safe.
- explanibrag 11y agoI once read that NASA control engineers have three independent teams code up three versions of their guidance systems. If the systems disagree, they go with the majority vote.
- justsid 11y agoEvery Airbus since the A320 uses the same system in their fly by wire design as well. Plus several fallback mechanisms where other computers can take over failed computers work or augument their work. For example the ELAC controls the ailerons and the SEC controls the spoilers, if the ELAC fails the SEC can take over and provide roll control via the spoilers, although limited (and those changes also come with a change of the planes flight envelope)
- kisna72 11y agoI goota say, this is the most fascinating thing I have seen all week.
- ash 11y agoThere was an interesting 2012 interview with John Muratore (SpaceX director of vehicle certification) about radiation tolerant design on SpaceX Dragon: http://aviationweek.com/blog/dragons-radiation-tolerant-design http://aviationweek.com/blog/dragons-radiation-tolerant-desi...
- iliis 11y agoAnother interesting case apart from spaceflight where radiation hardness is important: Particle accelerators. CERN for example has a lot of material, a quick search leads to e.g. https://lhcb-elec.web.cern.ch/lhcb-elec/html/rad_hard_links.html https://lhcb-elec.web.cern.ch/lhcb-elec/html/rad_hard_links.... or the Radiation to Electronics workgroup https://r2e.web.cern.ch/R2E/ https://r2e.web.cern.ch/R2E/
- kylehotchkiss 11y agoCoolest SO question I've seen in a while.
- dheera 11y agoFor ground-based applications, why can't this be solved by building a lead-shieled chassis? Like everything else in the software engineering world, abstract out the radioactivity problem and solve it separately. The other functional units shouldn't have to know or care about whether they are running in a radiactive or non-radioactive environment.
- leni536 11y agoThere might be weight considerations if this is a mobile device. Then this "abstraction" is certainly not costless (like many abstractions in the software engineering world).
- jotux 11y agoThere are actually processors designed specifically to prevent issues like this [1]. They use ECC flash, ECC RAM, and dual CPUs that run in lock-step. 1. http://www.ti.com/product/rm48l550 http://www.ti.com/product/rm48l550
- jacobsladder 11y agoDoing any modification to the source code to prevent this is not a good design. C/C++ is not designed for this use case, so it's going to create a mess if one will try to work around this. This might lead to similar problems that premature optimization does to the code. Instead the solution should be on hardware level, like in airplanes. Put three computers in radiation environment. Then put a forth computer that'd analyze the computing results from the three computers and do action only when there 3 out of 3 or 2 out of 3 computers agree on the result. Or average / median can be applied, depending on the task. Ideally the fourth computer needs to be put in non-radioactive environment. If not possible, that still simplifies the problem somewhat. Because only the final forth computer who collects the data and selects the trustworthiness can contain bugs, not the rest of the code.
- jacobsladder 11y agoTo clarify, each piece of the puzzle must do what it is expected to do, otherwise it will be hacky. It's not expected for C++ program to detect its underlying hardware problems, there are no tools, nothing for that. So any solution would then look like and feel like a hack, temporary workaround. It's however expected for the computer as a whole to produce buggy results, it's normal and there are many existing design solutions that can take that into account and work around that. So that's why you take three computers and judge their output. Then each piece of the puzzle does it what it is intended to do, it does what it is expected to do and it doesn't do stuff outside of its responsibility.
- jacobsladder 11y agoSorry it looks like a flooding, but to add to that, having program self-check itself is also unnecessarily ties the program to its usecase in the radiation environment, it creates unnecessary strong dependency to its execution environment, and that just goes against all the good principles of design. It's like having a software for clock in the microwave machine be aware that it is placed in the microwave machine.
- nitrogen 11y ago
- derekp7 11y agoI'm reminded of an old game called Core War, where the object is to write code that corrupts your opponent's code while simultaneously protecting your own code. I wonder if people who are good at that game would be the best candidates for this type of fault tolerant programming?
- dkopi 11y agoIsrael has had its own version called "codeguru extreme" that's been going on for the last 11 years. The rules are significantly different, but the idea and inspiration is from core wars. (Sorry, hebrew only: http://www.codeguru.co.il/xtreme/about.htm http://www.codeguru.co.il/xtreme/about.htm) It's sponsored by IBM, A large Israeli college, A technological high school chain - And Several Israeli Technological Military Units (Air force, Communications, Cyber). So yeah, that's probably a really good indicator you might be on to something.
- unexistance 11y agoa few more resources https://github.com/codeguru-il/corewars8086-survivors/tree/master/cgx2005 https://github.com/codeguru-il/corewars8086-survivors/tree/m... http://cyber.org.il/assembly/codeguru-guide.pdf http://cyber.org.il/assembly/codeguru-guide.pdf
- tgamblin 11y agoAnother place this use case comes up is supercomputing. Not because of the unusual levels of radioactivity, but because of unusual numbers of processors. When you have more components, a single bit flip somewhere is increasingly likely. Resilience has been a research area in HPC for a while now, and people have looked at fault tolerant algorithms, redundancy schemes, faster checkpointing, and other ways to make sure your HPC application running on a million cores won't die because one core gets a bit flip. So far this has luckily remained a research area in practice, because the vendors tend to do a good job of hardening their machines against errors as they get larger (most of the gloom and doom predictions take the error rates of current hardware and extrapolate). It will be interesting to see if it remains that way. Relevant article: http://superfri.org/superfri/article/view/14 http://superfri.org/superfri/article/view/14
- ams6110 11y agoSame reason RAID-5 doesn't work on for large disks. If you have a dozen 3TB drives in an array and one dies, the probability that you'll get a read error on another drive during the rebuild is quite high. Given enough bits, random errors that individually are almost impossible become almost a certainty.
- brokenmachine 11y agoWhat level of RAID would you use for an array involving a dozen 3Tb drives? If the drives can't be trusted, then you'd need some kind of error correction in software, I'd presume. I thought the drives should auto-correct any read errors. I'm not talking about in a radioactive environment, just normal usage.
- benjaminRRR 11y agoIEEE spectrum had a nice article very recently http://spectrum.ieee.org/computing/hardware/how-to-kill-a-supercomputer-dirty-power-cosmic-rays-and-bad-solder http://spectrum.ieee.org/computing/hardware/how-to-kill-a-su...
- beagle3 11y agoAs far as I can see, no one mentioned fluidic[0] computation so far. I am not aware of a fluidic processor that can run C++ compiled code, but .. if you want hardware that can withstand 1000 degree celsius, there's pretty much no alternative that I'm aware of. [0] https://en.wikipedia.org/wiki/Fluidics https://en.wikipedia.org/wiki/Fluidics
- swayvil 11y agoOff the top of my naive head. Have 3 or 5 or a dozen copies of the thing running in parallel. As many as it takes. Every action calls for a vote among the copies. Majority rules. Periodically validate the data. Again, majority determines what's valid.
- outworlder 11y agoMake sure that the code that does the "ballot" is not a single point of failure itself.
- swayvil 11y agooh good point. That makes it more interesting.
- exabrial 11y agoI remember learning in my embedded programming class about state machines and how certain states cannot be reached. In the lab, I accounted for every possible valid state with a transition out to another state. I left my microcontroller running when I went to get lunch, came back and it was frozen. I did a dump, and discovered it was idling in a state that has no entry into it, and because I had no exit, it would just sit there. I 'fixed' the problem by adding a transition to reset the controller from every state that shouldn't be reached.
- peterwwillis 11y agoThis is considered a minor security feature. When a program unexpectedly finds itself in a routine, or a routine ends abruptly, it's possible it was a code jump, or the after-effects of a payload... Neither of which are good things.
- TazeTSchnitzel 11y agoIf you use a switch(), have a default:, even if it's seemingly impossible.
- jakub_g 11y agoand print "call Brian" in it (anecdote from a HN thread a month ago): https://news.ycombinator.com/item?id=11397251 https://news.ycombinator.com/item?id=11397251
- StringyBob 11y agoYes - in hardware where faults are expected to be rare it's often a good idea to just detect that something went wrong. If you know something bad happened you can choose to re-run. (E.g. restart using a watchdog timer) Silently jumping back to a default state is sometimes useful, but could result in unpredictability or perhaps silent data corruption for some critical applications.
- boomlinde 11y agoAn entirely different approach could be to make it more likely to crash to minimize the harmful effects of executing corrupt code. I don't know how these corruptions manifest themselves, but if for example a single bit gets flipped every now and then somewhere (probably a naive assumption), a CPU that had a 0b11111111 nop instruction and 8 reset instructions at 0b01111111, 0b10111111, 0b11011111 etc., you could interleave your code with tons of nop instructions to minimize the possibility of executing corrupted code. You'd then be more likely to reset than to execute something that will lead to further corruption. As for data, I like the idea of storing/reading it redundantly in 3 or 5 places and assume that the majority of a read to all of them (bit by bit) is correct and rewrite the supposedly corrupt data. Again, not sure how well a solution like this actually applies to radiation corruption. You can of course use any existing techniques for data error correction, like Hamming coding (used in for example teletext to correct errors).
- PhasmaFelis 11y ago> I don't know how these corruptions manifest themselves, but if for example a single bit gets flipped every now and then somewhere (probably a naive assumption), a CPU that had a 0b11111111 nop instruction and 8 reset instructions at 0b01111111, 0b10111111, 0b11011111 etc., you could interleave your code with tons of nop instructions to minimize the possibility of executing corrupted code. You'd then be more likely to reset than to execute something that will lead to further corruption. I like this. It's functional, yet wildly impractical.
- kingosticks 11y agoThe idea of a single bit flip in an instruction fetch is very real. Imagine an instruction encoding where your intended load op becomes a store due to a single bit flip and your system hangs waiting for a response that never comes. Obviously you should have used ECC on your instruction ram but that can have a bug impact on your design so maybe you skipped it...
- awinter-py 11y agogenetic code has a lot of the same protective mechanisms (multiple copies of genes, for example), and is highly focused on radiation protection.
- SapphireSun 11y agoI wonder if there's a specialized debugger that injects random faults into your code while its running (e.g. flipping booleans or IO to peripherals). Not just fuzzing the inputs to the program, but fuzzing the contents of memory and registers as routines run. You could set the fuzz rate at different levels to detect different kinds of errors (e.g. maybe one error happens frequently but another requires a timer to tick up to a certain level before errors can affect it). EDIT: Thinking about this a bit more, for messing with registers, you probably need specialized hardware or you need to intercept the data on the way to the register.
- bjackman 11y agoYou could do this with an emulator I'm sure. At my company we have fairly high-fidelity models of the hardware we use/develop which could probably include on-chip peripherals in the things fuzzed. Also I guess in irradiated environments you use very simple hardware (no caches, MMUs, complex memory bus/controller) so that would make it more feasible. Would probably be really fun to develop! Edit: if you had the resources maybe you could even fuzz simulations of the RTL. Our systems take about a week to boot Linux on simulations but I guess that would drop dramatically for simpler MCU systems.
- SapphireSun 11y agoThat does sound like an incredible start. I fear that for the kinds of applications we're talking about speed could be an issue. For instance, if the system has to respond to events it can't control, queues of events can build up or things that are likely to be synchronized might not be etc. I feel like in many situations, you'd want to run at full speed for official tests though early testing could use an emulator. Of course, if you're emulating a much slower hardware as you mentioned, the test is more realistic. ;)
- bjackman 11y agoAh the timing thing is not actually an issue because you simulate or emulate the entire system, including timers and even the PLLs that drive them. There's a globally consistent timeline. Of course this places constraints on the things you can simulate (e.g. networking is out the window).
- scribu 11y agoOn a more trivial note, this reminds me of the radiation-hardened quine: https://github.com/mame/radiation-hardened-quine https://github.com/mame/radiation-hardened-quine Would be amazing if the method used for implementing it could be generalised somehow.
- i336_ 11y agoWhile not about radiation hardening or redundant hardware, this article shows how StarCraft's developers discovered and handled random hardware failure: http://www.codeofhonor.com/blog/whose-bug-is-this-anyway http://www.codeofhonor.com/blog/whose-bug-is-this-anyway The bug webpage mentioned in the article is dead, and clicking the link subtly redirects you. Here's the archived version: http://web.archive.org/web/20140824005145/http://www.guildwars.com/support/en-hardwarefailure.php http://web.archive.org/web/20140824005145/http://www.guildwa...