Re: System Panic Makes My Life Easier
Ivan Sergio Borgonovo <[email protected]>
| Newsgroups | gmane.org.user-groups.linux.svlug |
|---|---|
| Organization | http://www.WebThatWorks.it |
| Message-ID | <[email protected]> |
On 08/06/2016 03:45 AM, Rick Moen wrote: > Right around the year 1999 or 2000, my wife Deirdre had a puzzling > problem with Linux on an AMD-based system of that day: The 'man' > command segfaulted, as did 'ls' if you used certain options to that > command, but not otherwise. This was practically a black swan event, > but someone on a Linux mailing list managed to identify the root cause: > The CPU's floating point circuitry was wonky, with the result that > /usr/bin/man's calculations that it uses for formatting broke, and the > command segfaulted. I don't know what the exact function in 'ls' was > that had the same problem, but it was something on that approximate > order of things. Uh that made me curious... It's pretty unlikely you need FPU instructions while doing text formatting in console. The only interesting candidates are sqrt() (pretty unlikely) and ceil after a division. There is a way to get ceil after a division with integer math but it's not hard to imagine someone simply decided to include math.h. Still I've greater respect for people that implemented man and ls, I bet they are far better coders than me. So I downloaded current man source code to get an idea and while they never used ceil(), math is included, and there is a huge use of floating point functions. MY EYES! BTW there are places where they work around using ceil(). Mainly they reimplemented vasprintf. No surprise this is problematic and resource consuming. In fact many embedded libraries let you decide if you want to include a printf that support %float or not. I've been trying to find where man needs to print fp numbers, but the only thing I could find was in the configuration code checking capabilities of printf. That's not going to trigger a segfault after the program has been compiled. man itself don't use floating point numbers, just call code that implement vasprintf that use floating point functions, but never triggering code that use fp numbers. So in current implementation it is hard to guess what was the problem. I downloaded ls code too, it doesn't seem to depend on float, still the easiest way to get it was apt-getting coreutils and it comes with a lot of other stuff to get a clue using grep. Do you have any other detail? Because this looks fun and weird. thanks -- Ivan Sergio Borgonovo http://www.webthatworks.it http://www.borgonovo.net