Page 1 of 1

[Genhis] [2.0.43] OSX only hang in mapgen code

Posted: Thu Apr 24, 2025 8:48 pm
by cliff_build
What did you do?
I played a multiplayer game with the Warp-Drive-Machine mod with some windows PCs and an OSX (M1/arm64) laptop.
What happened?
The OSX factorio instance hangs soon after landing on a new planet. The windows instances work just fine.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expected all clients to behave the same way (and ideally not hang).
Does it happen always, once, or sometimes?
I have a save that reproduces this problem (attached).

I did some amount of debugging attempts. When factorio is hung in this state, it is using 1 CPU worth of resources, and running commands like

Code: Select all

sudo sample 3236 10 -file /tmp/factorio_sample2.txt
gives output that includes the following (which implies to me that the game is busy doing some sort of map generation code). I don't know a lot about Warp Drive Machine, but this is just after the ship landed on a new alien-biomes planet. Notice that the sampled stacks do not have any lua code running that I can see.

I have not tried loading the save on linux, so I don't know whether it works there or not.

I am willing to do work to try and help debug, including changing the mod code. I'd love to at least have some understanding of what I should even be looking for though. I don't really understand what would cause infinite-map-generation.

Note that in the attached save, the game actually hangs a tiny bit after loading (maybe 30 ticks or something).

Code: Select all

    8360 Thread_37889358: MapGenerationHelper
      8360 thread_start  (in libsystem_pthread.dylib) + 8  [0x185cef0fc]
        8360 _pthread_start  (in libsystem_pthread.dylib) + 136  [0x185cf42e4]
          8360 std::__thread_proxy[abi:v160006]<std::tuple<std::unique_ptr<std::__thread_struct>, void (MapGenerationHelper::*)(), MapGenerationHelper*>>(void*)  (in factorio) + 72  [0x106c689f>
            8360 MapGenerationHelper::consumeTasks()  (in factorio) + 484  [0x106001f80]  MapGenerationHelper.cpp:153
              8360 EntityMapGenerationTask::compute()  (in factorio) + 52  [0x105fdfba4]  EntityMapGenerationTask.cpp:111
                8360 EntityMapGenerationTask::computeInternal()  (in factorio) + 104  [0x105fdfc70]  EntityMapGenerationTask.cpp:134
                  8357 Noise::multioctaveNoise(float, float, unsigned int, unsigned int, float, float, float, float, float, NoiseScratch&, float*) const  (in factorio) + 332  [0x1060f5e84]  Noi>
                  ! 3516 Noise::noise(float, float, unsigned int, unsigned int, float, float, float, NoiseScratch&, float*) const  (in factorio) + 900,904,...  [0x1060f57bc,0x1060f57c0,...]  No>
                  ! 2044 Noise::noise(float, float, unsigned int, unsigned int, float, float, float, NoiseScratch&, float*) const  (in factorio) + 864,836,...  [0x1060f5798,0x1060f577c,...]  No>
                  ! 969 Noise::noise(float, float, unsigned int, unsigned int, float, float, float, NoiseScratch&, float*) const  (in factorio) + 888,884,...  [0x1060f57b0,0x1060f57ac,...]  Noi>

Re: [Strangepan] [2.0.43] OSX only hang in mapgen code

Posted: Fri May 09, 2025 2:47 pm
by StrangePan
Hi, is this the correct save? It doesn't seem to have any of the mods that are listed in your log file.

Re: [Strangepan] [2.0.43] OSX only hang in mapgen code

Posted: Sat May 10, 2025 2:08 am
by cliff_build
I'm so sorry, it was not the correct save. This is the correct one.

Re: [Genhis] [2.0.43] OSX only hang in mapgen code

Posted: Mon May 12, 2025 11:54 am
by StrangePan
No problem! We were able to reproduce the issue with the new save you sent us.

Re: [Genhis] [2.0.43] OSX only hang in mapgen code

Posted: Mon May 12, 2025 2:44 pm
by Genhis
Thanks, the save file helped! The problem in map generation was caused by undefined behavior when casting infinity (float) to unsigned integer. For 2.0.49, I added more checks around this place and it will throw an exception if `MultioctaveNoise::octaves` is negative or infinite. Old saves will get a migration, but the mod author will have to fix map generation on their end. Most likely it's a division by zero somewhere in noise expressions which causes the octaves value to be infinite.

Re: [Genhis] [2.0.43] OSX only hang in mapgen code

Posted: Tue May 13, 2025 12:43 am
by cliff_build
Thank you!

Re: [Genhis] [2.0.43] OSX only hang in mapgen code

Posted: Tue May 13, 2025 11:35 pm
by FerrariMAF
Hi there @Genhis. The the new version is now raising the error, but I'm debugging and not finding the cause of the issue... its a map_gen_setting..
I have no idea what MultioctaveNoise::octaves are... =(

In my tests, the issue is on the map_gen_setting used to create a new surface... I made a console command with the mapgen used, and the error show up on the console...(file attached) Can you help me to find out what is wrong with this mapgen? it uses space age and alien biomes mod...
multioctaveerror.lua
(49.52 KiB) Downloaded 43 times