Home
 

The Underpinnings

About Recent Entries

Error handling in C Jan. 26th, 2010 @ 07:03 pm
One of the things I really disliked in C is the lack of good error handling.

A few days ago I was working ona project and decided to do something about it:
#define chk_error(cond) if(cond) { goto err; }
#define err_handler err:

I don't even bother to use the last macro. Just make sure you put in a label in every function you use the chk_error macro and you're good. The compiler, will, of course, warn you if you forget.

I think the linux kernel likely has a similar macro?

This fails in some complex cases where it would be nice to have non-default error handlers. But that's easy enough to do, actually and I'll likely come up with a macro along the lines of chk_error(cond, handler) along with a set_err_handler(label) to handle those cases.

Sometimes I think the pre-processor is one of the most undervalued C features that many more "modern" languages fail to fully provide.

Example usage:
	    char * tmpname = calloc(1, strlen("/tmp/epoll_emu.XXXXXXX") + 2); /* Extra padding */
	    chk_error(tmpname == 0);
            ...
            chk_error(unlink(tmpname) == -1);

	err:
	    return -1;

One of those "you have to be here" kind of things. Jan. 14th, 2010 @ 07:27 pm
Our instructor complained our chapter summaries were too boring:


Systems Researcher in Function Land
Chapter 1

Lost in his own thoughts, the systems research continued plodding along. The researcher took a manpage out from his wallet, gazed on it and sighed.

It was his favorite side-effect. He hadn't seen any in weeks. Why had he come to functionalland? He tried to remember. His last trip here hadn't seemed to go all that well, why did he come back? Ah yes... a quest for purity. Or so he seemed to remember from the brochure.

In any case, this part of functionalland was different from what he remembered. Instead of camels running around O shaped racetracks, the camels here seemed to all be resting. Apparently the extensive amount of time in the sun had made them lazy and unwilling to move. There were also less French people, though the lazy camels seemed to be trying to emulate some of their behaviors.

"French people" thought the researcher with a fleeting smile.

His smile slowly faded into a frown as a deepening realization slowly dawned on him: there weren't even croissants here.

--------------------------------------------------------------------------

Systems Researcher in Function Land
Chapter 2

The researcher plodded on. Gathering his strength he ascended the hill in front of him and slowly made his way to the top. As he stepped to the top of the hill, a meadow came into view.

He'd never seen anything like it. It was... it was a battle. A massive number of statements, huddled around in the center of the meadow, shielding themselves against two armies of operational semantics that had descended down upon the unwitting statements.

The systems researcher reached for his trusted LALR parsers and rushed down the hill. He knew his parser wouldn't last the battle, but he couldn't bear to see such abuse. Bringing his parser to bear, he threw himself at the nearest group of semantics definitions.

Slowly, the definition turned around. It raised a magnifying glass towards the researcher, the researcher gripped his parser, ready to fight. The wind blew from the north, the researcher and the definition locked eyes and cycles passed.

The definition was made out of a series of intricately built legos. The researcher could see that each structure within the definition was carefully specified and placed to yield the overall shape. The definition's blocky appearance was comforting and gave a sense of depth.

The definition continued to stare, then it paused and the definition lowered it's eyes and muttered "you don't match me anyways." The it turned, running off. The systems researcher ran after it.

As they passed, the systems researcher noticed many other definitions made out of legos, yet the researcher also another type of definition. These definitions were wearing hemp, birkenstocks and all had little stickers that said "Made in Santa Cruz" on them. Their appearance was natural, but their behavior was anything but. These definitions didn't seem to have the same depth as the block lego sort. These seemed to only be concerned with outcomes, one got a cold feeling just looking at them.

Abruptly, the definition the researcher was chasing stopped near a nearby while statement. The definition turned it's eyes on the while statement and consumed it as the systems researcher screamed with rage and plunged his LALR parser into the definition's blocky back.

Far from being enraged by the assault, the definition simply turned around and in a lecturing tone, said: "you don't match me." The parser fell out of the definition uselessly and the systems researcher was left standing in the midst of the battle, mouth agape. He looked on when suddenly, out popped the while statement, slightly smaller. He glanced at the researcher puzzled when the definition yelped and out sprung an if-then-else statement and a little guy who looked like a state delta.

The while statement shrugged and ran back towards the blocky definition, which immediately consumed it again.

The researcher, seeing a lost battle when he found one, picked up his parser, shrugged and made his way out of the battle.

An odd place, functionalland.

Maybe the bleeding will stop after all... Jan. 6th, 2010 @ 07:30 pm
For those of you who don't watch the state of the state address or read articles about it, the Governor proposed that spending on prisons shouldn't be more than spending on higher education. He wants a constitutional amendment to that effect and wants the funding in the next budget to match this vision.

The New York Times wrote an article about it here: http://www.nytimes.com/2010/01/07/us/07calif.html containing this quote:
“Those protests on the U.C. campuses were the tipping point,” the governor’s chief of staff, Susan Kennedy, said in an interview after the speech. “Our university system is going to get the support it deserves.”


Huh.

