Winter 92 - KON & BAL'S PUZZLE PAGE

## KONSTANTIN OTHMER AND BRUCE LEAK

See if you can solve this programming puzzle, presented in the form of a dialog between Konstantin Othmer (KON) and Bruce Leak (BAL). The dialog gives clues to help you. Keep guessing until you're done; your score is the number to the left of the clue that gave you the correct answer. These problems are supposed to be tough. If you don't get a high score, at least you'll learn interesting Macintosh trivia.

KON I wrote this program that crashes with a bus error and I can't figure out what's going wrong.

BAL If it's crashing with a bus error, that's easy: just figure out where the bogus bus error address came from.

110 KON Well, that's the problem. I look around and there's not a bad address anywhere.

BAL Let me see.

105 KON OK.

```Bus Error at 1B586
1B582	BFEXTU (A3){D6; \$00}, D0
1B588	MOVE.L(A2)+,D1```

Register A3 has \$70E368, and A2 has \$70DEDC. So that's your puzzle; what do you do now?

BAL Hmmm. Suppose I trace a few times.

100 KON No problem; everything seems to work OK.

BAL What if I type "Go" and hope for the best?

95 KON You crash immediately with an address error at \$1B5A4. The code is trying to do an RTS, but the stack is trashed.

BAL Well that's just a little ways down from where I was before. Anything funny happening in between?

90 KON Nope, just a loop that doesn't touch the stack or anything.

BAL Was the stack OK when I crashed the first time?

85 KON No, the top address on the stack was garbage.

BAL OK, so I run the program again and break just before this routine gets called and check the stack.

80 KON The stack is OK. Everything looks fine. You're at a JSR (A0).

BAL Is A0 OK?

75 KON Yep, it points to the code you were looking at before--at \$1B582.

BAL So I step in and look at the stack.

70 KON You crash immediately with a bus error at \$82.

BAL Huh? Sounds like someone jumped to \$0.

65 KON A0 looked OK. It was just doing a JSR (A0).

BAL Some weird MacsBug bug?

60 KON In this case, no.

BAL All I did was step into a subroutine and I crash somewhere totally different?

55 KON Pretty cool, huh?

BAL Are the registers OK? What does the stack look like?

50

KON Garbage everywhere. The stack has all kinds of noise on it, and the registers seem pretty fragged.

BAL Hmmm. I try it again; this time I set a breakpoint a few instructions before the JSR (A0).

KON OK.

BAL Is everything OK?

45 KON The registers, stack, and code look OK.

BAL So I trace a few instructions, up to the JSR.

40 KON You crash immediately after the first trace with a bus error at \$0104B0CA.

BAL Well that address is garbage. Was it in any register or on the stack before I traced?

35 KON Nope.

BAL What happened to the stack?

30 KON There's 56 extra bytes on it now.

BAL What? Is my machine possessed?

KON It's just a computer.

BAL Some interrupt nastiness happening?

25 KON When you crash, you're at interrupt level 1.

BAL Now we're getting somewhere. Does MacsBug enable interrupts when I trace?

20 KON Yes.

BAL So where's the level 1 interrupt vector kept?

15 KON \$64.

BAL I DM it and see if it's OK.

10 KON It's \$104B07C. Pretty close to where you crashed.

BAL So it sounds like someone is trashing the interrupt vectors, and all the interrupts are held pending when I'm in MacsBug. As soon as I do anything that returns control to the Macintosh, I blow up. So I step spy on \$64 and see who trashes it.

0 KON It's a routine that assumed a buffer was being allocated but wasn't. So the buffer pointer was NIL, and the routine wrote all over low memory, including the exception vectors.

BAL Nasty.

KON Yeah. So how could you catch this before the vectors get trashed?

BAL Doesn't EvenBetterBusError catch writes to NIL?

KON Only at VBL time, and the chances of a VBL interrupt happening before the VBL vector gets trashed are mighty slim.

BAL You could initialize pointer variables to a bus error number like \$50FFC001 instead of NIL. If you did that, you'd crash at the write and know immediately what was wrong.

KON Cool.

