Skip to content

Commit 487201a

Browse files
sjanuarytobespc
authored andcommitted
Work around uint32_t stringstream problems in other plugins (#428)
* work around stringstream issueon Node 7 * work around uint32 stringstream problems in other plugins * work around uint32 stringstream problems in other plugins
1 parent c4f6fb3 commit 487201a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/plugins/node/env/nodeenvplugin.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,16 @@ static void GetNodeInformation(uv_async_t *async, int status) {
252252
contentss << "runtime.name=" << plugin::nodeName << '\n';
253253
}
254254

255-
contentss << "heap.size.limit=" << plugin::heapSizeLimit << '\n';
255+
// Cast the next 4 integers to uint64_t to work around a bug pushing uint32_t into stringstreams on Windows7/Node.js 7.7.3+
256+
contentss << "heap.size.limit=" << static_cast<uint64_t>(plugin::heapSizeLimit) << '\n';
256257
if (plugin::maxSemiSpaceSizeGuess > 0) {
257-
contentss << "max.semi.space.size=" << plugin::maxSemiSpaceSizeGuess << '\n';
258+
contentss << "max.semi.space.size=" << static_cast<uint64_t>(plugin::maxSemiSpaceSizeGuess) << '\n';
258259
}
259260
if (plugin::maxOldSpaceSizeGuess > 0) {
260-
contentss << "max.old.space.size=" << plugin::maxOldSpaceSizeGuess << '\n';
261+
contentss << "max.old.space.size=" << static_cast<uint64_t>(plugin::maxOldSpaceSizeGuess) << '\n';
261262
}
262263
if (plugin::maxHeapSizeGuess > 0) {
263-
contentss << "max.heap.size=" << plugin::maxHeapSizeGuess << '\n';
264+
contentss << "max.heap.size=" << static_cast<uint64_t>(plugin::maxHeapSizeGuess) << '\n';
264265
}
265266

266267

src/plugins/node/gc/nodegcplugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ void afterGC(GCType type, GCCallbackFlags flags) {
156156
contentss << "NodeGCData";
157157
contentss << "," << gcRealEnd;
158158
contentss << "," << gcType;
159-
contentss << "," << hs.total_heap_size();
160-
contentss << "," << hs.used_heap_size();
159+
contentss << "," << static_cast<uint64_t>(hs.total_heap_size());
160+
contentss << "," << static_cast<uint64_t>(hs.used_heap_size());
161161
contentss << "," << gcDuration;
162162
contentss << '\n';
163163

src/plugins/node/heap/nodeheapplugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ static void GetHeapInformation(uv_timer_s *data, int status) {
6868

6969
std::stringstream contentss;
7070
contentss << "NodeHeapData";
71-
contentss << "," << hs.total_heap_size();
72-
contentss << "," << hs.used_heap_size();
71+
contentss << "," << static_cast<uint64_t>(hs.total_heap_size());
72+
contentss << "," << static_cast<uint64_t>(hs.used_heap_size());
7373
contentss << '\n';
7474

7575
std::string content = contentss.str();

0 commit comments

Comments
 (0)