Closed ping-localhost closed 1 year ago
I've already updated all Go dependencies, removed the go cache, reinstalled ImageMagick via homebrew, all to no avail. 😅
Seems to be an issue with the latest version, as I've just downgraded to ImageMagick 7.1.0-37 (by building from source) and that works just fine. No idea how/where to report this issue though.
Does it segfault because you haven't first initialized the ImageMagick C library as per the example?
func main() {
imagick.Initialize()
imagick.NewMagickWand()
}
If that is the cause, I agree it would be nice if the constructor functions checked that you have called Initialize before calling into the C API to produce an error instead of a seg fault.
Interesting, the imagick.Initialize()
does resolve my issue. How odd that it worked fine on an older version, must have been undefined behaviour. Either way, totally my own fault. Thank you @justinfx
It would be nice if a clear error was returned, even if it was a panic, as the seg fault is quite unclear.
Yea it would be undefined if nothing is checking ahead of time. The segfault is from the C library. So the behaviour was entirely dependant on what that does. We do have some internal counters so I would think we could add check on the Go bindings side to panic with a clear message first.
Strangely, when I try to reproduce this using the same ImageMagick7 version, I don't see it segfault. I'm on linux with gcc, so I don't know if it has to be even more specific to clang and/or macos and/or go 1.19
i have same issue
in my case, use go 1.18, macos m1 ,imagemagick/7.1.0-51,imagick.v3 v3.4.2
@ben-swit and it was because you had not initialized the library first?
@justinfx yeah before when i used lagacy version initialized in init() function so run test code not rise that error
but resent that rise error so i init test main then not rised i think go 1.19 (module 1.18 ) different run before version
Hmm. So If I understand correctly, you are saying that by calling Initialize()
it will prevent the crash from happening. This is expected and aligns with what would happen in the C ImageMagick library. I did try to reproduce it earlier, but was unable to. I can have another look. The only thing I can think to try and improve this situation is to put a check into every New*()
constructors to see if Initialize()
has been called. The problem though is we do not return an error from the constructors right now. So all we could do is turn the C segfault into a Go panic, which I don't know if you think would be an improvement.
Machine
Versions:
go env
.zshrc
Example file:
Resulting panic: