Yes, that is the case... unmodified mags, no problems until the final 2 rounds.
except, it was two different 30 rounders, and 3 different magpul 20 rounders. All had the same issue
OK, you still haven't told me whether this was a complete rifle you bought or a home-build, the reason is if you bought a complete rifle--I would simply send it to the manufacturer since doing the home modifications might cause warranty issues.
I'm just guessing since I don't have your rifle on hand--but it sounds to me like your problem is not associated with the rifle properly firing and ejecting since it works fine most of the time.
You mentioned a ledge between the lower receiver and the feed ramps of the barrel's extension--it's true that that can cause problems by catching the nose of the bullet upon feed--but generally you would be seeing damage to the bullet's nose if that were happening on a consistent basis. You can fairly easily eliminate that with a Dremel by carefully "blending" the barrel's ramps into the receiver--google for it and you should be able to find videos of what that looks like. You can "control cycle" a cartridge
slowly (be sure to do this with safety on and the muzzle pointed at something you don't mind destroying if using a live cartridge) while observing where the cartridge goes and what it hits on the way into the chamber.
My money is on you have a magazine position issue which is causing a tilt in your cartridge due to low pressure in the magazine's spring/follower when most of the cartridges are expended. Again, you should be able to see if this is the issue by doing a slow cycle with your hand on the charging handle controlling the feed while observing it. I would probably pull the bolt and magazine catches and their associated parts from the lower and then re-install them and make sure they are installed correctly under proper tension and with normal clearance/functioning in the lower. Home builders often overlook the quality of a LPK--but investing in a good bolt catch is pretty important IMO. Magazines have a slot in their sides where the catch notches into them--sometimes a loose/improper fit can cause the magazine to shift up and down in the mag well. I'm guessing you get those LPK parts and magazine fit properly tuned to your receiver your feed issues will go away.
Hmmm...upon further reflection, a quick and easy solution might be to shop around and see if you can find a stiffer magazine spring and anti-tilt follower--in fact if you are really adventurous I might be tempted just out of curiosity to take one of your 30 round magazine springs and see if I can get it into the 20 round magazine just for the heck of it (though I've never done it and can't vouch for how well it would work, you might have to sacrifice the spring with a bit of trimming but they are generally pretty cheap) and test fire it and see if the second to last round curse goes away--if it does I'm guessing that would almost certainly confirm it's an issue with magazine seating to the receiver.