Repository navigation
Description
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
Activity
nlohmann commentedon Apr 7, 2016
Hi @cfoursan, which OS and compiler are you using?
cfoursan commentedon 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 commentedon 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 commentedon Apr 29, 2016
Hi @cfoursan, could you please check again with the most recent could (branch "develop")?
cfoursan commentedon 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 commentedon May 11, 2016
I still cannot reproduce the error. Can you provide me with concrete code so I can try?
nlohmann commentedon May 25, 2016
@cfoursan Can you provide me with concrete code so I can try?
nlohmann commentedon May 28, 2016
Closed due to inactivity.
cfoursan commentedon May 29, 2016
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 commentedon May 29, 2016
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!
Pilipets commentedon 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)I can't provide the minimum repro example at this point as it freezes when calling from another thread and
.dll...