It depends on how deep the trap is, if it is about 12″ from top then your P-Trap must be next to the joist. It could be some water backed up and you did not flush it out, sometimes the pipe gets
growth on inside and smells, Try Bio Clean, Pine oil are San Teens and dump one in the pipe and see if it does anything, you can get these at Plumbing Supplyhouse are maybe box stores have them are something like it, let me know.
Art retired plbg