A brief look back Dec. 13th, 2009 @ 05:28 pm
A year and some days ago I wrote that I was glad the Democratic caucus didn't achieve 60 seats in the Senate.

Given that they have now, and given the current struggles over the healthcare bill, I think this entry is more relevant today than when I wrote it: http://djcapelis.livejournal.com/113917.html

A recap for those who want just the hilights:
57-59 Seats: Good stuff for the Democratic caucus
60-61 Seats: Terrible stuff for the Democratic caucus
62+ Seats: Good stuff for the Democratic caucus
Tags:

Random Predictions Sep. 30th, 2009 @ 06:43 pm
I figured I might as well post three random claims and see how my future predicting skills work out:
  • DoubleTwist's announcement on October 6th will have something to do with Palm. (Fail)

  • Pixel Qi will be involved with the Apple tablet.

  • Within the next five years the NRC will have licensed or be substantially underway in licensing at least one new nuclear power plants in the United States. Nuclear power will begin to be viewed favorably by environmentalists as one of the few clean power options which can be made water neutral or water producing while not ruining vast amounts of pristine open space.


We'll see.
Other entries
» Disk layout
I'm taking the opportunity to switch from Gentoo to Exherbo on my machine machine. This means new everything, so new filesystems to plan, new disk layouts, etc.

I've been struggling to try and get the disk layouts right. An old unix optimization trick is to put filesystems which need higher speed I/O on the edge of the disk and filesystems which contain bulk data in the interior of the disk. Obviously swap goes on the outside, but the rest quickly become less clear.

I generally like to keep separate volumes for swap, /, /boot, /home, /usr, /tmp and /var. Swap is separate for obvious reasons, /boot is separate so I don't have to have it mounted unless I'm upgrading a kernel and so my filesystem choice on the rest of my partitions doesn't have to correlate with what grub supports this week. Most of the rest follow standard practice for unix partitioning, / is a small filesystem that's hard to corrupt, /home is separate because that's where everything goes. /tmp is separate to isolate user-writable areas on their own partitions and so it can be mounted nosuid, noexec. And finally /var is separate so overflowed logs can't cause full filesystems outside of /var.

The reality of the situation is even with quite large filesystems for /usr, /var and even /tmp, the /home filesystem just dwarfs them all in size. Since that means that /home takes up so much platter space the only real flexibility is to lay the other filesystems on the platter in a sensible manner and then just let /home have everything else. (Though leaving some extra space in case a logical volume needs to expand later.)

It turns out home takes up over 90% of the platter space. Given this, it really seems like platter layout is growing increasingly irrelevant. I think the only thing I really decided to do here was put everything not /home on the edge of the disk, since I can't really speed up /home much with these tricks. While /var might be a good candiate normally for a filesystem which wouldn't benefit from being on the edge of the disk, I can't really bring myself to put it in the interior when it wouldn't really help /home much anyways... so I might as well stick it at the edge. (And actually, since paludis puts its build directories there, this fast access does make package installation go faster as source decompression and compiling are often I/O bound.)

So the conclusion to all this? Platter layout just doesn't matter anymore. Unless I want to break up /home into separate places for different type of data. But there doesn't seem to really be a need for that, to say nothing of how absurd it would be to have a bunch of different logical volumes for /home for the sole purpose of doing platter layout hacks like this.

So I'm moving on from platter layout. Next up is figuring out which filesystems to use for each of these. Eventually I'll be ready to start compiling Exherbo.

I need to drop my habit of being this obsessive with my filesystems. Not only does it not really matter, but I'm going to have to redo this all when btrfs finally lands. (Yes, I know about the in-place upgrade but after this entry do you really think I'd be able to stand for doing an in-place upgrade to btrfs that leaves all the ext artifacts laying around? Further... I can't really do an in-place upgrade of the md/lvm storage spaces that I have setup to btrfs's volume management either. So I'll need another backup/wipe/redo cycle. Frustrating.)

Addendum: Okay, actually I read through this again and I realized there's is one take-away on things to know here. Put swap on the outside of the disk. That rule is still true.
» These are not the droids you're looking for.
Update: As Paul pointed out, this testcase doesn't display any abnormal behavior at all. Which is funny, because I wrote it earlier while arguing with a co-worker insisting C++ would do the right thing and it turns out it actually does, my testcase was just screwed!

Oh it's a funny language alright...

A case where malloc() and free() would correctly deallocate the appropriate amount of memory where new and delete do not:
djc@tea ~ $ cat dumbcpp.cpp 
#include<iostream.h>

struct A
{
    A()
    {
        cout << "Constructor A" << endl;
    }

    ~A()
    {
        cout << "Destructor A" << endl;
    }

    int a;
    int b;
};

struct B : public A
{
    B()
    {
        cout << "Constructor B" << endl;
    }

    ~B()
    {
        cout << "Destructor B" << endl;
    }

    int c;
    int d;
};

int main()
{
    cout << "Regular Allocations" << endl;
    A* a = new A;
    B* b = new B;
    cout << "\nRegular Deallocations" << endl;
    delete a;
    delete b;
    cout << "\nAllocate another B" << endl;
    b = new B;
    a = b;
    cout << "\nDelete it using an A*" << endl;
    delete a;
}
djc@tea ~ $ g++ dumbcpp.cpp 
In file included from /usr/include/c++/4.0.0/backward/iostream.h:31,
                 from dumbcpp.cpp:1:
