Freezing in relaxor ferroelectrics and dipolar glasses