KONSTANTIN OTHMER AND BRUCE LEAK As a mere lad, Bruce pulled the programmer's key out of the stone and swore allegiance to the Lady of the Leak. Years later, while good King Bruce was doing penance for his wandering ways, young KON of Locksley had to defend the crown against the Mongol hordes attempting to draw directly to the screen. Upon his return, King Bruce declared, "Let there be time," and there was. Today young KON and his sovereign do battle against the forces of evil lurking in your local heap.*

SCORING

• 100-110 Be honest.
• 75-95 Next time we find a bug, we're  calling you .
• 50-70 So this has happened to you!
• 25-45 No doubt about it, these puzzles are tough.
• 0-20 Well, maybe next time . . . *

Thanks to Scott Douglass for reviewing this column.*

Community Search:
MacTech Search:

Chromium 75.0.3770.142 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. Version 75.0.3770.142: Release notes were... Read more
Viber 11.1.0 - Send messages and make fr...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device, so... Read more
Wireshark 3.0.3 - Network protocol analy...
Wireshark is one of the world's foremost network protocol analyzers, and is the standard in many parts of the industry. It is the continuation of a project that started in 1998. Hundreds of... Read more
DEVONthink Pro 3.0beta4 - Knowledge base...
DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research papers, your life often fills your hard drive in the... Read more
Adobe Creative Cloud 4.9.0.512 - Access...
Adobe Creative Cloud costs \$20.99/month for a single app, or \$52.99/month for the entire suite. Introducing Adobe Creative Cloud desktop applications, including Adobe Photoshop CC and Illustrator CC... Read more
SketchUp 19.1.174 - Create 3D design con...
SketchUp is an easy-to-learn 3D modeling program that enables you to explore the world in 3D. With just a few simple tools, you can create 3D models of houses, sheds, decks, home additions,... Read more
ClamXav 3.0.12 - Virus checker based on...
ClamXav is a popular virus checker for OS X. Time to take control ClamXAV keeps threats at bay and puts you firmly in charge of your Mac’s security. Scan a specific file or your entire hard drive.... Read more
BetterTouchTool 3.151 - Customize multi-...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom)... Read more
FontExplorer X Pro 6.0.9 - Font manageme...
FontExplorer X Pro is optimized for professional use; it's the solution that gives you the power you need to manage all your fonts. Now you can more easily manage, activate and organize your... Read more
Dropbox 77.4.131 - Cloud backup and sync...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keeps them up-to-date between systems... Read more

## Latest Forum Discussions

Upcoming visual novel Arranged shines a...
If you’re in the market for a new type of visual novel designed to inform and make you think deeply about its subject matter, then Arranged by Kabuk Games could be exactly what you’re looking for. It’s a wholly unique take on marital traditions in... | Read more »
TEPPEN guide - The three best decks in T...
TEPPEN’s unique take on the collectible card game genre is exciting. It’s just over a week old, but that isn’t stopping lots of folks from speculating about the long-term viability of the game, as well as changes and additions that will happen over... | Read more »
Intergalactic puzzler Silly Memory serve...
Recently released matching puzzler Silly Memory is helping its fans with their intergalactic journeys this month with some very special offers on in-app purchases. In case you missed it, Silly Memory is the debut title of French based indie... | Read more »
TEPPEN guide - Tips and tricks for new p...
TEPPEN is a wild game that nobody asked for, but I’m sure glad it exists. Who would’ve thought that a CCG featuring Capcom characters could be so cool and weird? In case you’re not completely sure what TEPPEN is, make sure to check out our review... | Read more »
Dr. Mario World guide - Other games that...
We now live in a post-Dr. Mario World world, and I gotta say, things don’t feel too different. Nintendo continues to squirt out bad games on phones, causing all but the most stalwart fans of mobile games to question why they even bother... | Read more »
Strategy RPG Brown Dust introduces its b...
Epic turn-based RPG Brown Dust is set to turn 500 days old next week, and to celebrate, Neowiz has just unveiled its biggest and most exciting update yet, offering a host of new rewards, increased gacha rates, and a brand new feature that will... | Read more »
Dr. Mario World is yet another disappoin...
As soon as I booted up Dr. Mario World, I knew I wasn’t going to have fun with it. Nintendo’s record on phones thus far has been pretty spotty, with things trending downward as of late. [Read more] | Read more »
Retro Space Shooter P.3 is now available...
Shoot-em-ups tend to be a dime a dozen on the App Store, but every so often you come across one gem that aims to shake up the genre in a unique way. Developer Devjgame’s P.3 is the latest game seeking to do so this, working as a love letter to the... | Read more »
Void Tyrant guide - Guildins guide
I’ve still been putting a lot of time into Void Tyrant since it officially released last week, and it’s surprising how much stuff there is to uncover in such a simple-looking game. Just toray, I finished spending my Guildins on all available... | Read more »
Tactical RPG Brown Dust celebrates the s...
Neowiz is set to celebrate the summer by launching a 2-month long festival in its smash-hit RPG Brown Dust. The event kicks off today, and it’s divided into 4 parts, each of which will last two weeks. Brown Dust is all about collecting, upgrading,... | Read more »

