The problem was in this part: that was happening in DIFFERENT thread, which is undefined behavior, refer SDL_Renderer calls from different thread possible? for more info.
The problem was in this part: that was happening in DIFFERENT thread, which is undefined behavior, refer SDL_Renderer calls from different thread possible? for more info.