Here are a few pointers on a subject with which I am all too intimately familiar: getting lost while soloing over over a form, and while reading:
First, whatever various hells break loose during your solo, you can always just cue the band back in at the end. Set them up by playing something that sounds like a last A (assuming an AABA form)- going back to playing time would suggest that- and make significant eye contact with the rest of the band. If they're not deliberately hanging you out to dry, they'll come in at the end of the 8 bars, especially if you give them a nice bonehead-simple lead-in on the last measure. If they don't follow you, you can play eight more bars and then verbally count them back in. They would have to really have it in for you to ignore that.
You do also have to know the tune. Be able to sing the melody badly, know the length and structure of the form (12 bar blues, AABA, 32 bars + tag, 16+16, etc), and know the standard arrangement, if there is one (e.g., the repeated figure on Stolen Moments, or the stops in Work Song). At the very least you have to know the form.
Something you can do at the actual moment of getting lost is to just guess where the nearest reference point is; so if you get lost in the middle of the second A, then make a big downbeat and change the texture someplace that could plausibly be the beginning of the bridge, and carry on with the form from there. Who knows, you might even guess right. Even if you don't, most of the band will suspect that they counted wrong, and half of the rest of them aren't even paying attention. The actual cats will know that you blew it, and recovered. It doesn't matter.
More helpful tips after the break:
What's the longest phrase you can play without getting lost? If you can play 8 bars or a chorus of blues, you're in. After that it's just a matter of having the presence of mind to know whether you're on the first, second, or last A, or the bridge. Or whatever part of the form in question.
It's common for novices to forget which of the three A sections they're on, so beware of that. Maybe mentally screaming "TOP!" to yourself after the last A will help you keep them straight; get used to thinking bridge, last A, TOP! at the beginning of each of those sections, respectively. The first two A's should take care of themselves.
Simplify. You can probably play time unaccompanied through the form without getting lost. Build on that. Do a tactical retreat from your massively displaced/polyrhythmic hell-of-notes chops-fest, and just play time, adding things as you are able to without losing it.
These mostly apply to the type of reading I've been doing these days- challenging one or two page lead sheets:
Watch out for odd phrases. Is the form 4+4+4+5 bars? When you get to that last phrase, you're going to have to remember every time that there's an awkward extra bar. So don't get too comfortable at that spot- count through it. That goes double for any random, momentary meter changes the composer/arranger decides to throw at you.
Watch and listen for variations in the harmonic rhythm. That's the rate at which the chords change. If most of the changes happen once per measure, but there are two per measure in a few spots, you should be able to hear it and orient around them.
Figure out where your harmonic home base is. As you hack through the chart the first time, listen for the comfy-sounding chords, and remember where they are on the page. Get used to cuing off their sound when they recur elsewhere in the chart. With our recent "tune of the moment" Feet First, for example, there's D-7/A-7 thing that happens at the top, and throughout the piece. You should be able to hear that when it comes up later. You don't have to know a D-7 from a DX7 to do this; once you find it on the chart and start listening for it, it will be as distinctive as someone hitting a cowbell at that spot.