The problem was caused because the `Nearest2dUserData::obmat_` member was deallocated in derived classes even before the main class destructor was called. This is strange behavior and only seen in Mac or Linux Release builds. The solution is to not rely on the destructor to register snap values. So create a separate function.