/usr/include/c++/4.0.0/backward/backward_warning.h:32:2: warning: 
#warning This file includes at least one deprecated or antiquated 
header. Please consider using one of the 32 headers found in section 
17.4.1.2 of the C++ standard. Examples include substituting the 
<X> header for the <X.h> header for C++ includes, or 
<iostream> instead of the deprecated header <iostream.h>. 
To disable this warning use -Wno-deprecated.
djc@tea ~ $ ./a.out
Regular Allocations
Constructor A
Constructor A
Constructor B

Regular Deallocations
Destructor A
Destructor B
Destructor A

Allocate another B
Constructor A
Constructor B

Delete it using an A*
Destructor A

» This one's a fun one
Here's an excerpt from a bug I just filed against iTunes. It turns out I couldn't update my macbook and this was causing some amount of frustration. It seems the iTunes update stalled because it was trying to kill the annoying iTunesHelper.app task which I had long ago disabled because it's annoying little bugger. Unfortunately this makes the whole update process completely hang. Starting up iTunesHelper and running the update doesn't seem to do much better.

It's really frustrating to have software updates hang and never complete.

But fear not, for unix has an advanced signaling system you can use to request processes stop hanging. We call it... the kill command. Oh yes, it turns out all you needed to do to get the update to install was to carefully select the right processes to kill.

An excerpt from the recently filed bug #7112398 is below. This excerpt includes how I got the update to apply:

Title: iTunes update 8.2.1 hangs on install

Expected Results:
iTunes update doesn't hang and installs

Actual Results:
iTunes update never installs without me warming up the kill command

Notes:
Here's the sequence of tasks I killed that enabled the software to install:
root@tea ~ # ps -ef | grep -i update
0 30 1 0 0:48.16 ?? 0:48.18 /usr/sbin/update
501 43639 105 0 0:11.51 ?? 0:38.74 /System/Library/CoreServices/Software Update.app/Contents/MacOS/Software Update -psn_0_450670
0 67027 53119 0 0:00.01 ?? 0:00.01 /usr/bin/perl /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/preflight /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67039 67027 0 0:00.00 ?? 0:00.00 /bin/sh /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/preflight_actions/killiTunesHelper /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67040 67039 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c "/var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/InstallHelper" /Applications/iTunes.app/Contents/Resources/iTunesHelper.app
0 67042 251 0 0:00.00 ttys001 0:00.00 grep --color -i update
root@tea ~ # ps -ef | grep -i iTunes
0 66977 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
0 67014 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
501 67022 105 0 0:00.02 ?? 0:00.06 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Contents/MacOS/iTunesHelper -psn_0_458864
0 67027 53119 0 0:00.01 ?? 0:00.01 /usr/bin/perl /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/preflight /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67039 67027 0 0:00.00 ?? 0:00.00 /bin/sh /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/preflight_actions/killiTunesHelper /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67040 67039 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c "/var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/InstallHelper" /Applications/iTunes.app/Contents/Resources/iTunesHelper.app
0 67044 251 0 0:00.00 ttys001 0:00.00 grep --color -i iTunes
root@tea ~ # kill 67040
root@tea ~ # ps -ef | grep -i iTunes
0 66977 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
0 67014 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
501 67022 105 0 0:00.02 ?? 0:00.06 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Contents/MacOS/iTunesHelper -psn_0_458864
0 67050 53119 0 0:00.01 ?? 0:00.01 /bin/sh /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/preupgrade /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67052 67050 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
0 67054 251 0 0:00.00 ttys001 0:00.00 grep --color -i iTunes
root@tea ~ # kill 67014
root@tea ~ # kill 67052
root@tea ~ # ps -ef | grep -i iTunes
0 66977 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
501 67022 105 0 0:00.02 ?? 0:00.06 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Contents/MacOS/iTunesHelper -psn_0_458864
0 67055 53119 0 0:00.77 ?? 0:01.66 /System/Library/PrivateFrameworks/Install.framework/Resources/pkgExtractor /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Archive.pax.gz / /private/tmp/iTunesX.pkg.43639gOB5gn/iTunesX.installplan
0 67057 251 0 0:00.00 ttys001 0:00.00 grep --color -i iTunes

