Open GoogleCodeExporter opened 9 years ago
Thank you so much for your wonderful json library. We need a cross-platform
json library. So far, rapidjson works fine on Redhat/Solaris/AIX in our
project. Still we need to implement it on HP-UX, both IA64 and PA 64. Please
give any clue for this issue. Many thanks.
Original comment by zro...@gmail.com
on 15 Sep 2014 at 9:38
Hi.
Can you download a snapshot from https://github.com/miloyip/rapidjson and take
a try?
Original comment by milo...@gmail.com
on 15 Sep 2014 at 10:12
Hi,
Thank you so much for your quick response. I tried the snapshot from
https://github.com/miloyip/rapidjson first. But I found there are quite some
errors and warning on redhat(GCC 3.2.3). I guessed there are some new features
in C++ which are used in rapidjson 2.0 and the old GCC(3.2.3) doesn't support
them. So I chose rapidjson 1.1 instead.
Anyway, I found the root cause for invalid address alignment on hp-ux today.
1. sizeof(ChunkHeader)==12. It causes that variable buffer in function Malloc
is not aligning to 8. And it is not allowed to access an int64 at such an
address on hp-ux.
*** temporary fix on hp-ux:
struct ChunkHeader {
size_t capacity; //!< Capacity of the chunk in bytes (excluding the header itself).
size_t size; //!< Current size of allocated memory in bytes.
ChunkHeader *next; //!< Next chunk in the linked list.
size_t padding; //rock: need one size_t for alignment
};
2. In function Malloc, size is aligned to 4 but not 8. It may also causes that
variable buffer in function Malloc is not aligning to 8.
** temporary fix on hp-ux
void* Malloc(size_t size) {
size = (size + 7) & ~7; // Force aligning size to 8
if (chunkHead_->size + size > chunkHead_->capacity)
AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);
char *buffer = (char *)(chunkHead_ + 1) + chunkHead_->size;
RAPIDJSON_ASSERT(((uintptr_t)buffer & 7) == 0); // returned buffer is aligned to 8
chunkHead_->size += size;
return buffer;
}
I am not sure whether the fix is complete and won't cause other errors. But it
is now working fine on hp-ux. Are there any official fix for this issue or the
new version has already done with it?
Thanks again!
Original comment by zro...@gmail.com
on 16 Sep 2014 at 10:25
Thank you for your feedback.
I will check whether the Github versions need such modification (maybe via
macros) but the version in code.google.com shall not be updated.
I will also check whether it is possible to be compatible with older gcc
version (you may help on this as well).
Original comment by milo...@gmail.com
on 17 Sep 2014 at 10:29
Thank you so much! It would be my pleasure if anything I can help.
Original comment by zro...@gmail.com
on 17 Sep 2014 at 2:53
Original issue reported on code.google.com by
zro...@gmail.com
on 15 Sep 2014 at 9:33