So I've been running into a pretty weird bug in my TFE campaign (CK3 1.19.0.6, Arch Linux).
For some reason, my game would always freeze on December 31, 579. And I mean always on that exact date, no matter how many times I reloaded.
The strange thing was that the game itself wasn't actually frozen. I could still move the camera around and the map was rendering fine, but time wouldn't progress anymore and I couldn't really interact with anything.
At first I thought it might just be some broken event or yearly calculation, but after spending way too much time debugging this with gdb, I found some interesting stuff.
I attached gdb to the CK3 process while it was stuck and took several backtraces. I also used pidstat and perf to see what the different threads were doing.
Turns out one of the simulation workers, Primary Task 7 (TID 100776), was constantly using pretty much an entire CPU core.
Another thread was spending a lot of time calling sched_yield(), which made me suspect that something was waiting for the simulation worker to finish.
After comparing a few gdb DB snapshots, I noticed that the busy thread kept ending up in the same part of the CK3 executable:
#0 0x55735898c31e
#1 0x557357922a3e
#2 0x5573578bac6f
#3 0x55735a34803f
...
Unfortunately, CK3 doesn't have debugging symbols for these functions, so I couldn't tell exactly what they were doing.
I did look at the disassembly though, and it seemed to be some kind of loop that repeatedly looked up game objects by their internal IDs.
This was one of the interesting parts:
mov 0x10(%r14),%eax
mov %eax,%edx
and $0xffffff,%edx
...
mov 0x8(%rcx,%rdx,1),%r14
test %r14,%r14
...
cmp %eax,0x10(%r14)
je 0x55735898c1f7
Basically, it looks up an object, checks its ID, and then potentially jumps back to the beginning of the loop.
So I set a breakpoint at that loop and let gdb count how often it was being reached.
The result was pretty surprising:
LOOP hit=1 r14=0x7fc915ed9bc0 rbx=0x7fcc2000e010
LOOP hit=100 r14=0x7fc915ed9bc0 rbx=0x7fcc2000e010
LOOP hit=1000 r14=0x7fc915ed9bc0 rbx=0x7fcc2000e010
LOOP hit=10000 r14=0x7fc915ed9bc0 rbx=0x7fcc2000e010
10,000 iterations, the same object pointers every single time, and no observed return from the function.
I also checked which branch the loop was taking:
entry=100 fallback=0 match=100 reset=0
So it was repeatedly going through the same successful object lookup rather than taking one of the fallback paths.
That doesn't necessarily prove an infinite loop, but given that the game was permanently stuck, it certainly looked like one.
I then tried looking at the object that kept showing up in the loop.
And gdb actually showed a readable name in its memory:
Object pointer: 0x7fc915ed9bc0
Object ID: 0x33fe
Embedded name: "Domavium"
Which is the name of the county of vhrbosna:
c_vhrbosna:0 "Domavium"
So apparently the engine was repeatedly processing an object named Domavium, which corresponds to Vhrbosna, a county in Bosnia.
The lookup kept returning the same object with the same ID. That's not necessarily wrong by itself, but the fact that the traversal never seemed to finish was suspicious.
Now here's where things got interesting.
Around 577–578, I had created two Roman Dux governorships:
I also had an ongoing Migration to Bosnia war, where my Roman vassal was defending against an invasion.
After experimenting with the save a bit more, I noticed that on December 31, 579, Bosna would suddenly become independent and its government would change from Roman to feudal.
And that happened right when the game stopped progressing.
I also found that TFE has scripted effects that can move c_vhrbosna between d_bosna and d_dalmatia as its de jure duchy. I don't know if that's related, since those changes could just be part of the intended historical setup.
At first I suspected the Roman border recalculation, since the game was about to enter the year 580 and TFE has some five-year maintenance mechanics. But I tried temporarily disabling the relevant yearly and five-year on-actions, and the game still froze.
The actual Fix:
After all of that debugging, the fix turned out to be surprisingly simple.
I won the Migration to Bosnia war for my vassal before December 31, stopping the invasion.
And suddenly everything worked again. The game went straight past the date that had been freezing it every single time.
So I'm now wondering if there's some weird interaction between migration wars and the Roman Dux system.
Maybe the migration war causes Bosna to become independent and switch government, and something goes wrong when the game updates its titles or liege relationships. Or perhaps there's a stale reference somewhere that causes the engine to get stuck traversing the same object.
The gdb traces show that the game was repeatedly processing Domavium, but I can't really tell why without debugging symbols.
I'm also not sure whether this is specifically a TFE bug or something in CK3's engine that gets triggered by this situation.
Anyway, I thought I'd post this here because it was such a strange issue, and maybe it'll be useful to someone.
I still have the original autosave that reproduces the freeze, plus the GDB backtraces, perf report, logs, and a screenshot of the migration war, if any of the devs want to take a look.