I just did a few tests using Kamailio for git master branch with topos and mask_callid=1, all seemed ok, call id is masked and unmasked fine, calls were established and ended fine.
I am closing this one, if you still have issues, reopen (or create a new) issue, add again the log messages you get with latest version, a pcap with sip traffic would help as well.