The update proceeded for a time at this point. It stalled again later and so I continued with my killing spree:
root@tea ~ # ps -ef | grep -i iTunes
0 66977 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
501 67022 105 0 0:00.03 ?? 0:00.06 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Contents/MacOS/iTunesHelper -psn_0_458864
0 67105 53119 0 0:00.01 ?? 0:00.01 /usr/bin/perl /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/postflight /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67107 67105 0 0:00.00 ?? 0:00.00 /bin/sh /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/postflight_actions/runiTunesHelper /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67108 67107 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/killall -SIGTERM iTunesHelper
0 67115 251 0 0:00.00 ttys001 0:00.00 grep --color -i iTunes
root@tea ~ # kill 67108
root@tea ~ # ps -ef | grep -i iTunes
0 66977 1 0 0:00.00 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/defaults write com.apple.iTunesHelper FreshInstall 1 2
501 67022 105 0 0:00.03 ?? 0:00.06 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Contents/MacOS/iTunesHelper -psn_0_458864
0 67105 53119 0 0:00.01 ?? 0:00.01 /usr/bin/perl /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/postflight /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67107 67105 0 0:00.00 ?? 0:00.00 /bin/sh /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg/Contents/Resources/postflight_actions/runiTunesHelper /var/folders/N3/N3CfDzLyGvi8Mpyo7DczHE+++TI/Cleanup At Startup/com.apple.SoftwareUpdate.LTOKLp/iTunes/Packages/iTunesX.pkg / / /
0 67116 67107 0 0:00.01 ?? 0:00.01 /usr/bin/su djc -c /usr/bin/open //Applications/iTunes.app/Contents/Resources/iTunesHelper.app
0 67118 251 0 0:00.00 ttys001 0:00.00 grep --color -i iTunes
root@tea ~ # kill 67116

At this point the update succeeded. iTunes successfully reports being version 8.2.1




In case you're wondering:

djc@tea ~ $ defaults read com.apple.iTunesHelper FreshInstall
1
djc@tea ~ $ defaults write com.apple.iTunesHelper FreshInstall 1 2
2009-08-03 00:05:51.789 defaults[67306:10b] Unexpected argument 2; leaving defaults unchanged.


Probably should add that to the bug report...

Anyways... OS X's brittle behavior when you change things continues to cause me trouble.

