librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

when using librdkafka, create a thread will fail.

Open hnlylyb opened this issue 1 year ago • 0 comments

Description

when using librdkafka, use pthread to create a thread will be failed.

How to reproduce

#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <librdkafka/rdkafka.h>
#include <librdkafka/rdkafkacpp.h>

static void* msec_thread(void*)
{
        return nullptr;
}

static void slack_init()
{
        int rc;
        pthread_attr_t attr;
        pthread_t thr;

        pthread_attr_init(&attr);
        pthread_attr_setstacksize(&attr, 16 * 1024);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
        rc = pthread_create(&thr, &attr, msec_thread, NULL);
        pthread_attr_destroy(&attr);
        printf("rc:%d\n", rc);
}

int main(int argc, char **argv) 
{
        slack_init();
        RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
        delete conf;
        return 0;
}

using above code, it cannot create the thread, and print rc:22, but if I comment the code about rdkafka, it will print rc:0.

Checklist

librdkafka version: Operating system: ubuntu22.04

  • [x] librdkafka version (release number or git tag): v2.3.0
  • [x] Apache Kafka version: N/A
  • [x] librdkafka client configuration: N/A
  • [x] Operating system: ubuntu 22.04
  • [x] Provide logs (with debug=.. as necessary) from librdkafka
  • [x] Provide broker log excerpts
  • [x] Critical issue

hnlylyb avatar Mar 20 '24 06:03 hnlylyb