librdkafka
                                
                                 librdkafka copied to clipboard
                                
                                    librdkafka copied to clipboard
                            
                            
                            
                        Don't return NULL from rd_kafka_new()'s "This should never happen" codepath
As the new comment says: We shouldn't return NULL unless failure has actually occurred and our caller can proceed with cleaning up their resources. If librdkafka is still actively running background threads that need to touch those resources, we MUST NOT communicate otherwise to our caller.
Since this codepath "should never happen," it theoretically doesn't matter much what we do here. But return NULL in practice leads to use-after-free segfaults on overloaded VMs, so we shouldn't do that. Instead, just loop (and log) until the background threads have run, and then proceed. Slow success is still success.
Fixes #4100.