You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Segmentation fault when properties exceed ~100kb #223
Hi everyone, i'm running an event driven app and i use apache pulsar as backbone. I use message's properties to exchange metadata between the services.
I noted that, when the properties exceed ~100kb the client gives Segmentation fault (core dumped) (sometimes corrupted double-linked list instead)
I haven't done a proper test on the size, so take the size as a guideline
I was able to simulate the behaviour in a notebook:
importpulsarimportsysimportjson# need to serialize to json nested object because client accepts properties only# of type (self: _pulsar.MessageBuilder, arg0: str, arg1: str)nested_dict=json.dumps({
"foo": "bar"
})
big_dict= {
f"key{i}": nested_dictforiinrange(3000)
}
print(sys.getsizeof(big_dict)) # 103856client=pulsar.Client('pulsar://localhost:6650')
producer=client.create_producer('test-topic')
producer.send(content="test-message".encode(), properties=big_dict) # segfault
Unfortunately i don't have details in the stacktrace:
In [4]: producer.send(content="test-message".encode(), properties=big_dict)
Segmentation fault (core dumped)
🙈 I made a mistake in moving this issue. I first thought that it was in the apache/pulsar repository and transferred it to pulsar-client-cpp. I'm sorry about that. Perhaps this is pulsar-client-cpp related in any case.
Oh I realized where the issue is, there is a bug with the C++ client when batching is disabled. However, the Python client somehow disables batching by default.
You can manually enable the batching to get the issue around, while I'm going to push a fix at the C++ client.
I also pushed a PR (#224) to enable batching by default.
Activity
lhotari commentedon Aug 27, 2024
🙈 I made a mistake in moving this issue. I first thought that it was in the apache/pulsar repository and transferred it to pulsar-client-cpp. I'm sorry about that. Perhaps this is pulsar-client-cpp related in any case.
[-]Segmentation fault when properties exceed ~100kb[/-][+][Bug] Segmentation fault when properties exceed ~100kb[/+]emanueledomingo commentedon Aug 27, 2024
Ok, thanks! I also think it has to do with the core c++ implementation. But as a python user I wasn't sure.
BewareMyPower commentedon Aug 29, 2024
Yeah, it's related to the C++ core. And it's a known issue. It might be easy to fix. I will take some time for it when I'm free.
BewareMyPower commentedon Aug 29, 2024
I just double checked the issue and it looks like a bug with protobuf:
I tried the python client on macOS and it does not have this error but encountered the same issue for Ubuntu.
However, I tried the C++ client 3.5.1 on Ubuntu and this error does not happen:
Increasing the
iin loop does not fail with segfault as well. (if the properties are too big,ResultMessageTooLargewill be returned)It might be an issue from the Python client side. So let me move it to
pulsar-client-pythonfirst.BewareMyPower commentedon Aug 29, 2024
Oh I realized where the issue is, there is a bug with the C++ client when batching is disabled. However, the Python client somehow disables batching by default.
You can manually enable the batching to get the issue around, while I'm going to push a fix at the C++ client.
I also pushed a PR (#224) to enable batching by default.
Fix buffer overflow for non-batched send when the message metadata si…
Fix buffer overflow for non-batched send when the message metadata si…
emanueledomingo commentedon Aug 29, 2024
I confirm that by enabling batching, the bug does not appear. Thanks for the workaround suggestion!
Fix buffer overflow for non-batched send when the message metadata si…