I've had a couple of very dysfunctional friends. It's very difficult to reach a balance between maintaining boundaries (so that you don't get drawn completely into their distorted world) and maintaining a real relationship through those boundaries.
Ultimately I think it comes down to psychological flexibility... the ability to give and take, to adapt to others' needs/hopes, etc. Flexibility without boundaries leads to ending up as a doormat, or crazy, or whatever; being inflexible is just another word for crazy.
The nature of dysfunction with the friends I had was such that I would make accommodations and go along with what they wanted occasionally, but when a reciprocal accommodation was not forthcoming I would leave the ball in their court - letting them decide if they wanted to reciprocate. For example, I had a friend who was obsessed with aerobic exercise. Every time we ever did anything it would involve jogging, rock-climbing, cycling, etc. Occasionally I would want to go the movies, but he said that movies were for couch potatoes. He could not sit still, nor want to be inside for more than 40min. Eventually he started getting aggravated that I would let him know that me and some of the other guys from work were going to the movies - and that he was invited, especially when he had wanted to go jogging with me. Eventually he go so pissed off that we would just jog in silence and he wouldn't speak to me at work. He eventually he found another jogging companion. Admittedly I had gotten stubborn in wanting him to realise that he was being unreasonable, by continuing to exercise with him, but there was no realisation, just resentment that I had other interests.