Fatal error: concurrent map iteration and map write

I’m building locally. No problems. I’m building on netlify - it is causing a panic 50% of the time. Same code. Same variables. Any ideas?

10:14:03 AM: [09:14:03] Finished ‘build-prod’ after 37 s

10:14:04 AM: Building sites …

10:14:04 AM: fatal error: concurrent map iteration and map write

10:14:04 AM: goroutine 543 [running]:

10:14:04 AM: runtime.throw(0xea0a11, 0x26)

10:14:04 AM: /usr/local/go/src/runtime/panic.go:616 +0x81 fp=0xc420f165d0 sp=0xc420f165b0 pc=0x429f01

10:14:04 AM: runtime.mapiternext(0xc420d6d860)

10:14:04 AM: /usr/local/go/src/runtime/hashmap.go:747 +0x55c fp=0xc420f16660 sp=0xc420f165d0 pc=0x40877c

10:14:04 AM: reflect.mapiternext(0xc420d6d860)

Do you use a netlify.toml file? If so, post it here

Reason I ask is to confirm that the hugo version in your netlify.toml is the same version that you’re using locally. See:

I’m not using a netlify.toml - I am however setting the HUGO_VERSION in the env vars to 0.42. Interestingly the same error occurred when I went up to 0.49.2 - its really random. Kind of good to know I’m the only one… I’m thinking its something other than hugo doing this. I’ll keep digging.

Interesting. Are you setting any other env vars in Netlify? (Such as an env var for what command to run to build your site)

I’ll be honest… It’s not your standard site. A working version is here: https://servicefinder.acecentre.net I’m really not thinking this is a standard bug - more something we have created!

This is the build command

git submodule update --init --recursive && cd res/scripts && npm install && node ./fetch-ccg-geodata.js && cd ../../themes/hugo-acecentre-theme/ && npm install && npm install bower && ./node_modules/.bin/bower install && ./node_modules/.bin/gulp build-prod && cd ../../ && hugo

This the code… https://github.com/acecentre/nhs-service-finder

I’m sure its something rather stupid… Oh - and the env vars are in the screenshot attached

The above is by definition a bug in Hugo (or somewhere in Go). But it can be hard to identify/fix. As I have not seen this in a live site for years, and you say this happens with the latest Hugo, I suspect you must do “something special”. But it’s still a bug.

Can you post the full stack trace? I.e. is it more after “10:14:04 AM: reflect.mapiternext(0xc420d6d860)”?

"

Ahh… I always think its me!

Here is the full log https://gist.githubusercontent.com/willwade/bf1b3b445f887e1161ac775805fd1319/raw/67b729db9f57a20b64fa68a6b2dda0ff8afd2ce5/error-log.txt

I take back the “bug in Hugo” …

I’m pretty sure that it’s the .Scratch.Get "rawdata" that is the problem. Pulling in data from other pages via Scratch just does not work in a concurrent context.

1 Like

For once in my life I’m right! (Thanks @bep ! - I feel bad I made you look at that now… But its appreciated… )

1 Like

@bep Thanks for looking into the issue. Do you have any suggestion on how can one form an array of json like that?

Use append (Scratch.Add will also work) and jsonify. There are working examples floating around.

I did post a PR for this issue within nhs-service-finder hugo site. The problem was writing in the same key of a specific Scratch instance within loop of Pages. And the solution was to use a different name for each Page.
This issue may not be resolved with this change. Though i didn’t see it after the change.

@bep, would you mind explaining “concurrent context” further? I’m getting the same fatal error (a lot) and trying to debug.

Hi @AlanBreck
This topic is three years old and many things have changed since. Please have a read about Requesting Help and then start a new topic describing your issue.