## Price Scanner via MacPrices.net

Verizon is offering a 50% discount on iPhone...
Verizon is offering 50% discounts on Apple iPhone 8 and iPhone 8 Plus models though July 24th, plus save 50% on activation fees. New line required. The fine print: “New device payment & new... Read more
Get a new 21″ iMac for under \$1000 today at t...
B&H Photo has new 21″ Apple iMacs on sale for up to \$100 off MSRP with models available starting at \$999. These are the same iMacs offered by Apple in their retail and online stores. Shipping is... Read more
Clearance 2017 15″ 2.8GHz Touch Bar MacBook P...
Apple has Certified Refurbished 2017 15″ 2.8GHz Space Gray Touch Bar MacBook Pros available for \$1809. Apple’s refurbished price is currently the lowest available for a 15″ MacBook Pro. An standard... Read more
Clearance 12″ 1.2GHz MacBook on sale for \$899...
Focus Camera has clearance 12″ 1.2GHz Space Gray MacBooks available for \$899.99 shipped. That’s \$400 off Apple’s original MSRP. Focus charges sales tax for NY & NJ residents only. Read more
Get a new 2019 13″ 2.4GHz 4-Core MacBook Pro...
B&H Photo has new 2019 13″ 2.4GHz MacBook Pros on sale for up to \$150 off Apple’s MSRP. Overnight shipping is free to many addresses in the US: – 2019 13″ 2.4GHz/256GB 6-Core MacBook Pro Silver... Read more
AirPods with Wireless Charging Case now on sa...
Amazon has extended their Prime Day savings on Apple AirPods by offering AirPods with the Wireless Charging case for \$169.99. That’s \$30 off Apple’s MSRP, and it’s the cheapest price available for... Read more
New 2019 15″ MacBook Pros on sale for \$200 of...
B&H Photo has the new 2019 15″ 6-Core and 8-Core MacBook Pros on sale for \$200 off Apple’s MSRP. Overnight shipping is free to many addresses in the US: – 2019 15″ 2.6GHz 6-Core MacBook Pro Space... Read more
Amazon drops prices, now offers clearance 13″...
Amazon has new dropped prices on clearance 13″ 2.3GHz Dual-Core non-Touch Bar MacBook Pros by \$200 off Apple’s original MSRP, with prices now available starting at \$1099. Shipping is free. Be sure to... Read more
2018 15″ MacBook Pros now on sale for \$500 of...
Amazon has dropped prices on select clearance 2018 15″ 6-Core MacBook Pros to \$500 off Apple’s original MSRP. Prices now start at \$1899 shipped: – 2018 15″ 2.2GHz Touch Bar MacBook Pro Silver: \$1899.... Read more
Price drop! Clearance 12″ 1.2GHz Silver MacBo...
Amazon has dropped their price on the recently-discontinued 12″ 1.2GHz Silver MacBook to \$849.99 shipped. That’s \$450 off Apple’s original MSRP for this model, and it’s the cheapest price available... Read more

## Jobs Board

Best Buy *Apple* Computing Master - Best Bu...
**696259BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Location Number:** 001076-Temecula-Store **Job Description:** The Read more