Skip to content

[Bug] Segmentation fault occurs at Broker shutdown. #324

Closed

Description

@shustsud

Search before asking

  • I searched in the issues and found nothing similar.

Version

commit id:
b35ae1aa and af45a54c

Minimal reproduce step

step1:
Create a partitioned topic.(In my environment, 16 partitions are used.)

step2:
Many Consumers connect to partitioned topic.(In my environment, 200 Consumers connected to partitioned topic.)
Each Consumer connects to a different subscription.

step3:
Repeat Broker restart until segmentation fault occurs.

What did you expect to see?

Consumer reconnection succeeds.

What did you see instead?

Segmentation fault occurs.

Anything else?

This issue did not occur in 84ac6fb9.

Perhaps one of the commits between 787bfd0e and b35ae1aa caused this issue.

Client logs are as follows.

2023-10-05 09:03:17.711 INFO  [140211864341184] Client:90 | Subscribing on Topic :persistent://shustsud-test2/test/partitioned-topic
2023-10-05 09:03:17.711 INFO  [140211864341184] ClientConnection:187 | [<none> -> pulsar+ssl://<host(vip)>:<prot>] Create ClientConnection, timeout=10000
2023-10-05 09:03:17.721 INFO  [140211864341184] ConnectionPool:107 | Created connection for pulsar+ssl://<host(vip)>:<prot>
2023-10-05 09:03:17.726 INFO  [140211814409984] ClientConnection:397 | [<host(client)>:44036 -> <host(vip)>:<prot>] Connected to broker
2023-10-05 09:03:17.756 INFO  [140211814409984] HandlerBase:80 | [0x7f8594000ed0, dummy_18, 0] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f859402a240, dummy_18, 1] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594017d40, dummy_18, 2] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594035920, dummy_18, 3] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594017870, dummy_18, 4] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f85940476b0, dummy_18, 5] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f85940125b0, dummy_18, 6] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594053430, dummy_18, 7] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f85940594b0, dummy_18, 8] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f859405f480, dummy_18, 9] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594065450, dummy_18, 10] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f859406b210, dummy_18, 11] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594071250, dummy_18, 12] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594077220, dummy_18, 13] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f859407cfe0, dummy_18, 14] Getting connection from pool
2023-10-05 09:03:17.757 INFO  [140211814409984] HandlerBase:80 | [0x7f8594057f20, dummy_18, 15] Getting connection from pool
2023-10-05 09:03:17.758 INFO  [140211814409984] ClientConnection:187 | [<none> -> pulsar+ssl://<host(broker2)>:<prot>] Create ClientConnection, timeout=10000
2023-10-05 09:03:17.766 INFO  [140211814409984] ConnectionPool:107 | Created connection for pulsar+ssl://<host(broker2)>:<prot>
2023-10-05 09:03:17.767 INFO  [140211814409984] ClientConnection:397 | [<host(client)>:49870 -> <host(broker2)>:<prot>] Connected to broker
2023-10-05 09:03:17.772 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594000ed0, dummy_18, 0] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.772 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 15
2023-10-05 09:03:17.772 INFO  [140211814409984] ConsumerImpl:282 | [0x7f859402a240, dummy_18, 1] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.772 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 14
2023-10-05 09:03:17.772 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594017d40, dummy_18, 2] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.772 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 13
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594035920, dummy_18, 3] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 12
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594017870, dummy_18, 4] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 11
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f85940476b0, dummy_18, 5] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 10
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f85940125b0, dummy_18, 6] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 9
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594053430, dummy_18, 7] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 8
2023-10-05 09:03:17.773 INFO  [140211814409984] ConsumerImpl:282 | [0x7f85940594b0, dummy_18, 8] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.773 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 7
2023-10-05 09:03:17.774 INFO  [140211814409984] ConsumerImpl:282 | [0x7f859405f480, dummy_18, 9] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.774 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 6
2023-10-05 09:03:17.774 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594065450, dummy_18, 10] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.774 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 5
2023-10-05 09:03:17.774 INFO  [140211814409984] ConsumerImpl:282 | [0x7f859406b210, dummy_18, 11] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.774 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 4
2023-10-05 09:03:17.774 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594071250, dummy_18, 12] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.774 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 3
2023-10-05 09:03:17.774 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594077220, dummy_18, 13] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.774 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 2
2023-10-05 09:03:17.775 INFO  [140211814409984] ConsumerImpl:282 | [0x7f859407cfe0, dummy_18, 14] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.775 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 1
2023-10-05 09:03:17.775 INFO  [140211814409984] ConsumerImpl:282 | [0x7f8594057f20, dummy_18, 15] Created consumer on broker [<host(client)>:49870 -> <host(broker2)>:<prot>]
2023-10-05 09:03:17.775 INFO  [140211814409984] MultiTopicsConsumerImpl:303 | Successfully Subscribed to a single partition of topic in TopicsConsumer. Partitions need to create : 0
2023-10-05 09:03:17.775 INFO  [140211814409984] MultiTopicsConsumerImpl:146 | Successfully Subscribed to Topics
2023-10-05 09:06:56.935 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 12
2023-10-05 09:06:56.935 INFO  [140211814409984] HandlerBase:140 | [0x7f8594071250, dummy_18, 12] Schedule reconnection in 0.1 s
2023-10-05 09:06:56.960 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 4
2023-10-05 09:06:56.960 INFO  [140211814409984] HandlerBase:140 | [0x7f8594017870, dummy_18, 4] Schedule reconnection in 0.1 s
2023-10-05 09:06:56.986 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 8
2023-10-05 09:06:56.986 INFO  [140211814409984] HandlerBase:140 | [0x7f85940594b0, dummy_18, 8] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.011 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 0
2023-10-05 09:06:57.011 INFO  [140211814409984] HandlerBase:140 | [0x7f8594000ed0, dummy_18, 0] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 7
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f8594053430, dummy_18, 7] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:80 | [0x7f8594071250, dummy_18, 12] Getting connection from pool
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:80 | [0x7f8594017870, dummy_18, 4] Getting connection from pool
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:80 | [0x7f85940594b0, dummy_18, 8] Getting connection from pool
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:80 | [0x7f8594000ed0, dummy_18, 0] Getting connection from pool
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 11
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f859406b210, dummy_18, 11] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 15
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f8594057f20, dummy_18, 15] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 3
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f8594035920, dummy_18, 3] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 10
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f8594065450, dummy_18, 10] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 2
2023-10-05 09:06:57.209 INFO  [140211814409984] HandlerBase:140 | [0x7f8594017d40, dummy_18, 2] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.209 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 14
2023-10-05 09:06:57.210 INFO  [140211814409984] HandlerBase:140 | [0x7f859407cfe0, dummy_18, 14] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.210 INFO  [140211814409984] ClientConnection:187 | [<none> -> pulsar+ssl://<host(broker1)>:<prot>] Create ClientConnection, timeout=10000
2023-10-05 09:06:57.616 INFO  [140211814409984] ConnectionPool:107 | Created connection for pulsar+ssl://<host(broker1)>:<prot>
2023-10-05 09:06:57.616 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 6
2023-10-05 09:06:57.616 INFO  [140211814409984] HandlerBase:140 | [0x7f85940125b0, dummy_18, 6] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.616 INFO  [140211814409984] HandlerBase:80 | [0x7f8594053430, dummy_18, 7] Getting connection from pool
2023-10-05 09:06:57.616 INFO  [140211814409984] HandlerBase:80 | [0x7f859406b210, dummy_18, 11] Getting connection from pool
2023-10-05 09:06:57.616 INFO  [140211814409984] HandlerBase:80 | [0x7f8594057f20, dummy_18, 15] Getting connection from pool
2023-10-05 09:06:57.616 INFO  [140211814409984] HandlerBase:80 | [0x7f8594035920, dummy_18, 3] Getting connection from pool
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:80 | [0x7f8594065450, dummy_18, 10] Getting connection from pool
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:80 | [0x7f8594017d40, dummy_18, 2] Getting connection from pool
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:80 | [0x7f859407cfe0, dummy_18, 14] Getting connection from pool
2023-10-05 09:06:57.617 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 5
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:140 | [0x7f85940476b0, dummy_18, 5] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.617 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 13
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:140 | [0x7f8594077220, dummy_18, 13] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.617 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 9
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:140 | [0x7f859405f480, dummy_18, 9] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.617 INFO  [140211814409984] ConsumerImpl:1207 | Broker notification of Closed consumer: 1
2023-10-05 09:06:57.617 INFO  [140211814409984] HandlerBase:140 | [0x7f859402a240, dummy_18, 1] Schedule reconnection in 0.1 s
2023-10-05 09:06:57.617 INFO  [140211814409984] ClientConnection:397 | [<host(client)>:49194 -> <host(broker1)>:<prot>] Connected to broker
2023-10-05 09:06:57.617 ERROR [140211814409984] ClientConnection:1330 | [<host(client)>:49870 -> <host(broker2)>:<prot>] Connection closed with ConnectError
2023-10-05 09:06:57.617 INFO  [140211814409984] ConnectionPool:122 | Remove connection for pulsar+ssl://<host(broker2)>:<prot>
2023-10-05 09:06:57.617 INFO  [140211814409984] ClientConnection:267 | [<host(client)>:49870 -> <host(broker2)>:<prot>] Destroyed connection to pulsar+ssl://<host(broker2)>:<prot>
2023-10-05 09:06:57.618 WARN  [140211814409984] ClientConnection:1135 | [<host(client)>:44036 -> <host(vip)>:<prot>] Could not send message on connection: system:32 Broken pipe
2023-10-05 09:06:57.619 ERROR [140211814409984] ClientConnection:1330 | [<host(client)>:44036 -> <host(vip)>:<prot>] Connection closed with ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] ConnectionPool:122 | Remove connection for pulsar+ssl://<host(vip)>:<prot>
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-7, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f8594053430, dummy_18, 7] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-11, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f859406b210, dummy_18, 11] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-15, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f8594057f20, dummy_18, 15] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-3, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f8594035920, dummy_18, 3] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-10, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f8594065450, dummy_18, 10] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-2, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f8594017d40, dummy_18, 2] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 ERROR [140211814409984] BinaryProtoLookupService:68 | Lookup failed for persistent://shustsud-test2/test/partitioned-topic-partition-14, result ConnectError
2023-10-05 09:06:57.619 INFO  [140211814409984] HandlerBase:140 | [0x7f859407cfe0, dummy_18, 14] Schedule reconnection in 0.196 s
2023-10-05 09:06:57.619 INFO  [140211814409984] ClientConnection:267 | [<host(client)>:44036 -> <host(vip)>:<prot>] Destroyed connection to pulsar+ssl://<host(vip)>:<prot>
Segmentation fault

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. BewareMyPower commented on Oct 7, 2023

    @BewareMyPower
    Contributor

    I also observed a similar segfault recently. It happened randomly.

    A failed case:

    2023-10-07 15:46:10.026 INFO  [0x16f587000] ClientConnection:1340 | [127.0.0.1:60762 -> 127.0.0.1:6650] Connection disconnected
    2023-10-07 15:46:10.026 INFO  [0x16f587000] ConnectionPool:122 | Remove connection for pulsar://127.0.0.1:6650
    2023-10-07 15:46:10.026 INFO  [0x16f587000] HandlerBase:141 | [persistent://public/default/my-topic, standalone-11-18] Schedule reconnection in 0.1 s
    2023-10-07 15:46:10.026 INFO  [0x16f587000] ClientConnection:268 | [127.0.0.1:60762 -> 127.0.0.1:6650] Destroyed connection to pulsar://127.0.0.1:6650
    zsh: segmentation fault  ./examples/SampleProducer
    

    A successful case:

    2023-10-07 15:46:46.771 INFO  [0x16f997000] ClientConnection:1340 | [127.0.0.1:60787 -> 127.0.0.1:6650] Connection disconnected
    2023-10-07 15:46:46.771 INFO  [0x16f997000] ConnectionPool:122 | Remove connection for pulsar://127.0.0.1:6650
    2023-10-07 15:46:46.771 INFO  [0x16f997000] HandlerBase:141 | [persistent://public/default/my-topic, standalone-11-26] Schedule reconnection in 0.1 s
    2023-10-07 15:46:46.771 INFO  [0x16f997000] ClientConnection:268 | [127.0.0.1:60787 -> 127.0.0.1:6650] Destroyed connection to pulsar://127.0.0.1:6650
    2023-10-07 15:46:46.872 INFO  [0x16f997000] HandlerBase:81 | [persistent://public/default/my-topic, standalone-11-26] Getting connection from pool
    2023-10-07 15:46:46.872 INFO  [0x16f997000] ClientConnection:188 | [<none> -> pulsar://127.0.0.1:6650] Create ClientConnection, timeout=10000
    
  2. BewareMyPower commented on Oct 7, 2023

    @BewareMyPower
    Contributor

    The root cause might be b35ae1a, I reverted this commit and then the segmentation fault never happened. I will investigate the reason.

  3. BewareMyPower commented on Oct 8, 2023

    @BewareMyPower
    Contributor

    @shustsud Could you try my patch here to see whether it's fixed?

  4. shustsud commented on Oct 16, 2023

    @shustsud
    ContributorAuthor

    @BewareMyPower
    Thank you for your comment.
    I tried 5c77648 , but this issue(Segmentation fault) still seems to occur.

  5. BewareMyPower commented on Oct 16, 2023

    @BewareMyPower
    Contributor

    Maybe it's better to upload the stacktrace from the core dump.

    In my test environment the segfault never happened after that commit.

  6. BewareMyPower commented on Oct 16, 2023

    @BewareMyPower
    Contributor

    In addition, you can try capturing the shared_ptr instead of weak_ptr in asyncReceive because your scenario has many consumers while my test environment has many producers. I'm not sure the same issue stands for async_receive like async_write. If it works, you can open a PR.

  7. shustsud commented on Oct 17, 2023

    @shustsud
    ContributorAuthor

    The stacktrace extracted from the core dump is as follows.

    (gdb) bt
    #0  0x00000000006dccb0 in ?? ()
    #1  0x00007f918bd83763 in BIO_write () from /lib64/libcrypto.so.1.1
    #2  0x00007f918a85672f in boost::asio::ssl::detail::engine::put_input (data=..., this=<optimized out>, this=<optimized out>) at /usr/local/include/boost/asio/ssl/detail/impl/engine.ipp:229
    #3  0x00007f918a8881dd in boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >::operator()(boost::system::error_code, std::size_t, int) (this=0x7f9189947690, ec=...,
        bytes_transferred=0, start=0) at /usr/local/include/boost/asio/ssl/detail/io.hpp:269
    #4  0x00007f918a893113 in boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>::operator() (
        this=0x7f9189947690) at /usr/local/include/boost/asio/detail/bind_handler.hpp:289
    #5  boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int> > (function=...)
        at /usr/local/include/boost/asio/handler_invoke_hook.hpp:88
    #6  boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > > (context=..., function=...)
        at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:54
    #7  boost::asio::ssl::detail::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > > (this_handler=0x7f9189947690, function=...) at /usr/local/include/boost/asio/ssl/detail/io.hpp:374
    #8  boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > > > (context=..., function=...) at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:54
    #9  boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int> (this_handler=0x7f9189947690, function=...) at /usr/local/include/boost/asio/detail/bind_handler.hpp:344
    #10 boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int> > (context=..., function=...) at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:54
    #11 boost::asio::detail::executor_op<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::read_op<boost::asio::mutable_buffers_1>, boost::asio::executor_binder<AllocHandler<pulsar::ClientConnection::readNextCommand()::<lambda(const boost::system::error_code&, size_t)> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> > > >, boost::system::error_code, long unsigned int>, std::allocator<void>, boost::asio::detail::scheduler_operation>::do_complete(void *, boost::asio::detail::scheduler_operation *, const boost::system::error_code &, std::size_t) (owner=0x62d910, base=0x7f91840bc520) at /usr/local/include/boost/asio/detail/executor_op.hpp:70
    #12 0x00007f918a8a81e2 in boost::asio::detail::scheduler_operation::complete (bytes_transferred=0, ec=..., owner=<optimized out>, this=<optimized out>) at /usr/local/include/boost/asio/detail/scheduler_operation.hpp:40
    #13 boost::asio::detail::strand_executor_service::run_ready_handlers (impl=std::shared_ptr<boost::asio::detail::strand_executor_service::strand_impl> (use count 2, weak count 0) = {...}) at /usr/local/include/boost/asio/detail/impl/strand_executor_service.ipp:150
    #14 boost::asio::detail::strand_executor_service::invoker<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> const, void>::operator() (this=this@entry=0x7f9189947810) at /usr/local/include/boost/asio/detail/impl/strand_executor_service.hpp:127
    #15 0x00007f918a8a8821 in boost::asio::asio_handler_invoke<boost::asio::detail::strand_executor_service::invoker<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> const, void> > (function=...) at /usr/local/include/boost/asio/handler_invoke_hook.hpp:88
    #16 boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::strand_executor_service::invoker<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> const, void>, boost::asio::detail::strand_executor_service::invoker<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> const, void> > (context=..., function=...) at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:54
    #17 boost::asio::detail::executor_op<boost::asio::detail::strand_executor_service::invoker<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> const, void>, boost::asio::detail::recycling_allocator<void, boost::asio::detail::thread_info_base::default_tag>, boost::asio::detail::scheduler_operation>::do_complete (owner=0x62b2c0, base=<optimized out>) at /usr/local/include/boost/asio/detail/executor_op.hpp:70
    #18 0x00007f918a89f247 in boost::asio::detail::scheduler_operation::complete (bytes_transferred=0, ec=..., owner=0x62b2c0, this=0x7f918402a290) at /usr/local/include/boost/asio/detail/scheduler_operation.hpp:40
    #19 boost::asio::detail::scheduler::do_run_one (this=this@entry=0x62b2c0, lock=..., this_thread=..., ec=...) at /usr/local/include/boost/asio/detail/impl/scheduler.ipp:492
    #20 0x00007f918a9209d1 in boost::asio::detail::scheduler::run (this=0x62b2c0, ec=...) at /usr/local/include/boost/asio/detail/impl/scheduler.ipp:210
    #21 0x00007f918a920bc6 in boost::asio::io_context::run (ec=..., this=<optimized out>) at /usr/local/include/boost/asio/impl/io_context.ipp:71
    #22 operator() (__closure=0x62b0c8) at /home/xxx/work/20231016/pulsar-client-cpp/lib/ExecutorService.cc:39
    #23 0x00007f918aa3ed54 in execute_native_thread_routine () from /home/xxx/work/20231016/pulsar-client-cpp/lib/libpulsar.so
    #24 0x00007f9189d1eea5 in start_thread () from /lib64/libpthread.so.0
    #25 0x00007f9189a47b0d in clone () from /lib64/libc.so.6
    (gdb)
    

    As per the stacktrace, this issue may be occurring in async_receive(readNextCommand).

  8. BewareMyPower commented on Oct 19, 2023

    @BewareMyPower
    Contributor

    Yes, we observed similar segmentation faults as well :(

    I will push a similar fix as well

  9. BewareMyPower commented on Oct 19, 2023

    @BewareMyPower
    Contributor

    Could you try #330?

  10. shustsud commented on Oct 23, 2023

    @shustsud
    ContributorAuthor

    Thank you for fixing the issue.

    This issue has been resolved by #330, so this issue will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions