IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SL & STL C++ Discussion :

exception dans un string


Sujet :

SL & STL C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    19
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 19
    Par défaut exception dans un string
    Hello, dans le cadre du développement d'un serveur jeu j'utilise un serveur open-source nommé MaNGOS (http://getmangos.com/), avec sont client ( http://www.mangosclient.org/).

    Sauf que voila, le programme serveur en question s'arrête suite a une exception que je n'arrive pas a résoudre. J'ai un backtrace réaliser avec GDB. L'exception se produit très aléatoirement, la fonction peut se produire des milliers de fois sans erreur, c'est d'ailleurs sa que je ne comprend pas.

    backtrace :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 1115703648 (LWP 959)]
    0x00002ab2c0f6839d in free () from /lib/libc.so.6
    #0  0x00002ab2c0f6839d in free () from /lib/libc.so.6
    #1  0x00002ab2c0f6a16d in malloc () from /lib/libc.so.6
    #2  0x00002ab2c0b2893d in operator new () from /usr/lib/libstdc++.so.6
    #3  0x00002ab2c0b075d1 in std::string::_Rep::_S_create ()
       from /usr/lib/libstdc++.so.6
    #4  0x00002ab2c0b07f8b in std::string::_Rep::_M_clone ()
       from /usr/lib/libstdc++.so.6
    #5  0x00002ab2c0b08895 in std::string::reserve () from /usr/lib/libstdc++.so.6
    #6  0x000000000084b1cb in StrSplit (src=@0x42803e50, sep=@0x42803e40)
        at /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/basic_string.h:858
    #7  0x000000000062677b in Object::LoadValues (this=0x2aaadfc2be70, 
        data=0x2aaac74a5080 "44489 0 25 0 1065353216 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1290 92 250 0 0 100 0 0 0 92 250 1000 0 100 0 0 1000 1076691335 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1610 0 0 0 8 2048 4194304 1156415488 1157234688 11"...)
        at ../../../src/game/Object.cpp:787
    #8  0x0000000000688ca3 in Player::MinimalLoadFromDB (this=0x2aaadfc2be70, 
        result=0x2aaae56067f0, guid=44489) at ../../../src/game/Player.cpp:13846
    #9  0x00000000008184c8 in WorldSession::HandleCharEnum (this=0x2aaad24e2a70, 
        result=0x2aaae56067f0) at ../../../src/game/CharacterHandler.cpp:138
    #10 0x0000000000842e55 in SqlResultQueue::Update (this=0x13d1f00)
        at ../../../../src/shared/Database/SqlOperations.cpp:77
    #11 0x0000000000795bda in World::Update (this=0xb1a760, diff=92)
        at ../../../src/game/World.cpp:1614
    #12 0x00000000004fabe4 in WorldRunnable::run (this=<value optimized out>)
        at ../../../src/mangosd/WorldRunnable.cpp:65
    #13 0x00002ab2c0846371 in ZThread::ThreadImpl::dispatch (parent=0xaf6ba0, 
        impl=0x2aaab5f5fc70, task=@0x428041a0)
        at ../../../../dep/src/zthread/ThreadImpl.cxx:407
    #14 0x00002ab2c0848876 in ZThread::(anonymous namespace)::Launcher::run (
        this=0x7fffeaf7c5c0) at ../../../../dep/src/zthread/ThreadImpl.cxx:49
    #15 0x00002ab2c084c1ce in _dispatch (arg=0x9870ff0)
        at ../../../../dep/src/zthread/posix/ThreadOps.cxx:137
    #16 0x00002ab2c095ef1a in start_thread () from /lib/libpthread.so.0
    #17 0x00002ab2c0fc55d2 in clone () from /lib/libc.so.6
    #18 0x0000000000000000 in ?? ()
    #0  0x00002ab2c0f6839d in free () from /lib/libc.so.6
    No symbol table info available.
    #1  0x00002ab2c0f6a16d in malloc () from /lib/libc.so.6
    No symbol table info available.
    #2  0x00002ab2c0b2893d in operator new () from /usr/lib/libstdc++.so.6
    No symbol table info available.
    #3  0x00002ab2c0b075d1 in std::string::_Rep::_S_create ()
       from /usr/lib/libstdc++.so.6
    No symbol table info available.
    #4  0x00002ab2c0b07f8b in std::string::_Rep::_M_clone ()
       from /usr/lib/libstdc++.so.6
    No symbol table info available.
    #5  0x00002ab2c0b08895 in std::string::reserve () from /usr/lib/libstdc++.so.6
    No symbol table info available.
    #6  0x000000000084b1cb in StrSplit (src=@0x42803e50, sep=@0x42803e40)
        at /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/basic_string.h:858
        r = (
        std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > &) @0x42803e20: {<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
        _M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0xd409450, _M_finish = 0xd409588, 
          _M_end_of_storage = 0xd409650}}, <No data fields>}
        s = {static npos = 18446744073709551615, 
      _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x3f1ee28 "10766913"}}
    #7  0x000000000062677b in Object::LoadValues (this=0x2aaadfc2be70, 
        data=0x2aaac74a5080 "44489 0 25 0 1065353216 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1290 92 250 0 0 100 0 0 0 92 250 1000 0 100 0 0 1000 1076691335 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1610 0 0 0 8 2048 4194304 1156415488 1157234688 11"...)
        at ../../../src/game/Object.cpp:787
        tokens = {<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
        _M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0xd409450, _M_finish = 0xd409588, 
          _M_end_of_storage = 0xd409650}}, <No data fields>}
        index = <value optimized out>
    #8  0x0000000000688ca3 in Player::MinimalLoadFromDB (this=0x2aaadfc2be70, 
        result=0x2aaae56067f0, guid=44489) at ../../../src/game/Player.cpp:13846
        delete_result = false
        fields = (Field *) 0x2aaaec350bd8
    #9  0x00000000008184c8 in WorldSession::HandleCharEnum (this=0x2aaad24e2a70, 
        result=0x2aaae56067f0) at ../../../src/game/CharacterHandler.cpp:138
        guidlow = 44489
        plr = (class Player *) 0x2aaadfc2be70
        data = {<ByteBuffer> = {static DEFAULT_SIZE = 4096, _rpos = 0, 
        _wpos = 251, 
        _storage = {<std::_Vector_base<unsigned char,std::allocator<unsigned char> >> = {
            _M_impl = {<std::allocator<unsigned char>> = {<__gnu_cxx::new_allocator<unsigned char>> = {<No data fields>}, <No data fields>}, 
              _M_start = 0x2aaae35cecc0 "", _M_finish = 0x2aaae35cedbb "", 
              _M_end_of_storage = 0x2aaae35cee42 ""}}, <No data fields>}}, 
      m_opcode = 59}
        num = 1 '\001'
    #10 0x0000000000842e55 in SqlResultQueue::Update (this=0x13d1f00)
        at ../../../../src/shared/Database/SqlOperations.cpp:77
        callback = (class MaNGOS::IQueryCallback *) 0x2aaaeade7c20
    #11 0x0000000000795bda in World::Update (this=0xb1a760, diff=92)
        at ../../../src/game/World.cpp:1614
        next = {_M_cur = 0x54, _M_ht = 0x2ab2c084787e}
        autobroadcaston = 1
    #12 0x00000000004fabe4 in WorldRunnable::run (this=<value optimized out>)
        at ../../../src/mangosd/WorldRunnable.cpp:65
        diff = 92
        realCurrTime = 3125690303
        realPrevTime = <value optimized out>
        prevSleepTime = 84
    #13 0x00002ab2c0846371 in ZThread::ThreadImpl::dispatch (parent=0xaf6ba0, 
        impl=0x2aaab5f5fc70, task=@0x428041a0)
        at ../../../../dep/src/zthread/ThreadImpl.cxx:407
    No locals.
    #14 0x00002ab2c0848876 in ZThread::(anonymous namespace)::Launcher::run (
        this=0x7fffeaf7c5c0) at ../../../../dep/src/zthread/ThreadImpl.cxx:49
    No locals.
    #15 0x00002ab2c084c1ce in _dispatch (arg=0x9870ff0)
        at ../../../../dep/src/zthread/posix/ThreadOps.cxx:137
        __PRETTY_FUNCTION__ = "void* ZThread::_dispatch(void*)"
    #16 0x00002ab2c095ef1a in start_thread () from /lib/libpthread.so.0
    No symbol table info available.
    #17 0x00002ab2c0fc55d2 in clone () from /lib/libc.so.6
    No symbol table info available.
    #18 0x0000000000000000 in ?? ()
    No symbol table info available.
      13 Thread 1166059872 (LWP 970)  0x00002ab2c0fc59ac in epoll_wait ()
       from /lib/libc.so.6
      12 Thread 1157667168 (LWP 969)  0x00002ab2c0fc59ac in epoll_wait ()
       from /lib/libc.so.6
      11 Thread 1149274464 (LWP 968)  0x00002ab2c0fc59ac in epoll_wait ()
       from /lib/libc.so.6
      10 Thread 1140881760 (LWP 967)  0x00002ab2c0fc59ac in epoll_wait ()
       from /lib/libc.so.6
      9 Thread 1132489056 (LWP 966)  0x00002ab2c0961d2f in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
      8 Thread 1124096352 (LWP 965)  0x00002ab2c0961d2f in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
      7 Thread 1107310944 (LWP 964)  0x00002ab2c0f8ddf5 in nanosleep ()
       from /lib/libc.so.6
    * 6 Thread 1115703648 (LWP 959)  0x00002ab2c0f6839d in free ()
       from /lib/libc.so.6
      4 Thread 1098918240 (LWP 716)  0x00002ab2c0961d2f in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
      3 Thread 1090525536 (LWP 713)  0x00002ab2c0961d2f in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
      2 Thread 1082132832 (LWP 712)  0x00002ab2c0961d2f in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
      1 Thread 46947238967328 (LWP 703)  0x00002ab2c09600f5 in pthread_join ()
       from /lib/libpthread.so.0
    L'erreur se produirais quand un string se crée ? vraiment étrange.
    Lien du fichier : http://github.com/mangos/mangos/blob...hared/Util.cpp

    Fonction qui provoque l'erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    Tokens StrSplit(const std::string &src, const std::string &sep)
    {
        Tokens r;
        std::string s;
        for (std::string::const_iterator i = src.begin(); i != src.end(); i++)
        {
            if (sep.find(*i) != std::string::npos)
            {
                if (s.length()) r.push_back(s);
                s = "";
            }
            else
            {
                s += *i;
            }
        }
        if (s.length()) r.push_back(s);
        return r;
    }
    Voila voila, si quelqu'un pouvez se pencher sur mon probleme je lui serais très reconnaissant, car je ne vois pas en quoi la création d'un string pourrais faire cela Oo.

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2009
    Messages : 14
    Par défaut
    La création du string "s" ou du container de strings "r" en local ne
    pose aucun prb même si la fonction est statique. Ce n'est que
    l'effet visible du prb et non la source du prb.
    Peut-être que la string "src" ou la "sep" passées en paramètres
    sont détruites ou réaffectées(ce qui invalide l'itérateur "i") dans un
    autre thread? si c'est le cas, il faut les locker avant d'appeler ta
    fonction StrSplit pour en interdire la modif.

    Egalement, je constate que tu crées un Tokens sur la pile
    pour le renvoyer en retour ==> pas terrible au niveau perfs car il y a
    recopie. Il vaut mieux passer le container par référence.

    Bon courage!

Discussions similaires

  1. retour chariot dans un string
    Par bono dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 29/12/2003, 12h17
  2. Réponses: 2
    Dernier message: 28/08/2003, 00h00
  3. [Syntaxe] mettre des ' dans une string ?
    Par souch dans le forum Débuter
    Réponses: 4
    Dernier message: 14/08/2003, 16h26
  4. Recherche d'un String dans un String ?
    Par apen2k2 dans le forum Langage
    Réponses: 9
    Dernier message: 14/04/2003, 11h08
  5. Centrer un texte dans un string Grid
    Par christine dans le forum C++Builder
    Réponses: 5
    Dernier message: 22/10/2002, 22h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo