IDEA crashes when I use a plugin for generating code which calls a native Go library
Answered
I developed a plugin dependence on a Go library (build in c-shared mode). It work fine in sandbox, but after installed, it crash the IDEA when I click the "生成" ("Generate") button. And the Native library didn't print any log to idea.log (but print to terminal in sandbox environment).
I finally found the reason: big size byte array read from file cause the memory problem. But I can't confirm without log or dump file.
I put the plugin and source code in attachment and hope for help. My system is Mac OS Monterey 12.0.1, and the Go library was build in go 1.17.
- Upload id: 2022_05_20_UeKHXmzPMsFoY2pB (files: gormGenPlugin-1.0.zip, gorm_gen_plugin.zip)
- Upload id: 2022_05_20_DwRVy1uEeZeKUghb (file: idea-logs-20220519-2032483452445316971280452.zip)
Please sign in to leave a comment.
Hi,
Please provide us with more details.
Is this plugin developed for GoLand? Is the crashing code executed in some extension point? If yes, then please clarify where exactly it crashes.
https://github.com/zhaozhihom/gogenfuncThis is the repo build the libgormgen.dylib
github.com/zhaozhihom/gen@v0.1.0/generator.go:493
If the content size more than 2kb(maybe more, I didn't test), the VM crash.
Yes, it was developed for goland, and it crashed in goland the same performance.
Hello,
I've tried to reproduce it with your version of the plugin in #GO-221.5591.52, built on May 10, 2022 to no avail.
Could you please share a code snippet on where you invoked Generate action?
OK,Actually I use jna to call the function of go library(here https://github.com/zhaozhihom/gogenfunc) , below is the code snippet
I have provided the source code in the attachment. The purpose of this code is to get the db connect message(url, username, password), and generate models and CRUD code from tables. You can install the plugin I provided above, and try it. The position of the Action is Tools|Gorm Generator:
Create a new connection:
Choose tables and click "Generate":
The crash happened in this step. What confused me is the plugin worked normally in sandbox.
Reproduced, it looks like a memory issue. You may reproduce the problem in the sandbox by using the latest version of GoLand/IntelliJ IDEA. I see that currently, you are using 2021.2 instead of 2022.1.1.
This is my project SDK config, it is 2022.1. Is there something wrong...
Are you using the Run Plugin Gradle configuration or not? It uses the 2021 version of IntelliJ IDEA.
I upgrade the intellij version to 2022.1.1. It still dosen't reproduce in sandbox.
Is there a test data that I could use to fill in fields for a remote connection to a database? I was able to reproduce it once on the database connection pop-up, but no way to do it again with the same steps.
By the way, you can also enable Internal Mode in GoLand to see stacktraces in the same way as in sandbox: https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
<credentials>
This is my test db.
A question: I have enabled Internal Mode and see the "Internal Actions". How can I see the stacktraces?
Does it have any progress? I don't know how to see stacktraces.
Please try to start GoLand from CLI to see if it produces a bit more details: https://intellij-support.jetbrains.com/hc/en-us/articles/360011901879
Yes, it worked if started from CLI, and print the log I expected. But it dosen't work if I start it from tool-box. What is the reason could be?
Maybe I can share the screen,it will be more efficient.
Do you mean that there are no logs with crashes or plugin works as expected if you've started GoLand from CLI?
You can upload a small screencast to https://uploads.jetbrains.com/ and provide its ID.
From Cli: work, not crash and get logs
Form ToolBox: not work,crash without logs
I suspect that the reason could be in the environment – GoLand inherits all environments from Terminal, but it doesn't do the same thing for Toolbox App.
Can you upload a screencast to https://uploads.jetbrains.com/ and provide its ID (with/without crash)?
I print all environment variables of both way, toolbox lack of some variables, which could be the reason?
From Terminal:
Yes, that could be the reason, especially if your application operates with some variables.
How can I add variables when start the goland or in runtime?
You can start Toolbox App via CLI and it should inherit environments variables from CLI to desktop applications: /Applications/JetBrains\ Toolbox.app/Contents/MacOS/jetbrains-toolbox