fix global barrier bug in table_group.cpp and limit maximum value of S to prevent overflow