Protogen Goroutine stack exceeds

王林
Release: 2024-02-09 09:48:09
forward
821 people have browsed it

Protogen Goroutine 堆栈超过

php Xiaobian Yuzai today will introduce to you a problem related to Protogen: the situation when the Goroutine stack exceeds. When developing with Protogen, sometimes you will encounter an error message indicating that the Goroutine stack exceeds. The occurrence of this problem may cause program crashes or performance degradation. So, why does this problem occur and how to solve it? Next, we will answer them one by one.

Question content

Recently I encountered a code generation problem in golang. I have a huge raw file and now need to add logging to most of the messages using an external package. However, if I add logging for too many fields, it panics and says the goroutine stack is exceeded. Is there a way to generate code in chunks, or just increase the maximum cache size of generated goroutines?

I tried debug.SetMaxStack and running the build command with go code but nothing changed, it didn't seem like a good solution to me

Workaround

It turns out, The problem is, as @BurakSerdar said in the comment about the recursive print loop. So if you have something like:

message human {
  string name = 1;
  human child = 2;
  human parent = 3;
}
Copy after login

You shouldn’t do this:

message human {
  string name = 1;
  human child = 2 [(logger.field) = true];
  human parent = 3;
}
Copy after login

I believe the same goes for other customizations you want to add to fields, if you have a message that contains a field with the same message type

The above is the detailed content of Protogen Goroutine stack exceeds. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!