Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Program crashes with packet & selector usage  (Read 4477 times)

0 Members and 1 Guest are viewing this topic.

Lorizean

  • Newbie
  • *
  • Posts: 14
    • View Profile
Program crashes with packet & selector usage
« on: December 27, 2010, 04:46:32 pm »
Hello,

I'm totally new at using SFML, so I really don't know what could be wrong here.

First of all, I'm using SFML 1.6 on Ubuntu 10.04 lucid with Code::Blocks 10.05 and g++ 4.4.3.

When receiving Packets, I get Segmentation faults and the program crashes (This happens even with the example packet code from the tutorial).
I worked around this by not sending the packets but raw data, using the GetData(),GetDataSize() commands and then Append()-ing the data on receiving.

I also get crashes with calls to std::bad_alloc when using Selector.Add(); again, this also happens in the example code from the selector tutorial.

I'd be grateful if anybody could help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Program crashes with packet & selector usage
« Reply #1 on: December 27, 2010, 04:55:31 pm »
Could you please run the debugger and show me the line of the crash as well as the call stack?
Laurent Gomila - SFML developer

Lorizean

  • Newbie
  • *
  • Posts: 14
    • View Profile
Program crashes with packet & selector usage
« Reply #2 on: December 27, 2010, 05:19:34 pm »
Never used gdb before, but here we go.
All I'm getting is:
Code: [Select]

terminate called after throwing an instance of 'std::bad_alloc'
  what(): std::bad_alloc

Program received signal SIGABRT, Aborted.
0x0012d422 in __kernel_vsyscall ()

The line is line 72 in network-selector.cpp
Code: [Select]

Selector.Add(Listener);


Is this what you needed?

*edit*
ran a backtrace too:
Code: [Select]

#0  0x0012d422 in __kernel_vsyscall ()
#1  0x002ac651 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0x002afa82 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0x0020652f in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#4  0x00204465 in ?? () from /usr/lib/libstdc++.so.6
#5  0x002044a2 in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0x002045e1 in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0x00204c5f in operator new(unsigned int) () from /usr/lib/libstdc++.so.6
#8  0x0804aedb in __gnu_cxx::new_allocator<char>::allocate (this=0xbffff370, __n=4294967295)
    at /usr/include/c++/4.4/ext/new_allocator.h:89
#9  0x0804a9ac in std::_Vector_base<char, std::allocator<char> >::_M_allocate (this=0xbffff370, __n=4294967295)
    at /usr/include/c++/4.4/bits/stl_vector.h:140
#10 0x0804a30a in _Vector_base (this=0xbffff370, __n=4294967295, __a=...) at /usr/include/c++/4.4/bits/stl_vector.h:113
#11 0x08049ed7 in vector (this=0xbffff370, __x=...) at /usr/include/c++/4.4/bits/stl_vector.h:242
#12 0x08049db4 in SocketTCP (this=0xbffff364) at /usr/local/include/SFML/Network/SocketTCP.hpp:46
#13 0x080498ae in DoServer (Port=2435) at main.cpp:72
#14 0x08049c33 in main () at main.cpp:136


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Program crashes with packet & selector usage
« Reply #3 on: December 27, 2010, 07:38:16 pm »
Looks like a stack corruption, which usually means that something is badly configured (when source code is obviously ok).

How did you install SFML? Is it from the SFML website, or from the Ubuntu package repository?
Laurent Gomila - SFML developer

Lorizean

  • Newbie
  • *
  • Posts: 14
    • View Profile
Program crashes with packet & selector usage
« Reply #4 on: December 27, 2010, 07:47:47 pm »
from the website, the repository only had 1.5.
I'd try the repository but my linux pc doesn't have internet atm (I'm using another laptop right now)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Program crashes with packet & selector usage
« Reply #5 on: December 27, 2010, 07:57:45 pm »
Is it a 64-bits Ubuntu? If so, you may have to recompile SFML yourself. The version from the repositories should work as well.
Laurent Gomila - SFML developer

Lorizean

  • Newbie
  • *
  • Posts: 14
    • View Profile
Program crashes with packet & selector usage
« Reply #6 on: December 27, 2010, 07:58:24 pm »
nope, 32bits
I'll try to install 1.5 from the website and then from the repositories once i get internet again. I'll report back with results.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Program crashes with packet & selector usage
« Reply #7 on: December 27, 2010, 08:03:13 pm »
Arg :lol:

Ok, so let's wait and see if 1.5 works.
Laurent Gomila - SFML developer

Lorizean

  • Newbie
  • *
  • Posts: 14
    • View Profile
Program crashes with packet & selector usage
« Reply #8 on: December 27, 2010, 11:48:03 pm »
Well, that was stupid. It seems I had sfml 1.5 from the ubuntu repository installed via aptitude and, separately, sfml-1.6 compiled from source. somehow that led to conflicts, I randomly checked aptitude and saw 1.5 under installed so I deleted it and now it works like a charm.
Thanks for the fast responses btw.