Sure, you've heard of falling through the cracks. But rising through the cracks? It's a less common feat, unless you're a refiner like Valero Energy  (NYSE:VLO). Valero and its smaller competitors Frontier Oil (NYSE:FTO) and Western Refining (NYSE:WNR) rise along with crack spreads, a funky name for refining margins. Valero's second quarter shows just how potent results can be when cracks go through the roof.

For the quarter, Valero ran slightly less crude oil through its refineries, because of above-average outages. Low industrywide capacity utilization fed supply uncertainties, helping to prop up throughput margins, which ran at more than $18 per barrel. That's 16% higher than last year's then-record quarter.

There's obviously some bad news afoot, if you look at the movement of the stock price in recent sessions. It shouldn't be news to anyone that crack spreads are volatile, but they've definitely fallen fast enough in recent weeks to give observers a bit of whiplash. The culprit? Refiners are getting their act together and producing more gasoline. Crude oil prices keep hitting new highs, while the price of gasoline steadily ebbs from its late-May peak. Cracks have thus contracted like the pupils of a victim in a slasher flick.

Just as Fording Canadian Coal (NYSE:FDG) and other metallurgical coal producers are getting clocked for bringing more coal to market, the refiners getting are reamed for improving the nation's gasoline supply. As a big fan of properly structured economic incentives, I find these screwy dynamics pretty frustrating.

Wackiness aside, Valero isn't headed for the poorhouse just because its cracks are narrowing. As management noted on the call, the firm's profitability is still historically excellent. Like ConocoPhillips (NYSE:COP), Valero's got a massive buyback under way, which may prove savvy if investors turn out to be fleeing this high-quality stock too readily. With the shares valued at around six times trailing income from continuing operations, I think the purchase will be looked upon favorably in hindsight.

Related Foolishness:

Fool contributor Toby Shute doesn't own shares in any company mentioned. The Motley Fool has a favorable disclosure policy.