boskee / Minecraft

Simple Minecraft-inspired program using Python and Pyglet
MIT License
207 stars 33 forks source link

Segmentation Fault on Ubuntu #78

Closed travcunn closed 5 years ago

travcunn commented 11 years ago

After the main menu, I get a segmentation fault on Ubuntu. Other times when I do it, I get the following error:

Traceback (most recent call last):
File "main.py", line 159, in <module>
main(options)
File "main.py", line 133, in main
pyglet.app.run()
File "/usr/local/lib/python2.7/dist-packages/pyglet/app/__init__.py", line 264, in run
EventLoop().run()
File "/usr/local/lib/python2.7/dist-packages/pyglet/app/xlib.py", line 82, in run
window.dispatch_platform_event(e)
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/__init__.py", line 1169, in dispatch_platform_event
event_handler(e)
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/__init__.py", line 1438, in _event_button
x, y, button, modifiers)
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/__init__.py", line 1219, in dispatch_event
EventDispatcher.dispatch_event(self, *args)
File "/usr/local/lib/python2.7/dist-packages/pyglet/event.py", line 340, in dispatch_event
if handler(*args):
File "/home/travis/Minecraft/views.py", line 56, in on_mouse_press
self.dispatch_event('on_mouse_click', x, y, button, modifiers)
File "/usr/local/lib/python2.7/dist-packages/pyglet/event.py", line 340, in dispatch_event
if handler(*args):
File "/home/travis/Minecraft/gui.py", line 139, in on_mouse_click
self.dispatch_event('on_click')
File "/usr/local/lib/python2.7/dist-packages/pyglet/event.py", line 340, in dispatch_event
if handler(*args):
File "/home/travis/Minecraft/views.py", line 291, in launch_server
localip = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][0]
IndexError: list index out of range
AL lib: ReleaseALC: 1 device not closed
Jimx- commented 11 years ago

I got this problem when I was starting a server too, it seems that socket.gethostbyname_ex(socket.gethostname())[2]only contains "127.0.0.1" on Ubuntu. But if you play singleplayer game it will directly connect to 127.0.0.1 without any problem. I guess we should find another way to get all the ips of the host correctly.