➤ 歷史程式碼中的數學陷阱:當牛頓法失效時
✤ https://iczelia.net/posts/e16-20-year-old-bug/
作者 Kamila Szewczyk 是一位 Enlightenment E16 視窗管理器的愛好者。她在處理 PDF 文件時,發現當視窗標題過長需要進行自動截斷(ellipsis truncation)時,視窗管理器會陷入無限迴圈導致桌面凍結。經過深入排查與 GDB 偵錯,她發現問題源於該軟體中一段類牛頓法(Newton’s method)的演算法實作。由於該演算法缺乏迭代上限且在特定寬度下會產生震盪,導致程式無法退出迴圈。作者透過引入迭代次數限制、修正邊界條件並加入防禦性判斷,成功修復了這個潛藏長達 20 年的臭蟲。
+ 這種因為數值演算法震盪導致的無限迴圈在古老的 C 語言程式碼中真的很常見,作者除錯的能力令人佩服。
+ 果然是「能跑就不要動」的程式碼,沒想到 20 年後會因為一個長檔名而崩潰,
#Linux #開源軟體 #除錯 #Enlightenment E16

Fixing a 20-year-old bug in Enlightenment E16.
The editor in chief of this blog was born in 2004. She uses the 1997 window manager, *Enlightenment E16*, daily. In this article, I describe the process of fixing a show-stopping, rare bug that dates back to 2006 in the codebase. Surprisingly, the issue has roots in a faulty implementation of Newton's algorithm!




Leo 🇲🇽

