How can I erase a locked group with C-API?

unlock the group, then erase the group, but prompt me that serialization failed when I save the model.
When I annotate the whole method, it can be saved normally.

void DeleteLockEntities(SUEntitiesRef entities) {
	size_t num = 0;
    // get number of instances
	SU(SUEntitiesGetNumInstances(entities, &num));
	std::vector<SUEntityRef> erase_entities;
	if (num > 0) {
		std::vector<SUComponentInstanceRef> src_instances(num);
        // get all instances
		SU(SUEntitiesGetInstances(entities, num, &src_instances[0], &num));
		for (int i = 0; i < num; i++) {
			this->current_progress++;
			SUComponentInstanceRef src_instance = src_instances[i];
			bool is_lock = false;
            // get flag of lock
			SU(SUComponentInstanceIsLocked(src_instance, &is_lock));
			if (is_lock) {
				erase_entities.push_back(SUComponentInstanceToEntity(src_instance));
                // unlock
				SU(SUComponentInstanceSetLocked(src_instance, false));
			}
		}
	}
    // get number of groups
	SU(SUEntitiesGetNumGroups(entities, &num));
	if (num > 0) {
		std::vector<SUGroupRef> src_group(num);
        // get all groups
		SU(SUEntitiesGetGroups(entities, num, &src_group[0], &num));
		for (int i = 0; i < num; i++) {
			this->current_progress++;
			SUComponentInstanceRef src_instance = SUGroupToComponentInstance(src_group[i]);
			bool is_lock = false;
            // get flag of lock
			SU(SUComponentInstanceIsLocked(src_instance, &is_lock));
			if (is_lock){
				erase_entities.push_back(SUComponentInstanceToEntity(src_instance));
                // unlock
				SU(SUComponentInstanceSetLocked(src_instance, false));
			}
		}
	}
    // erase all group of locked
	if (!erase_entities.empty())
		SU(SUEntitiesErase(entities, erase_entities.size(), &(erase_entities[0])));
}

When reporting errors, please state the API version.

FYI, components and groups might contain nested groups or instances that could be locked. (Your code does not check for this scenario.)

Can you attach sample file please?