actionlint icon indicating copy to clipboard operation
actionlint copied to clipboard

Action lint fails occasionally - fatal error: concurrent map writes

Open zilinjak opened this issue 1 year ago • 4 comments

Hello, when using rhysd/actionlint:latest docker image to analyze workflows- https://hub.docker.com/r/rhysd/actionlint

The action sometimes fails out of nowhere without any reason. The log can be seen here

Thanks for any advices

zilinjak avatar Oct 26 '23 14:10 zilinjak

We notice the same issue and for whatever reason we've started to see it more often recently. Can reproduce this quite easily locally when running actionlint in context of a repo with several (14 in my case) GitHub workflows:

while true; do
	output=`actionlint -format '{{json .}}' 2>&1`
	if [[ $output == *"fatal error: concurrent map"* ]]; then
		echo "FATAL ERROR SEEN"
		break
	fi
done

It's a bug (accessing a non thread-safe container concurrently) in actionlint that merely happens when a custom error message format is provided through -format. The map being accessed concurrently is ErrorFormatter.rules (see here).

We've noticed at least the following race condition regarding this map when RegisterRule is called from multiple concurrent check functions calls.

I'm not sufficiently familiar with the codebase to propose a good solution. A naive solution would be to use a thread-safe map instead, but I can't properly judge the performance implications.

ReinAchten-TomTom avatar Oct 31 '23 13:10 ReinAchten-TomTom

@rhysd is this something you could look into or suggest how to best fix? I'm not proficient in golang, but can give it a try if you provide a hint. Thnx! :pray:

ReinAchten-TomTom avatar Nov 07 '23 12:11 ReinAchten-TomTom

Let me check this issue this weekend. I don't have enough time to handle all projects for now.

rhysd avatar Nov 07 '23 13:11 rhysd

I've run into this as well. Using an older version of actionlint in the meantime. Looking into the issue, it seems switching to sync.Map for the rules map may help?

noahnu avatar Dec 20 '23 21:12 noahnu

I apologize for the delay. I could fix this at d80a2a3. @ReinAchten-TomTom's comment was so helpful to fix this.

rhysd avatar Feb 16 '24 03:02 rhysd

@rhysd thanks a lot for addressing this problem! is there any plan to release a new tagged version soon? 🙏

maikelvdh avatar Feb 19 '24 14:02 maikelvdh