I had problems like that with a Dodge Ram diesel a few years ago. Was giving me fits with sometimes it would do it, sometimes it wouldn't. Took it to the transmission "specialist" and he had it the whole day and said the tranny needed an overhaul. Me being the cheap doubting MacThomas I am did the low crawl and found a pile of grime and rocks and stuff around where the shifter shaft goes into the transmission. Blew it out good and coated with some Knock er loose and never had a problem again. Man oh man did I feel heroic figurin that one out!!