(Oh, and really can someone fix #6953336 which points out a typo in a manpage? It's a really quick fix... frustrating I can't do it myself.)
» Just another example of why traditional news publications are dying for good reason
I would be sad about the whole newspapers dying thing if they actually bothered to do any good reporting anymore. Calitics does more and better reporting on insider California political baseball than almost anything. (And yes, they are more biased, but I'd rather wade through a biased source with good information than an unbiased source with no information.) Tech reporting is just downright terrible outside the Internet. For other topics, various other online new sources provide excellent information on other topics. Fivethirtyeight and electoral-vote cover politics better than almost any newspaper I can think of, and even sports reporting these days often is better just pulling information and videos straight from the sites of the major sporting associations.

Here's an example of terrible tech reporting. Christopher Werth from Newsweek is the reporter you can thank for this incoherent, fearmongering and completely unprofessional article. You can read the full article here, but here's a few highlights:
  1. "A few weeks ago malware known as Zero Day was found to have exploited a vulnerability in Microsoft's Windows operating system"
  2. "allow online criminals to take control of a computer from anywhere in the world without being detected"
  3. "Serious threats like Zero Day"
  4. "Windows runs on nearly 95 percent of the world's computers, which is why it bears the brunt of online assaults"
  5. "The company is also scrambling to develop an update that guards against Zero Day"

Don't give me the "hard deadlines in a newsroom" excuse. If you don't understand it, don't write about it. If your publishing structure doesn't allow you to produce good content, why should anyone care if you go out of business?

For those of you without the technical expertise to see that the writer doesn't know what he's talking about, let's take it point by point: (Numbered response here directly maps to the numbered quotations above.)
  1. Zero day is not a specific piece of malware but is a generic classification people use to refer to any malware that exploits an unpatched vulnerability or was recently released. It is most certainly not a proper noun.
  2. Anything that allows online criminals to take control of a computer from anywhere in the world also allows them to do so undetected. The two issues are completely orthogonal and this bug is not much better or worse in the detection respect than any other similar vulnerability or mechanism for full control.
  3. All vulnerabilities are zero day vulnerabilities at some point. Every last one. As for this specific vulnerability, it is one of the less serious types vulnerabilities as it requires user interaction and a compromised website to trigger. The serious vulnerabilities are ones that do not require the user to do anything but be connected to the Internet.
  4. Windows may run on a vast majority of computers, but server operating systems often receive a large portion of attacks highly disproportional to their market share because people are much more interested in compromising servers than clients.
  5. No, they're scrambling to provide an update to bug they've known about for many months now. They are doing nothing to prevent zero day attacks.

You'd think the reporter could get the basic terminology right before he tried to synthesize opinions of experts into a meaningless and useless article that does little to provide the public with any additional knowledge or insight but instead just offers unsubstantiated fear and no new solutions.

Christopher Werth needs to stay away from the tech beat. Producing articles like this one make the public less informed of the issues involved and offer no insight. Articles this bad ought to be a bigger violation of a news publication's journalistic ethics than most things they criticize blogs about. (And by no means do I not desire more journalistic ethics in blogs... it's just that newspapers need to get off their high horse.)

I guess expecting reporters to write coherent articles that enlighten and inform is just too high a standard.

webeditors@newsweek.com have received a link to this entry with a letter encouraging them retract their story or publish corrections. If they reply, I will update this entry and let you know.

Update: Newsweek has corrected the story. I don't know when since they didn't reply, but the version they're running now is significantly more coherent, if not exactly enlightening or informative.
» XFig
I posted on twitter that I was curious if anyone knew of something other than Xfig for figure drawing. The best answer so far has been "check out Dia" but I think the following screenshot best encapsulates why some people still use Xfig:


It's not that this export list is entirely amazing and can't be implemented technically in other programs. It's that the fact that these are the formats that come up when you export a diagram shows how people use this software and its main purpose. And that philosophy is what I haven't been able to find in another piece of software.

Until that changes, I'll stick with Xfig and its terrible looking widgets.
» NYC and Washington DC
The whole story of my first trip to NYC hasn't yet been told on this blog. Neither has my trip to Washington DC on the 4th of July. A full telling of this story involves three branches of the American government, a gay pride parade, several interactions with police officers, several shots of whiskey, a Chinese celebration of American independence and Ethiopian food. Unfortunately a full accounting of these events has not yet been prepared...

However, thanks to the easy Flickr integration Gwenview provides as part of the standard KDE desktop, you can see photos from these two journeys, today. It's a good feature. Not that I'd dedicate a keynote to it or anything, but hey. I suppose everyone has their own way of announcing additional features to make users' lives easier. Some people just put it in your software so it's already there when you need it, others make you wait for ages and then pretend it's revolutionary when they finally ship it as an upgrade to a product you already bought.

Okay, enough bashing iPhoto. Generally these days I like Apple and think they do innovative work, but that keynote was ridiculous and that feature wasn't innovative, but blatantly missing. (The face recognition was awesome though. I suppose it's too bad it doesn't work.)

For those of you who survived the technical rant embedded in what was supposed to be a travel piece, your reward—is photos:

Trip to New York City (28 June 2008)
Trip to Washington DC (4 July 2009)
» So I moved to Princeton
Most of you know that I recently moved to Princeton, New Jersey for the summer. As a native Californian who generally expects all other states to be completely inferior in every way, (not really) I didn't relish the thought of moving, to of all places, New Jersey. Yet my lack of relish was misplaced. While Princeton isn't exactly the most happening place in the world, it certainly looks like it will be a nice place to spend the summer. Instead of desperate urban hellscape that New Jersey's reputation would lead you to believe, Princeton is instead a nice quiet little town that really if anything, is too nice.

For those of you who don't believe, here's some photos of Princeton, you can see for yourselves: http://www.flickr.com/photos/39879310@N02/3667480710/in/set-72157620661940642/

As for why I'm here, I'm working at Fraser Research, which is a small little research firm redesigning the Internet. It's a project that has been going on for quite a few years now and is slowly getting nearer to completion. The design is interesting and may or may not ever see the light of day, but either way ends up being an nifty project to work on. Some pieces of the design are influenced by some of the work that was done at Bell Labs, as that's Sandy's old stomping grounds. Various pieces take into consideration things that usually are never thought about, so those parts end up being fairly fascinating. Overall, I think it should be a fun summer.

On another topic, due to an amusing set of circumstances other than myself, every last person currently at Fraser is British or an ex-Brit. The other three students are from Cambridge and Sandy and his wife both crossed the pond quite a bit back. It's a bit of an odd experience: I traveled to New Jersey and ended up surrounded by British people, which seems amusing enough to note. The bottom line seems to have been that my active vocabulary has shifted to use words like "bugger" much more often than I really expected.

For those of you who don't really care to go through the full stream of pictures I linked to above, here's a few links into the middle of the stream where you can see something more specific:
Pictures of the office: http://www.flickr.com/photos/39879310@N02/3666676329/in/set-72157620661940642/
Pictures of the house: http://www.flickr.com/photos/39879310@N02/3666674929/in/set-72157620661940642/

Oh, also: Tomorrow I visit Manhattan. Perhaps more pictures then.
» Reviewing Scientific Papers
I don't have any sort of claim to vast experience with reviewing papers or even a claim to producing useful scientific papers. Yet, I do have a claim to needing to take a break from a paper I'm reviewing to let my thoughts simmer down into something coherent. In the meantime, I thought I'd jot down a few thoughts on paper reviews. These thoughts aren't unique and it's unclear there's much of a contribution in stating them here, but perhaps a recasting of ideas in different words might inspire thought. (Or not, I keep re-reading this and it seems more rambling and disorganized than thought provoking. One day I'll learn to do drafts of things I write before hitting that submit button.)

Reviewing a scientific paper can be incredibly multifaceted. You can take a paper that demonstrates an amazing piece of technology that provides substantial improvements that the authors have data to back up and end up deciding it doesn't make a very good paper. The reasons why this is so can sometimes be hard to express. Especially to the poor disappointed authors who eventually receive your review and read it carefully for clues on how to vanquish whatever it was that turned you off from the research they've put so much time into.

Sometimes a paper's problem is that while one can take a piece of technology and construct an amazing system that works well in a lab, it can be highly unlikely that system will work well in real life. The thing is, you never know whether this is the problem. No one really has any clue what types of systems nicely transition from a lab to real-life. We all have ideas on which types of things will make the transition, but determining whether or not this is going to be a problem with a particular paper is not easy. Real life and reality have been frequently known to adopt sub-optimal solutions just as easily as they've been known to adopt triumphs of the research community. Completely accurate determinations as to which systems will succeed involve market forces, timing and a bunch of other factors not easily grasped, predicting the likelihood research turns to reality requires a type of foresight we haven't isolated. Since this problem is impossible, publication venues for papers generally base review criteria on the contribution a paper provides.

Generally, this means that in addition to creating a good system, one must bring something new to the table. The standard thought is that a paper that doesn't make some sort of contribution is just about unlikely to turn into reality as the work done before it. So even if the authors end up building a good system, if a very similar system has already been built, or the authors only solve a few simple issues along the way, we generally assume that solving those issues was not the limiting factor preventing that type of technology from finding it's way out into the world and making everyone's lives better. So when you read paper reviews or you end up reviewing papers, you hear a lot of discussion about what the contribution of each paper might be. The magnitude of the contribution, that is—the actual advancement in the paper—is the defining factor that usually determines a paper's ability to get published.

While this might seem to make sense, let me re-emphasize: The value of the paper is in it's contribution. No one cares what amazing things the system does if it doesn't also bring a contribution to the table. There are many papers which have laid out what should be really nice solutions to really pressing problems that never go anywhere because of niggling reasons reality cares about and academia doesn't. Unless a paper can show that they've overcome a specific problem with their system any future papers that build equivalent amazing systems aren't useful contributions to the field and will face rejection.

To make this all just a little more complex is the problem that no one really has a clear idea on what merits a good contribution. The type of contribution a paper might bring to the table is entirely ill-defined and often only begins to make sense through lots of practice. A contribution can sometimes simply be combining things together in a different way that uses some undefinable yet recognizable spark of innovation and/or insight to transform a series of most theoretical papers into a robust and deployable system. Another type of contribution is providing a fundamental building blocks that don't really yield any immediate benefit but will eventually (hopefully) be used by later systems to change the world. There are many other types of contributions. While all the types of contributions are important, everyone has slightly different ideas on how to reconcile the wide variety of contributions into a coherent scheme which dictates what papers are truly important and which are not.

It can be frustrating to end up giving poor marks to systems you think are good while giving good marks to systems you think are bad. But it's about the contribution, not about the system.

The end conclusion? Paper reviews are hit and miss. A lot of papers are easy to review and most people who read them agree on the outcome. Others however, are much less clear. Often I think, the more interesting papers tend to fall into the latter category.
» Dealing with security questions
These days everyone asks you for a question and answer combination to recover a password online. These often stump me... it's fairly easy to find out where I went to elementary school or what my mother's maiden name is. Everytime I have to make a new one of these I'm constantly put into a bind.

The trickiest part of coming up with a good security question and answer pair is trying to meet two criteria that have an annoying tendency to conflict:
  1. The answer to the question need to be something you'll remember or could easily find out.
  2. The answer can't be something anyone else would know or could easily find out.

It turns out, there is something that matches this criteria quite well. That's relationships and—more particularly for those who have one to take advantage of—a sexual history.

Now this isn't for everyone, obviously some people's sexual history is rather well documented on Web 2.0 and/or rather well known by their friends, but even in some of these cases it can at least cause quite a bit of work for an attacker and can be used for low-security low-risk type of Q&A pairs. Your friends often can mess with you in other ways, logging onto your accounts usually isn't one of the ones they care to bother with. But hey, maybe your friends like messing with you. Whatever, it's up to you.

There's obviously one more concern I didn't quite document either that's brought up rather quickly when you get into relatioinships and sex. The question shouldn't be that embarrassing. Sometimes you end up talking about these over the phone to some poor customer service representative and something like "Who did I first go down on under the bleachers of my old high school that one time?" is probably not a question or an answer you really want to share with them. That's just too much information. (By the way, for those wondering: This is not an example of a valid question that matches my history.)

So what types of questions are appropriate?

Well, did you ever have a short lived relationship? Simply asking the question:
"Who came before Xander?" or "Who came after Yolanda?" where either Xander, Yoland or the person who matches the answer to those questions could be the person you were in that short lived relationship with awhile back that your friends probably (and maybe hopefully?) forgot about by now.

Or even: "Complete the series: Xander, Yolanda, ???, Zeta." For those with more, uhm, elaborate histories the series could even be people you only did a certain types of acts with if you don't want it to be a simple chronological listing of relationships or partners.

Things like "Who was my first kiss?" tend to come up in those stupid Internet quizzes a lot, so avoid those. Things like firsts are often interesting information and people not yourself are likely to remember them. The person you kissed is likely to remember whether or not they were your first, they may not remember whether they were your fourth or fifth... so questions like "Who was the third person I kissed?" is much more likely to be something you'll still be able to answer but other people will find much more difficult.

Now these still leave some room for social engineering, but doesn't everything?

So go meet someone new tonight, it's a security issue.

(In related news... security implications of blogging about how you chose your security questions online? Probably not the best thing to do, leave it to the professionals.)
» SCADA Systems
I recently sent a message out to the security research list at UCSD because we've been discussing SCADA systems lately. I thought I'd go ahead and post a variant of the message to my blog.

Before I jump into the body of the message I should probably mention that SCADA is a loose classification of a bunch of different types of systems that deal with industrial controls on private utility networks (among others). When people talk about hackers infiltrating the power grid and scream about the national security implications of something like that, these are the systems they are referring to.

So we've been talking about them. A lot of the security problems around these systems aren't that interesting, but the systems are important so what interesting problems there are with these systems are quite interesting. Here's part of what I wrote:

I recently found some SCADA boxes and got my adventuring companion to take a few pictures of them with her iphone. (Didn't have a camera on me.) I thought a few of you might be interested in the security you might find at these outlying sites.

The particular site we ended up seeing was the Black Mountain site which mostly contains cell antennas. It's easily accessible—you just climb the mountain—but it's remote enough where it's not closely monitored. Certainly if you snuck up there at night you could probably do anything you wanted. I didn't see any cameras either. The site looks like this:


The SCADA systems are nicely labeled:



And are protected with only the finest and most cutting edge security solutions available for under $20 at your local home depot:

(For those of you who don't like picking locks, a pair of metal cutters would do the trick equally well.)

The SCADA boxes aren't even located within any of the locked cages, but to get inside those isn't hard either. This was the typical lock configuration. Talk about the weakest link:


I was perplexed for some time on why they set things up this way and finally realized that they've got a bunch of different organizations using these sites and no common key distribution, so each organization just puts their own lock on the chain and that way each org's field maintenance people can get in without having to coordinate with the others.

I found it slightly amusing that I could throw a lock on there between the two links before their sets of locks and mess up their entire system. One wonders how long it would take before each organization to have their access restored to the site as they'd have to cut the chain and then redeploy each org's locks on there. It doesn't seem like they talk to each other all that well. Of course they could try cutting the lock, but I'm sure you could put a lock on there that would make them opt to cut the chain instead.

You'd think there'd be enough crazy "oh no cell phone towers are killing our children and making my back ache" people out there that you'd get a few who'd want to lock repair people out of these facilities, but I guess this type of attack just isn't that common...

Anyway. I didn't try hooking into any of the SCADA systems. (I didn't have a laptop with me either, this was a spur of the moment hey what's that on that mountain there, let's go climb it and see type of thing. Usually I'd have a small amount of equipment hanging around in my car, but she drove so I didn't have access to that.) So, I can't say for sure how easy it would be to enter their network here, but if you were looking for a place, this is one of many.

We probably have a few on campus too in the facilities complex if anyone wants to take a look.

» Interesting thing to note
Nuclear reactors could also be used as desalinization plants.
» Using cmake
So today I decided to use cmake for one of my projects. I'm not entirely convinced it's going to save the world yet, but I'm convinced that I should give it a try. qmake is one of my favorite build systems and this seemed like the closest thing that didn't actually require installing qmake. (Which on most distributions still isn't packaged separately from Qt and while I like Qt, requiring it to generate makefiles is a bad plan and a good way to annoy anyone who doesn't already have Qt installed.)

So I dove into cmake. It's reasonably similar to qmake, if a bit more ugly. I usually start out most qmake projects with the "qmake -project" command which stares at the files you have and generates a little basic project file. Then you modify this to make it do what you actually want. cmake doesn't have such a thing by default, so my advice is to do this:

$ wget http://websvn.kde.org/*checkout*/trunk/KDE/kdesdk/cmake/scripts/gencmake
$ chmod +x gencmake
$ mv gencmake ~/bin
$ cd ~/projects/projectname
$ gencmake


gencmake has now taken its place as yet another vital script in my ~/bin directory. I hope some of you find it as useful as I did.
» So an alternative to blogging
So I haven't been blogging much, but for sharing small inane things I've been using tumblr a bit:
http://djcapelis.tumblr.com/

Not that I've been using that much either, but for those of you who use RSS readers and want more things to aggregate, here's a low-traffic median on which I occasionally link to random things I encounter on this Internet thing.
» Shooting yourself in the foot: a case study
This is me complaining about this particular item of news:
http://tech.slashdot.org/article.pl?sid=09/02/09/1348255

This is dangerous. First off, it's ineffective because someone will just create a program that manually loads other programs into its own address space and does co-operative multiplexing between them. While this type of program would actually be fairly easy to create, it causes large changes: This is just going to result in desperate users pushing the identity of a process outside of the control of the operating system into an annoying userspace app. Users will gladly cast aside memory protection and pre-emeption to do this type of thing... it doesn't immediately effect them.

There's two ways this can play out:
1) Microsoft places a limit on fork() (I can't remember the Win32 equiv, but it's there) and forces three applications to actually mean just three processes.
2) Microsoft doesn't place a limit on fork() and everything I said above is null because the one app actually will be able to give memory protection, process identification and pre-emeption abilities back to the OS. Then it turns out Microsoft's restrictions are completely useless and can be nullified by one little small program that re-implements the OS loading code. If it goes ahead and does the right thing to hook the syscalls on the system it'll even be able to do this transparently and getting around these restrictions will be as simple as double clicking on the installer.

It's times like this I almost wish I did a little windows development just so I could write this application and show them how ridiculous restrictions like this are.

In short, the choice Microsoft says they'll be making for monetary and marketing concerns either ends up doing nothing at all except providing an annoyance or provides their end-users with a more dangerous operating system environment that neuters their own OS while still not effectively providing a limit on the number of concurrent codebases running on the computer.

Your turn.
» Hmmm... does anyone know what this means?
Anyone know what this means?

[  118.830022] ------------[ cut here ]------------
[  118.830026] WARNING: at drivers/gpu/drm/i915/i915_gem.c:2470 i915_gem_idle+0x179/0x341()
[  118.830028] Modules linked in:
[  118.830032] Pid: 5377, comm: X Not tainted 2.6.28.2-DJC-AES #5
[  118.830034] Call Trace:
[  118.830041]  [] warn_on_slowpath+0x51/0x6d
[  118.830046]  [] lapic_resume+0x171/0x1fc
[  118.830051]  [] _spin_lock_irqsave+0x23/0x2a
[  118.830056]  [] lock_timer_base+0x26/0x4b
[  118.830060]  [] try_to_del_timer_sync+0x46/0x4f
[  118.830064]  [] i915_gem_retire_requests+0xf2/0x114
[  118.830068]  [] i915_gem_idle+0x179/0x341
[  118.830071]  [] i915_gem_leavevt_ioctl+0x0/0x35
[  118.830075]  [] i915_gem_leavevt_ioctl+0x14/0x35
[  118.830079]  [] i915_gem_leavevt_ioctl+0x0/0x35
[  118.830083]  [] drm_ioctl+0x1d2/0x260
[  118.830087]  [] vfs_ioctl+0x55/0x6b
[  118.830090]  [] do_vfs_ioctl+0x373/0x3ae
[  118.830095]  [] vfs_write+0xcd/0x102
[  118.830098]  [] sys_ioctl+0x51/0x70
[  118.830102]  [] system_call_fastpath+0x16/0x1b
[  118.830105] ---[ end trace 3a06ac7332c964b0 ]---
[  118.873541] mtrr: no MTRR for 80000000,10000000 found


xf86-video-intel version 2.6.1, libdrm version 2.4.4, kernel 2.6.28.2, Xorg 1.5.3-r1 (gentoo's patchset) configured for UXA.

Configuration:
aes ~ # gunzip -c /proc/config.gz | grep -i drm
CONFIG_DRM=y
# CONFIG_DRM_TDFX is not set
# CONFIG_DRM_R128 is not set
# CONFIG_DRM_RADEON is not set
CONFIG_DRM_I810=m
# CONFIG_DRM_I830 is not set
CONFIG_DRM_I915=y
# CONFIG_DRM_MGA is not set
# CONFIG_DRM_SIS is not set
# CONFIG_DRM_VIA is not set
# CONFIG_DRM_SAVAGE is not set

aes ~ # gunzip -c /proc/config.gz | grep -i mtrr
CONFIG_MTRR=y
CONFIG_MTRR_SANITIZER=y
CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1
CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1

aes ~ # xrandr -q
Screen 0: minimum 320 x 200, current 2624 x 900, maximum 2624 x 900
VGA connected 1024x768+1600+132 (normal left inverted right x axis y axis) 304mm x 228mm
   1024x768       60.0*+   75.1     75.0     70.1     60.0*
   832x624        74.6
   800x600        72.2     75.0     75.0     60.3     56.2
   640x480        75.0     72.8     72.8     75.0     75.0     66.7     60.0     59.9
   720x400        70.1
TMDS-1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 443mm x 249mm
   1600x900       60.0*+   60.0
   1360x765       60.0
   1280x800       60.0
   1152x864       75.0     75.0
   1280x720       60.0
   1024x768       75.1     75.0     70.1     60.0
   832x624        74.6
   800x600        72.2     75.0     60.3     56.2
   640x480        75.0     72.8     72.8     75.0     66.7     60.0     59.9
   720x400        70.1

aes ~ # glxinfo | grep -v GL | grep -v extensions
name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.2
client glx vendor string: SGI
client glx version string: 1.4

   visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
 id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------
0x21 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x22 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x69 32 tc  0 32  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None


This seems like maybe a configuration issue and not an actual bug... but where do I even look for information about something like this?

Of course, X works... just not terribly well and the last part is definitely a problem. (The part showing no acceleration enabled whatsoever as reported by glxinfo... glxgears gets to about 60FPS when I get lucky and otherwise goes to hell.)

Random gripe only vaguely correlated: The manpage for genkernel does not match the actual tool. The person who changed the tool without updating the manpage for it should be summarily whipped. Bad bad bad to change the command line options on a tool for no apparent reason and then not even update the documentation or leave behind stubs that say "X is deprecated, it's now Y" when the old switches easily map to new ones. Who the hell taught this team how to make a tool? I swear to god as soon as dracut gets just a bit more ready I'm switching to that to make my initrds instead of using genkernel. (Making initrds is the only thing I use genkernel for at the moment now anyways.)

Advertisement

Top of Page Powered by LiveJournal.com