You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears to be an issue in PutN in stream.h. It instantiates templates differently for PutReserve and PutUnsafe. This causes it to use use PutReserve from stream.h (which does nothing), then uses PutUnsafe from stringbuffer.h (which assumes PutReserve allocated space).
Contents of stream.h PutN which causes assertion:
//! Put N copies of a character to a stream.
template<typename Stream, typename Ch>
inline void PutN(Stream& stream, Ch c, size_t n) {
PutReserve<Stream>(stream, n);
for (size_t i = 0; i < n; i++)
PutUnsafe(stream, c);
}
Removing the template argument from PutReserve seems to resolve the issue, as it now uses PutReserve from stringbuffer.h.
Revised stream.h PutN which does not cause assertion:
//! Put N copies of a character to a stream.
template<typename Stream, typename Ch>
inline void PutN(Stream& stream, Ch c, size_t n) {
PutReserve(stream, n);
for (size_t i = 0; i < n; i++)
PutUnsafe(stream, c);
}
The text was updated successfully, but these errors were encountered:
It looks like I triggered this by using GenericStringBuffer<UTF8<>, MemoryPoolAllocator<> >. When used with a non-default allocator, PutN doesn't match the template specialization in stringbuffer.h, and falls back to the generic implementation in stream.h.
I am verifying my own fix for this, and will put up a pull request to add a failing test and fix the issue.
Fix inconsistent calling of template functions in PutN in stream.h. When
used with a GenericStringBuffer<<UTF8>, MemoryPoolAllocator>, PutN would call
PurReserve from stream.h, and PutUnsafe from stringbuffer.h. This
resulted in bytes being added to the buffer without allocating space.
This was not an issue when used with the default memory allocator,
because in this case the specialized PutN is used from stringbuffer.h.
Using PrettyWriter to output JSON I encounter an assert when PutN is used to indent the output.
I hit the same assert with both Visual C++ 2008 and GCC 4.7.
Assertion failed: stackTop_ + sizeof(T) * count <= stackEnd_, file d:\p4\thirdpartyexports\rapidjson\export\1.0\1.0.3a2\includes\rapidjson\internal/stack.h, line 129
It appears to be an issue in PutN in stream.h. It instantiates templates differently for PutReserve and PutUnsafe. This causes it to use use PutReserve from stream.h (which does nothing), then uses PutUnsafe from stringbuffer.h (which assumes PutReserve allocated space).
Contents of stream.h PutN which causes assertion:
Removing the template argument from PutReserve seems to resolve the issue, as it now uses PutReserve from stringbuffer.h.
Revised stream.h PutN which does not cause assertion:
The text was updated successfully, but these errors were encountered: