Tencent / rapidjson

A fast JSON parser/generator for C++ with both SAX/DOM style API
http://rapidjson.org/
Other
14.25k stars 3.53k forks source link

Assertion failed writing large data #2061

Open xloem opened 2 years ago

xloem commented 2 years ago

I haven't narrowed this down yet, but I'm opening an issue because I don't see anything already present in the issues.

/usr/include/rapidjson/internal/stack.h:129: T* rapidjson::internal::Stack<Allocator>::PushUnsafe(std::size_t) [with T = char; Allocator = rapidjson::CrtAllocator; std::size_t = long unsigned int]: Assertion `stackTop_ + sizeof(T) * count <= stackEnd_' failed. 

from this code:

            static thread_local rapidjson::StringBuffer linebuf;
            static thread_local rapidjson::Writer<rapidjson::StringBuffer> lineout;
            linebuf.Clear();
            lineout.Reset(linebuf);
            lineout.StartObject();
            more_input.data = input.data + more_input.data;
            lineout.String("input", 5); lineout.String(more_input.data.data(), more_input.data.size());
            lineout.String("label", 5); lineout.String(output.data.data(), output.data.size());
            auto commit_id = commit->id();
            auto commit_string = commit_id.to_hex_string();
            lineout.String("commit", 6); lineout.String(commit_string.data(), commit_string.size());
            lineout.String("repo", 4); lineout.String(repo_entry->path.data(), repo_entry->path.size());
            lineout.EndObject();
            puts(linebuf.GetString());

The "more_input" string is likely many megabytes large, although I haven't inspected the data to know for sure.

I infer that I either need shorter strings or a custom allocator, but it would be nice to find information on what the details are.

v172744v commented 1 year ago

我也碰到了这个问题