fix recursive crash in sample on optimized builds