Page 1 of 1

[0.12][cube] Headless server on Ubuntu crash

Posted: Fri Jul 17, 2015 10:13 pm
by montoyo
Hello!
First I would like to congratz the whole Factorio team for their awesome work! 0.12 is awesome! ;)
I was trying to install factorio on my ubuntu server (LTS 12.04.5). It works well and I can start the server; however, when I join with my Windows client, it crashes. Here's the log:

Code: Select all

   0.000 2015-07-17 23:49:28; Factorio 0.12.0 (Build 103, linux64)
   0.000 Operating system: Linux
   0.000 Read data path: /home/?/factorio/data
   0.000 Write data path: /home/?/factorio
   0.000 Binaries path: /home/?/factorio/bin
   0.012 Running in headless mode
   0.013 Loading mod core 0.0.0 (data.lua)
   0.015 Loading mod base 0.12.0 (data.lua)
   0.341 Factorio initialised
   0.342 Info Router.cpp:405: Router peerID(0) shutting down.
   0.342 Info Router.cpp:432: Router state -> Disconnected
   0.342 Info MultiplayerManager.cpp:848: networkTick(0) mapTick(-1) changing state from(Ready) to(PreparedToHostGame)
   0.342 Info MultiplayerManager.cpp:848: networkTick(0) mapTick(-1) changing state from(PreparedToHostGame) to(CreatingGame)
   0.342 Loading map /home/?/factorio/saves/?.zip
   0.356 Info Scenario.cpp:160: Map version 0.12.0-36
   0.382 Info PosixUDPSocket.cpp:32: Opening socket at port 34197
   0.382 Info Router.cpp:432: Router state -> Connected
   0.382 Info Synchronizer.cpp:55: NetworkTick(0) initialized Synchronizer local peer(0) latency(6).
   0.382 Hosting game at port 34197, peerID 0, session magic 3986
   0.382 Info MultiplayerManager.cpp:848: networkTick(0) mapTick(1274) changing state from(CreatingGame) to(InGame)
   0.382 Info NetworkInputHandler.cpp:40: mapTick(1274) networkTick(0) initialized NetworkInputHandler local peer(0).
   0.499 Info MultiplayerManager.cpp:1311: Received peer info for peer(0) username(<server>).
   0.499 Info MultiplayerManager.cpp:989: networkTick(6) mapTick(1274) received stateChanged peerID(0) oldState(Ready) newState(CreatingGame)
   0.499 Info MultiplayerManager.cpp:989: networkTick(6) mapTick(1274) received stateChanged peerID(0) oldState(CreatingGame) newState(InGame)
Factorio crashed. Generating symbolized stacktrace, please wait ...
  12.519 Warning Logger.cpp:315: Symbols.size() == 19, usedSize == 14
#0  0x5e7499 in CrashHandler::SignalHandler(int) at /tmp/factorio-tDqLaj/src/Util/CrashHandler.cpp:139
#1  0x7fe18fcee150 in ?? at ??:0
#2  0x7fe18fcee0d5 in ?? at ??:0
#3  0x7fe18fcf183b in ?? at ??:0
#4  0xdfb2dd in __gnu_cxx::__verbose_terminate_handler() at ??:0
#5  0xd6dfb6 in __cxxabiv1::__terminate(void (*)()) at ??:0
#6  0xd6e001 in std::terminate() at ??:0
#7  0xd6fdd8 in __cxa_throw at ??:0
#8  0x8a3910 in isIPv4 at /tmp/factorio-tDqLaj/src/Net/PosixUDPSocket.cpp:316
#9  0x8a3fc0 in _ZN21PosixUDPSocketAddressC4ERKSst at /tmp/factorio-tDqLaj/src/Net/PosixUDPSocket.cpp:241
#10 0x8a4c8c in _ZN21PosixUDPSocketAddressC4ER12Deserialiser at /tmp/factorio-tDqLaj/src/Net/PosixUDPSocket.cpp:263
#11 0xcf564f in load at /tmp/factorio-tDqLaj/src/Util/Deserialiser.hpp:24
#12 0x7fe19183fe9a in operator>><PosixUDPSocketAddress> at /tmp/factorio-tDqLaj/src/Util/Deserialiser.hpp:110
#13 0x7fe18fdac31d in _ZN24ConnectionRequestMessageC4ER12Deserialiser at /tmp/factorio-tDqLaj/src/Net/NetworkMessages.cpp:37
  12.974 Warning Logger.cpp:315: Symbols.size() == 18, usedSize == 13
  12.974 Error Util.cpp:45: Unexpected error occurred. You can help us to solve the problem by posting the contents of the log file on the Factorio forums.
Someone had the same problem (See the first answer of NoPantsMcDance) there https://forums.factorio.com/forum/vie ... =7&t=13536 but there's something in the console which does not show up in the logs:

Code: Select all

terminate called after throwing an instance of 'UserError'
  what():  network.invalid-address("SERVER_IP:34197", "Name or service not known")
(I replaced the real IPv4 by SERVER_IP)

I'm not quite sure, but I think it's an IPv4/IPv6 problem...
Thanks in advance for your help!

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 12:40 am
by ashein
Thanks for the big update, guys.

I can confirm the issue with "name or service not known" (the second error type as per OP). I'm running a Debian 7 Wheezy headless machine. Apart from the xrandr dependency I didn't have at first everything started fine until I tried to connect. The network is internal as can be seen from the log, no firewalls, no fancy iptables or whatnots.

My redundant log is below.
Console output

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 2:44 am
by montoyo
Just found a solution. I was right, it's an IPv4 problem.

To the factorio developpers:
I'm pretty sure you know what's happening, but just in case: In the hints passed to getaddrinfo, you have set ai_family to AF_INET6 so it wont work with IPv4 addresses. I'm not quite sure but I think that you can use AF_UNSPEC so that it'll work fine with both IPv4 and IPv6.

To the one who don't want to wait for an official fix:
Thanks to the Factorio team who didn't remove debugging symbols (you guys, are amazing ;) ), I've found a fix for the 64 bits linux version.
Auto patcher
I wrote an auto patcher; enter the following commands to run it:
Source code
Manual patch
You have to know how to use a hex editor:
  • Open your favorite hex editor
  • Open bin/x64/factorio
  • Go to 4A3581
  • This is what you should find there: C7 84 24 94 00 00 00 0A
  • If you don't find this, then you're not using factorio 0.12.0 for x64 linux, abort.
  • Replace by this: C7 84 24 94 00 00 00 02
  • Save
  • You're done!
This replaced AF_INET6 (0x0A) by AF_INET (0x02) so it'll now only work with IPv4.

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 4:22 am
by NoPantsMcDance
Working on Ubuntu 14.04. Thanks man

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 7:30 am
by NoPantsMcDance
Tried to play with a friend on my server and I can connect but the instant he tries to connect the server freezes then drops his connection.

http://pastebin.com/07riMKtv

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 12:00 pm
by montoyo
Yup. This time the new peer's (client) log seems to be more interesting:

Code: Select all

   0.021 2015-07-18 13:51:04; Factorio 0.12.0 (Build 103, win64)
   0.021 Operating system: Windows 8 
   0.021 Read data path: F:/Program Files/Factorio/data
   0.021 Write data path: C:/Users/Nicolas/AppData/Roaming/Factorio
   0.021 Binaries path: F:/Program Files/Factorio/bin
   1.454 Initialised Direct3D: AMD Radeon HD 6900 Series; driver: aticfx64.dll 8.17.10.1395
   1.522 Graphics options: [FullScreen: true] [VSync: true] [UIScale: 100%] [MultiSampling: X 8] [Graphics quality: normal] [Video memory usage: all]
   1.687 Loading mod core 0.0.0 (data.lua)
   1.692 Loading mod base 0.12.0 (data.lua)
   3.475 Initial atlas bitmap size is 16384
   3.478 Created atlas bitmap 16384x7658
  26.570 Info Updater.cpp:720: Downloading https://www.factorio.com/updater/get-available-versions?username=Montoyo&token=<private>&apiVersion=2
  27.398 Authorization error (Invalid username or token.)
  27.510 Factorio initialised
  34.093 Info Updater.cpp:720: Downloading https://www.factorio.com/updater/get-token?username=Montoyo&apiVersion=2
  34.983 Info Updater.cpp:720: Downloading https://www.factorio.com/updater/get-available-versions?username=Montoyo&token=<private>&apiVersion=2
  35.643 0 packages available to download (experimental updates enabled).
  45.390 Info Router.cpp:405: Router peerID(0) shutting down.
  45.391 Info Router.cpp:432: Router state -> Disconnected
  45.391 Joining game 62.210.125.206:34197 at port 34197
  45.391 Info WindowsUDPSocket.cpp:73: Opening socket at port (34197)
  45.391 Info Router.cpp:432: Router state -> Connecting
  45.401 Info MultiplayerManager.cpp:848: networkTick(0) mapTick(-1) changing state from(Ready) to(Connecting)
  45.577 Info Router.cpp:432: Router state -> WaitingForAccept
  45.811 Info Synchronizer.cpp:55: NetworkTick(87099) initialized Synchronizer local peer(2) latency(6).
  45.811 Info Synchronizer.cpp:491: networkTick(87099) adding peer(0) success(true).
  45.811 Info Synchronizer.cpp:491: networkTick(87099) adding peer(1) success(true).
  45.811 Info Router.cpp:432: Router state -> Connected
  45.811 Info Router.cpp:614: ConnectionAccepted ownPeerID(2) nextPeerID(3)
  45.811 Info MultiplayerManager.cpp:848: networkTick(87099) mapTick(-1) changing state from(Connecting) to(VerifyingConnection)
  47.461 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(100/600).
  47.461 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(100/600).
  47.461 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(100/600).
  47.461 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(100/600).
  49.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(200/600).
  49.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(200/600).
  49.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(200/600).
  49.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(200/600).
  50.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(300/600).
  50.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(300/600).
  50.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(300/600).
  50.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(300/600).
  52.465 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(400/600).
  52.465 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(400/600).
  52.465 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(400/600).
  52.465 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(400/600).
  54.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(500/600).
  54.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(500/600).
  54.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(500/600).
  54.127 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(500/600).
  55.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87093) from peer(1). Drop detection state(600/600).
  55.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87094) from peer(1). Drop detection state(600/600).
  55.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87095) from peer(1). Drop detection state(600/600).
  55.794 Info Synchronizer.cpp:455: NetworkTick(87099) Requesting heartbeat for networkTick(87096) from peer(1). Drop detection state(600/600).
  55.811 Error MultiplayerManager.cpp:107: MultiplayerManager failed: "Failed to establish connection with peer <MY_IPv4>:34197."
  55.815 Info MultiplayerManager.cpp:848: networkTick(87099) mapTick(-1) changing state from(VerifyingConnection) to(Failed)
  55.815 Info Synchronizer.cpp:585: NetworkTick(87099) peer(1) peerHeartbeatsEmpty(true) is not responding, dropping.
  63.911 Info MultiplayerManager.cpp:154: NetworkTick(87099) quitting multiplayer connection.
  63.911 Info MultiplayerManager.cpp:848: networkTick(87099) mapTick(-1) changing state from(Failed) to(Disconnected)
  63.911 Info Router.cpp:405: Router peerID(2) shutting down.
  63.912 Info WindowsUDPSocket.cpp:161: Socket closed
  63.912 Info Router.cpp:432: Router state -> Disconnected
  66.490 Goodbye
Plus this, which is frequently printed in the console (but not in the log):

Code: Select all

Warning Router.cpp:202: Parsed peerID(3) expected address (<my worldwide IPv4>:1024) doesn't match received address(<my router's local IPv4>:34197)
The server is running on a remote ubuntu machine in headless mode but the two clients I'm using are using the same router to access the remote machine; so maybe that's the problem...
Oh by the way, by "my router's local IPv4" I mean the 192.168.* IP of my gateway.

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 2:31 pm
by TheMax
Confirmed.

Second client from same source IP connects:
15149.811 Connection request from 87.xxx.xxx.xxx:34197
15149.812 Info Router.cpp:497: NetworkTick(903133) replying to connectionRequest for address( 87.xxx.xxx.xxx::34197).
15149.911 Info Router.cpp:648: networkTick(903139) adding peer(11) address(87.xxx.xxx.xxx::34197) sending connectionAccept(true)
15149.912 Info Router.cpp:520: networkTick(903139) sending connectionAccept to address(87.xxx.xxx.xxx::34197) connectionRequestID(11809) newPeerID(11)
15149.912 Info Synchronizer.cpp:491: networkTick(903139) adding peer(11) success(true).
15161.594 Info Synchronizer.cpp:455: NetworkTick(903145) Requesting heartbeat for networkTick(903139) from peer(11). Drop detection state(100/600).
15161.595 Info Synchronizer.cpp:455: NetworkTick(903145) Requesting heartbeat for networkTick(903140) from peer(11). Drop detection state(100/600).
...
15169.944 Info Synchronizer.cpp:585: NetworkTick(903145) peer(11) peerHeartbeatsEmpty(false) is not responding, dropping.

also Ubuntu 14.04

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 4:17 pm
by montoyo
So I did this:
Windows in Ubuntu VNC in Windows
And the same bug came up; this is not a linuxheadlessserver-only bug. When two players connects from the same IP, it doesn't work. Should I create a separate forum post for this bug?

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 4:44 pm
by TheMax
@Montoyo: I think that would be a good idea.

Re: [0.12] Headless server on Ubuntu crash

Posted: Sat Jul 18, 2015 6:36 pm
by montoyo

Re: [0.12][cube] Headless server on Ubuntu crash

Posted: Thu Jul 23, 2015 12:58 pm
by cube
Thanks for the report, this is now fixed for 0.12.1. The problem was caused by a bug in older versions of glibc ( https://fedoraproject.org/wiki/Networki ... networking ). As a workaround I've removed the use of the AI_ADDRCONFIG flag.

Re: [0.12][cube] Headless server on Ubuntu crash

Posted: Thu Jul 23, 2015 1:00 pm
by cube
Also, if you have used montoyo's patch, then automatic update will not work for you from 0.12.0. Either patch it back before updating or download the complete version.