TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Debugging file corruption on iOS

90 点作者 nspiegelberg将近 11 年前

6 条评论

SoftwareMaven将近 11 年前
This is the challenge of modern software development. When I first started my career, I spent two months looking for a random crashing bug in a video game due to misplaced free(); this was in code that was 100% ours. Now, there likely isn&#x27;t an application in existence that does anything interesting where 100% of the code was written for the app itself. As such, you are no longer debugging your own code, but other people&#x27;s as well.<p>Vernor Vinge coined the idea of a software archeologist, people who could sift through layers of code, all the way back to the beginning of time (Jan 1, 1970 and Unix, of course), to understand how systems work and to make modifications to them. We aren&#x27;t that far from that point; already, there are people who seem to specializing in digital spelunking to find and fix bugs in these underlying layers.<p>While I love building new code, some of the most satisfying moments in my career have been when I&#x27;ve gone back through somebody else&#x27;s code, untied it (oh, you built a polymorphic type system including class initializers and destructors in a decidedly not object oriented language? Cool.) and fixed it. There&#x27;s something interesting about getting into somebody else&#x27;s head and seeing how they approached the problem, then finding out where they were wrong.
评论 #8171038 未加载
评论 #8170014 未加载
评论 #8170136 未加载
pretz将近 11 年前
&gt; &quot;The SSL layer instead handled a raw file descriptor and, consequently, lifetime handling was not automatically synchronized ... We worked with the networking team and fixed this issue within hours.&quot;<p>Why on earth is Facebook writing their own SSL layer for iOS?
评论 #8170129 未加载
评论 #8169741 未加载
评论 #8171159 未加载
fdawg4l将近 11 年前
<p><pre><code> &gt; &#x2F;&#x2F; setup a honeypot file &gt; int trap_fd = open(…); &gt; &#x2F;&#x2F; Create new function to detect writes to the honeypot &gt; static WRITE_FUNC_T original_write = dlsym(RTLD_DEFAULT, &quot;write&quot;);; &gt; ssize_t corruption_write(int fd, const void *buf, size_t size) { &gt; FBFatal(fd != trap_fd, @&quot;Writing to the honeypot file&quot;); &gt; } &gt; return original_write(fd, buf, size); &gt; } &gt; &#x2F;&#x2F; Replace the system write with our “checked version” &gt; rebind_symbols((struct rebinding[1]){{(char *)&quot;write&quot;, (void *)corruption_write}}, 1); </code></pre> Does this code snippet look fishy to anyone else? First, the mismatch braces are messing with my head. I&#x27;m thinking the brace before the return is a typo. Also, the call to the macro looks wrong. Shouldn&#x27;t they be checking for fd == trap_fd?
评论 #8171259 未加载
评论 #8171253 未加载
shurane将近 11 年前
I would love to see a standalone testcase demonstrating this bug. Although, what was Facebook&#x27;s solution to fix it? Was it to make a fix to the SSL library to use a CFSocker wrapper?<p>| It turns out that abandoning manual code analysis was a good strategy.<p>Wait a minute, wasn&#x27;t this manual code analysis? They were certainly digging around the codebase and a particular slice of commits to figure out why the crash kept occurring.
评论 #8170113 未加载
Thaxll将近 11 年前
Move fast and break things.
评论 #8170866 未加载
carbonr将近 11 年前
i feel they are just over complicating.