Closed Kobzol closed 1 year ago
@Kobzol ,Thank you for reporting the issue. I reproduced the valgrind result. Is seems that the issue is caused by #1096 (including #1095).
Could you try 37fcaa1264746456c14aec08bf6efc8d1ab06f7b (Just before commit merging #1096). On my environment, it works fine. @Kobzol , could you try it? If it would work well too, I will revert #1096.
@Arenoros, could you debug #1096 ? If you would fixed the issue, please create a new PR.
I can confirm that with this commit, it doesn't segfault, and Valgrind doesn't report any errors.
Fixed by #1101
Describe the bug When I try to run the "Streaming feature" example from the C++ quickstart, the program segfaults.
Using the
cpp_master
branch (commit2987022c10ac066b55c6e554369eab92cdebe506
). It works fine with thecpp-6.1.0
tag.To Reproduce Test file (
test.cpp
):Using
g++ 11.4.0
on Ubuntu 22.04. It works without optimizations, so it's most probably some UB/memory error. Works withclang 14.0.0
(both with and without optimizations).Here is the Valgrind output:
Memcheck output
``` ==176304== Invalid read of size 8 ==176304== at 0x10AA68: main (in /tmp/msgpack-c/example/test) ==176304== Address 0x4e0b108 is 8 bytes inside a block of size 24 free'd ==176304== at 0x484C93D: operator delete(void*, unsigned long) (vg_replace_malloc.c:1103) ==176304== by 0x10AA07: main (in /tmp/msgpack-c/example/test) ==176304== Block was alloc'd at ==176304== at 0x4848F95: operator new(unsigned long) (vg_replace_malloc.c:485) ==176304== by 0x10AC50: main (in /tmp/msgpack-c/example/test) ==176304== ==176304== Invalid read of size 8 ==176304== at 0x10AA6C: main (in /tmp/msgpack-c/example/test) ==176304== Address 0x4e0b100 is 0 bytes inside a block of size 24 free'd ==176304== at 0x484C93D: operator delete(void*, unsigned long) (vg_replace_malloc.c:1103) ==176304== by 0x10AA07: main (in /tmp/msgpack-c/example/test) ==176304== Block was alloc'd at ==176304== at 0x4848F95: operator new(unsigned long) (vg_replace_malloc.c:485) ==176304== by 0x10AC50: main (in /tmp/msgpack-c/example/test) ==176304== ==176304== Invalid read of size 8 ==176304== at 0x10AA72: main (in /tmp/msgpack-c/example/test) ==176304== Address 0x4e0b110 is 16 bytes inside a block of size 24 free'd ==176304== at 0x484C93D: operator delete(void*, unsigned long) (vg_replace_malloc.c:1103) ==176304== by 0x10AA07: main (in /tmp/msgpack-c/example/test) ==176304== Block was alloc'd at ==176304== at 0x4848F95: operator new(unsigned long) (vg_replace_malloc.c:485) ==176304== by 0x10AC50: main (in /tmp/msgpack-c/example/test) ==176304== ==176304== Invalid free() / delete / delete[] / realloc() ==176304== at 0x484C93D: operator delete(void*, unsigned long) (vg_replace_malloc.c:1103) ==176304== by 0x10AA7F: main (in /tmp/msgpack-c/example/test) ==176304== Address 0x4e0b100 is 0 bytes inside a block of size 24 free'd ==176304== at 0x484C93D: operator delete(void*, unsigned long) (vg_replace_malloc.c:1103) ==176304== by 0x10AA07: main (in /tmp/msgpack-c/example/test) ==176304== Block was alloc'd at ==176304== at 0x4848F95: operator new(unsigned long) (vg_replace_malloc.c:485) ==176304== by 0x10AC50: main (in /tmp/msgpack-c/example/test) ==176304== "Log message ... 2" ==176304== Invalid read of size 1 ==176304== at 0x10B515: msgpack::v1::object_stringize_visitor::visit_str(char const*, unsigned int) (in /tmp/msgpack-c/example/test) ==176304== by 0x10D3CE: void msgpack::v1::object_parser::parseExpected behavior It should not crash.