#27 Memory (heap) corruption with experimental internal ma

0.5.0
closed-wont-fix
Reader (16)
5
2015-03-06
2011-02-10
No

Memory is corrupted by json-cpp 0.5.0 in following configuration:
I used MSVC 2008.

# define JSON_VALUE_USE_INTERNAL_MAP 1
// # define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1

JSON_VALUE_USE_INTERNAL_MAP is necessary for me to make getMemberNames() return names sorted as in json data (see bug ID: 3014601)
Defining JSON_USE_SIMPLE_INTERNAL_ALLOCATOR to 1 removes problem.

Way to reproduce:
I took json data with simple structure, but long text valus (whole json size: 30K).
I parsed that json in a loop.
After parsing 130-150 times program crashes during occasional CRT heap check.

Discussion

  • Sergey Kolomenkin

    • priority: 5 --> 9
    • assigned_to: nobody --> blep
     
  • Sergey Kolomenkin

    • labels: --> Reader
     
  • Sergey Kolomenkin

    Here is a code that will crash in 2 seconds (less than 150 iterations of loop) (MSVC2008):

    const std::string sJason = "{\"x\":{\"d\":{\"t\":\"v\"},\"t1\":[\"v1\"],\"t2\":[\"a\",\"b\",\"c\"]}}";
    int cnt = 0;
    while(true)
    {
    cnt++;
    Json::Value root; // will contains the root value after parsing.
    Json::Reader reader;
    const bool parsingSuccessful = reader.parse(sJason, root);
    printf("try %d done!\n", cnt);
    }

    NOTE! don't forget about mode in config.h:
    # define JSON_VALUE_USE_INTERNAL_MAP 1
    //# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1

     
  • Sergey Kolomenkin

    P.S. The more internal arrays or objects we have in above sample, the less loop iterations are necessary to crash.

     
  • Baptiste Lepilleur

    I do not have time to study this isue. I suspect that there are many other issues with this container as it has no unit tests (at least we can now write some). This is the reason it is marked has experimental.

     
  • Baptiste Lepilleur

    • priority: 9 --> 5
    • summary: Memory (heap) corruption --> Memory (heap) corruption with experimental internal ma
     
  • Christopher Dunn

    • status: open --> open-postponed
     
  • Christopher Dunn

    Dropped from codebase. We might allow hashmap via configuration in the future.

     
  • Christopher Dunn

    • status: open-postponed --> closed-wont-fix
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks