I got this on the chat log some time ago:
[advtrains] -!- train_ensure_init: Called with id = 224782 but a nil
2019-12-07 11:36:48: ACTION[Main]: [advtrains] -!- stack traceback:
[C]: in function 'xpcall'
/usr/share/games/minetest/builtin/game/register.lua:420: in function
[advtrains] -!- Train 224782 is not initialized! Couldn't check couples!
does this warning appear often, or only a single time? In theory, it
should go away after a server restart.
(it is caused by an inconsistency, where a train that doesn't exist
anymore is still registered in the occupation table.)
The message kept appearing until server crash.
But it did not reappear after the server restarted?
No, it didn't.
While writing the train copy tool, I had to implement the check for train
length so that it wouldn't end up with the end of the train off the rails.
If the back of the train ended up off the rails and into the terrain, I
would get a very similar "Train xxxxxx is not initialized! Couldn't check
couples!" message. This was with the JR-E231 train in a 3-car set with 2
control cars and a pantogrpah car.
I could enter the front control car and drive the train at 1 m/s forward
(this restriction is imposed when the train is off track in
trainlogic.lua). Trying to set ATC to full speed (Sneak+W) wouldn't work in
this state. The rear two wagons would be completely dark, and trying to
de-couple them would give the "Train not initialized! Couldn't check
couples!" error. I'm fairly sure trying to destroy the wagons directly,
since it checks if the wagon is coupled, would give the same error.
After a long time holding W, the train could escape onto the tracks. After
the train escaped, the other 2 carriages would be lit and their couples
would work properly without giving the error message, so I could then
destroy the train properly.
Suggested way to reproduce: Check out the copytrain branch (or master if it
is merged by the time you read this). Comment out the code in the paste
function that checks if the train would end up off-track. Place a train so
that the back goes off the end of the rails.