Skip to content
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

json object's creation can freezes execution #231

Closed
cfoursan opened this issue Apr 7, 2016 · 11 comments
Closed

json object's creation can freezes execution #231

cfoursan opened this issue Apr 7, 2016 · 11 comments
Labels
kind: bug solution: invalid the issue is not related to the library

Comments

@cfoursan
Copy link

cfoursan commented Apr 7, 2016

When I try create json object and if no memory to allocate there is execution freeze instead of std::bad_alloc.

Gdb trace:
Thread 541 (Thread 0x7fc74f64a700 (LWP 133066)):
#0 0x000000000043cf71 in ZSt3getILm0EIPSt6vectorIN8nlohmann10basic_jsonISt3mapS0_SsblmdSaEESaIS4_EEZNS4_6createIS6_ISt16initializer_listIS4_EEEEPT_DpOT0_EUlS7_E_EENSt11__add_c_refINSt13tuple_elementIXT_ESt5tupleIIDpT0_EEE4typeEE4typeERKSM (__t=empty std::tuple) at /usr/include/c++/4.8/tuple:766
#1 0x000000000043cf9c in _ZNKSt10unique_ptrISt6vectorIN8nlohmann10basic_jsonISt3mapS0_SsblmdSaEESaIS4_EEZNS4_6createIS6_ISt16initializer_listIS4_EEEEPT_DpOT0_EUlPS6_E_E3getEv (this=0x7fc74f648ba0) at /usr/include/c++/4.8/bits/unique_ptr.h:234
#2 0x000000000043a1d1 in nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator>::create<std::vector<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator>, std::allocator<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> > >, std::initializer_list<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> > >(std::initializer_list<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> >&&) () at ../src/json.hpp:689
#3 0x0000000000437af4 in nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator>::basic_json (this=0x7fc74f648f30, init=..., type_deduction=true, manual_type=nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator>::array) at ../src/json.hpp:1571

@nlohmann
Copy link
Owner

nlohmann commented Apr 7, 2016

Hi @cfoursan, which OS and compiler are you using?

@cfoursan
Copy link
Author

cfoursan commented Apr 7, 2016

Hi. Sorry, forget about that information.
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Ubuntu 14.04.3 LTS, Trusty Tahr

@nlohmann
Copy link
Owner

nlohmann commented Apr 7, 2016

There are known issues with GCC 4.8's C++11 support (see https://github.com/nlohmann/json#supported-compilers). I am not sure whether this could be the reason for this issue, but could you try with a newer version?

@nlohmann
Copy link
Owner

Hi @cfoursan, could you please check again with the most recent could (branch "develop")?

@nlohmann nlohmann added the state: please discuss please discuss the issue or vote for your favorite option label Apr 29, 2016
@cfoursan
Copy link
Author

cfoursan commented May 5, 2016

Hi @nlohmann, I tried on
g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Ubuntu 15.10 (Wily Werewolf).

I got std::bad_alloc as expected. So version of GCC could be a reason of this issue.

@nlohmann
Copy link
Owner

I still cannot reproduce the error. Can you provide me with concrete code so I can try?

@nlohmann
Copy link
Owner

@cfoursan Can you provide me with concrete code so I can try?

@nlohmann
Copy link
Owner

Closed due to inactivity.

@cfoursan
Copy link
Author

I'm sorry for late answer. I tried to reproduce the bug on gcc 4.8. But with no success. That's why let this ticket be closed. If the bug will reproduce I'll let you know. Thanks for fast response!

@nlohmann
Copy link
Owner

Thanks for checking back. I'd love to get rid of all bugs, but you understand I need a way to reproduce it to debug. All the best!

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed state: please discuss please discuss the issue or vote for your favorite option labels Jun 19, 2016
@Pilipets
Copy link

Pilipets commented Jun 29, 2021

That's interesting, but I'm using MSVC v140 C++14, and the whole program freezes on this line AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...);

Inspecting the calling stack, I found out that it came from std::pair<iterator, bool> emplace(Args&& ... args)

        // transform null object into an object
        if (is_null())
        {
            m_type = value_t::object;
            m_value = value_t::object;
            assert_invariant();
        }

I can't provide the minimum repro example at this point as it freezes when calling from another thread and .dll...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

3 participants