Don't think this is a bug. There is quite a lot of traits that can cause this. For example if your general has spent many years in a settlement with a pleasure palace or brothel etc, its only a matter of chance until he probably decides to go in if he has a lot of other despicable traits. Try looking for traits that seem deplorable in his description. Also has to do with the wife traits, if she is... to be generous... not attractive... there is a big chance he will father children from a more attractive woman in secrecy. The traits for wife just say "decrease chance of having children" but think of it as "decreased chance for HER, not him".

Overall this is very annoying, but makes sense historically for some minded individuals. And if one is a bastard, theres a pretty good chance he didn't stop with one with that woman so... also the fact that if one is known as bastard the nobles may look down on any others as potential bastard too. So, in my eyes, not a bug, but unlucky, but also not to be unexpected!