calculate_payload_size causes a stack overflow in debug mode with very small stack #1143
-
|
The function Related: #1081 |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments
-
|
I dont understand how it could happen. Are you trying serialize a huge link list? |
Beta Was this translation helpful? Give feedback.
-
|
Could you show me your overflow stack? |
Beta Was this translation helpful? Give feedback.
-
struct node {
std::unique_ptr<node> n;
int value;
};Are you trying to serialize a huge link list like this (node count >= 10^4) ? |
Beta Was this translation helpful? Give feedback.
-
|
The entire MyAppProto struct is nearly 4,000 bytes in size and contains 48 struct members. |
Beta Was this translation helpful? Give feedback.
-
|
Are you sure this is all stack? I think the stack of struct_pack is not very huge. |
Beta Was this translation helpful? Give feedback.
-
|
I Try to create a huge struct but it still works well, struct |
Beta Was this translation helpful? Give feedback.
-
But these stack frames alone occupy 0x2af0 bytes. I'm running in debug mode( |
Beta Was this translation helpful? Give feedback.
-
10KB is small, normally a stack has 1MB+ space. |
Beta Was this translation helpful? Give feedback.
-
To restate: I'm running in a constrained thread-stack environment where the thread stack is limited to only 3 KB. |
Beta Was this translation helpful? Give feedback.
-
|
Does Release Mode works well?
|
Beta Was this translation helpful? Give feedback.
-
|
Yes — it works well in release mode ( |
Beta Was this translation helpful? Give feedback.
-
|
For meta programming grammer limit, struct_pack have to use a recursively way to calculate size. There has also many wrapper functions for meta programming which could be optimized. Those cause it stack overflow in very small stack. I afraid this problem is hard to resolve. |
Beta Was this translation helpful? Give feedback.
-
|
By the way, we use |
Beta Was this translation helpful? Give feedback.
-
I previously thought there were other ways to replace recursive calls to reduce stack usage.
|
Beta Was this translation helpful? Give feedback.
-
|
OK, so it seems that |
Beta Was this translation helpful? Give feedback.
OK, so it seems that
/O0 /d2Obforceinlineor/Od + /Ob1could fix your problem.