Skip to content

Json::value constructed memory corruption #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dodng opened this issue Mar 3, 2017 · 3 comments
Closed

Json::value constructed memory corruption #585

dodng opened this issue Mar 3, 2017 · 3 comments

Comments

@dodng
Copy link

dodng commented Mar 3, 2017

(gdb) bt
#0  0xb775bc7c in __kernel_vsyscall ()
#1  0xb744b577 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xb744ccf3 in __GI_abort () at abort.c:89
#3  0xb748a953 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0xb758279c "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#4  0xb7490a7a in malloc_printerr (action=<optimized out>, str=0xb7582afc "malloc(): memory corruption (fast)", ptr=0xb0e034f0)
    at malloc.c:4996
#5  0xb7492c8f in _int_malloc (av=av@entry=0xb0e00010, bytes=bytes@entry=24) at malloc.c:3359
#6  0xb7493e38 in __GI___libc_malloc (bytes=24) at malloc.c:2891
#7  0xb767b2a4 in operator new(unsigned int) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#8  0x0807343a in __gnu_cxx::new_allocator<Json::Value>::allocate (this=0xb25f511c, __n=1) at /usr/include/c++/4.9/ext/new_allocator.h:104
#9  0x08072a7f in __gnu_cxx::__alloc_traits<std::allocator<Json::Value> >::allocate (__a=..., __n=1)
    at /usr/include/c++/4.9/ext/alloc_traits.h:182
#10 0x08071ff9 in std::_Vector_base<Json::Value, std::allocator<Json::Value> >::_M_allocate (this=0xb25f511c, __n=1)
    at /usr/include/c++/4.9/bits/stl_vector.h:170
#11 0x08071195 in std::vector<Json::Value, std::allocator<Json::Value> >::_M_insert_aux (this=0xb25f511c,
    __position=<error reading variable: Cannot access memory at address 0x0>, __x=...) at /usr/include/c++/4.9/bits/vector.tcc:353
#12 0x0807007e in std::vector<Json::Value, std::allocator<Json::Value> >::push_back (this=0xb25f511c, __x=...)
    at /usr/include/c++/4.9/bits/stl_vector.h:925
================================
(gdb) p errno
$1 = 4
================================

It just happen in multi data

@cdunn2001
Copy link
Contributor

Not sure. Maybe old version of the code? Maybe try a new compiler?

It just happen in multi data

Multithreaded? Jsoncpp is not thread-safe.

@dodng
Copy link
Author

dodng commented Mar 10, 2017

Hi,thanks your answer.It is not the jsoncpp problem,It is my code bug
(use std::sort ,when check equal value return true;)

By the way, Jsoncpp is not thread-safe ?
if the Function parameter is local parameter,Reader::parse is thread-safe?
image

image

@cdunn2001
Copy link
Contributor

Yes, but only the new Builders are thread-safe in that sense. The old parser uses one or two global variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants