A few months ago, I was writing a Go module for using
I ran into a problem
that appeared to be related to Go/cgo stack allocation. That turned out to be a
red herring (no offense to herrings of any color), and we now have a working Go
library for Rosie!
What was the actual problem?
I don’t know! It seems that the problem was in a memory access to a stack-allocated structure, though I have not had the time to investigate it further. Here’s what I know:
- The problem manifested when a Go program with one goroutine (main) that was
librosietriggered a garbage collection. It also appeared when creating an additional goroutine that called
- The error reported was from
- Forcing the main goroutine to stay on its initial OS thread made the problem go away.
At the time, in December 2017,
librosie was compiling with
-Wall and no
warnings, and was tested with
valgrind for any misuse of memory, with none
After some investigation and a variety of inconclusive experiments, I put the
problem on the back burner and continued with some refactoring of and minor
librosie. That’s when I accidentally solved the problem.
One day when I had some time to return to the problem, I found it had been
has a change to
caploop() which appears to contain the solution. This commit
replaced a set of simple macros used to manipulate a stack (in a C array) with a
set of functions that do the same thing.
Both the macros and the functions were run with
valgrind and no inappropriate
memory accesses were found. Yet, the version with the macros causes the Go
stack error, while the version with functions does not.
One day I will look further into this, because I would like to understand exactly what the issue was. If you have any insights or good guesses, please comment on Reddit.
The Go client for
With the Go stack issue resolved, we now have a working Go module for Rosie! It’s pretty simple right now, exposing most of Rosie’s functionality but lacking some convenience functions.
librosie Go library
may be found on Gitlab
along with a
that uses it. Additional functions for convenient use of
planned, as indicated by the comments in the file. Also, some new Rosie
features are not yet supported, like the ability to map pattern names to colors
for easy-to-read output for humans. We will add those soon.
If you are a Go programmer and want to contribute to
rosie.go, to make it more
usable or more Go-like, we welcome your input (especially pull requests)!
Discussion on reddit
Please post comments to the Rosie subreddit.