On one trip, my daughter was a smidge under 40" with sneakers at home - so I didn't think she'd make it. I told her to get measured at Test Track just in case - and she made it! She made it inside too. She did the ride a second time. But the third time, in a row, she was fine when measured on the outside of the ride but not on the inside - even though she had JUST done the ride. Not getting a third time in wasn't a huge deal, but it was tough to explain to her how she managed to be a different size so close to when she was fine. As a plus - we had prepared her to not be able to do any of the 40" rides. Instead, we found that she was tall enough every time if it was her very first ride of the morning. After that, it was gamble - and she was never tall enough in the afternoon. At only 38" I wouldn't even bother trying the 40" rides though. I would prepare him for possibly not making Mine Train - that way it's a bonus when he does.
*On that trip, there were some kids under 40" on BTMRR. I knew this because they were shorter than my daughter. So, though they're usually extremely careful about measuring, there are exceptions but I wouldn't plan on them since you want safety!