dimanche 4 septembre 2016

Why does very simple `json-c` code crash on Windows 10 with Visual Studio 2015, but works in any other configuration?

I have following code:

int main(int argc, char *argv[])
{
        const char jsonInput[] = R"__({ "Object": "value" })__";
        unique_ptr<json_tokener, void(*)(struct json_tokener *)> tokener(json_tokener_new(), json_tokener_free);
        unique_ptr<json_object, int(*)(struct json_object *)> data(json_tokener_parse_ex(tokener.get(), jsonInput, 21), json_object_put);
        return 0;
}

It does almost nothing. It tries to parse the simpliest JSON object with json-c 0.12.99. It works good:

  1. On any Windows version when I compile it with Visual Studio 2013.
  2. On Linxu when I compile it with clang or gcc.
  3. On Windows 7 when I compile it with Visual Studio 2015.

But: it is guaranteed to crash when I compile it with Visual Studio 2015 and run on Windows 10. The stack trace follows:

check_bytes(const unsigned char * const first, const unsigned char value, const unsigned __int64 size) Line 194 C++

is_block_an_aligned_allocation(const void * const block) Line 252 C++

free_dbg_nolock(void * const block, const int block_use) Line 870 C++

_free_dbg(void * block, int block_use) Line 1011 C++

free(void * block) Line 20 C++

json_object_lh_entry_free(lh_entry * ent) Line 409 C++

lh_table_free(lh_table * t) Line 567 C++

json_object_object_delete(json_object * jso) Line 415 C++

json_object_put(json_object * jso) Line 188 C++

std::unique_ptr::~unique_ptr() Line 1397 C++

main(int argc, char * * argv) Line 47 C++

Does anyone know what is the reason of the crash?

Aucun commentaire:

Enregistrer un commentaire