Thus far, the responses about the negative aspects of sharing only discuss idea "theft." This would seem to apply mostly when the ideas being shared are already publishable, near publishable, or at least very likely to lead to something publishable. The biggest danger I have ever experienced with sharing occurs earlier in the process and has nothing to do with theft. It is to enter the following pattern:
(1) I share an idea or problem with somebody before I have really given myself time to marinate in it. (2) The other person introduces their own ideas--- and is so persuasive, or detailed, or optimistic about their own views, that I get caught up in them. (3) I lose the thread of my original idea and/or spend a long time fruitlessly trying to attack my own problem with somebody else's way of thinking.
I'm not saying that my way is always better or leads to the right thing, and that the only thing stopping me from publishing great results is distractions from lesser minds. I am saying that sometimes you should not share your ideas until you are either well and truly stuck, or far enough along that you could give a coherent (if detail-free) seminar talk about them. You need to know enough about your own ideas that you can put them down for a minute and compare them with someone else's without information loss. When this is, exactly, changes from person to person and problem to problem. But if you share too soon, you run a risk of spending a lot of mathematician-hours checking the details of somebody else's half-baked idea before you have even checked your own. I think grad students are generally more in danger of this than they are of idea theft. (It is easy to unconsciously take an established person's educated guess for "expert wisdom", even when it is not intended as such.)