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

C++ Discussion :

Problème de compilation


Sujet :

C++

Vue hybride

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

    Informations forums :
    Inscription : Décembre 2009
    Messages : 37
    Par défaut Problème de compilation
    Bonjour à tous ,
    je travaille sur l'implémentation d'un protocole sous NS2 .
    en essayant de complier le code je trouve une erreur de segmentation , le débogage me donne ça :
    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
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    *** glibc detected *** /usr/local/bin/ns: double free or corruption (fasttop): 0x08e1aee8 ***
    ======= Backtrace: =========
    /lib/tls/i686/cmov/libc.so.6[0xb7c650d1]
    /lib/tls/i686/cmov/libc.so.6[0xb7c667d2]
    /lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xb7c698ad]
    /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb7e156f1]
    /usr/local/bin/ns(_ZN9__gnu_cxx13new_allocatorIiE10deallocateEPij+0x11)[0x838aca1]
    /usr/local/bin/ns(_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPij+0x25)[0x838a82d]
    /usr/local/bin/ns(_ZNSt6vectorIiSaIiEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPiS1_EERKi+0x1ed)[0x838a20d]
    /usr/local/bin/ns(_ZNSt6vectorIiSaIiEE9push_backERKi+0x71)[0x8389cc5]
    /usr/local/bin/ns(_ZN3Ant15send_bkwant_pktEP6Packet+0x284)[0x8388448]
    /usr/local/bin/ns(_ZN3Ant17recv_scoutant_pktEP6Packet+0xbf)[0x8387c29]
    /usr/local/bin/ns(_ZN3Ant12recv_ant_pktEP6Packet+0x3e)[0x8387b10]
    /usr/local/bin/ns(_ZN3Ant4recvEP6PacketP7Handler+0xe9)[0x8387ab7]
    /usr/local/bin/ns(_ZN9Connector4sendEP6PacketP7Handler+0x2c)[0x81bdf0c]
    /usr/local/bin/ns(_ZN8CMUTrace4recvEP6PacketP7Handler+0xb9)[0x82adcd7]
    /usr/local/bin/ns(_ZN10Classifier4recvEP6PacketP7Handler+0x55)[0x81c173f]
    /usr/local/bin/ns(_ZN10Classifier4recvEP6PacketP7Handler+0x55)[0x81c173f]
    /usr/local/bin/ns(_ZN8NsObject6handleEP5Event+0x27)[0x81b93eb]
    /usr/local/bin/ns(_ZN9Scheduler8dispatchEP5Eventd+0x95)[0x81b617b]
    /usr/local/bin/ns(_ZN9Scheduler3runEv+0x2c)[0x81b60ae]
    /usr/local/bin/ns(_ZN9Scheduler7commandEiPKPKc+0x6b)[0x81b625d]
    /usr/local/bin/ns(_ZN8TclClass12dispatch_cmdEPvP10Tcl_InterpiPPKc+0x32)[0x83e713a]
    /usr/local/bin/ns[0x83ecf87]
    /usr/local/bin/ns(TclInvokeStringCommand+0x6e)[0x83efa2e]
    /usr/local/bin/ns(TclEvalObjvInternal+0x35b)[0x83f173b]
    /usr/local/bin/ns[0x841dc8a]
    /usr/local/bin/ns(TclCompEvalObj+0xdd)[0x842225d]
    /usr/local/bin/ns[0x841db23]
    /usr/local/bin/ns(TclCompEvalObj+0xdd)[0x842225d]
    /usr/local/bin/ns(TclObjInterpProc+0x2a7)[0x844c487]
    /usr/local/bin/ns(TclProcInterpProc+0x80)[0x844c940]
    /usr/local/bin/ns[0x83ed1af]
    /usr/local/bin/ns(TclInvokeStringCommand+0x6e)[0x83efa2e]
    /usr/local/bin/ns(TclEvalObjvInternal+0x35b)[0x83f173b]
    /usr/local/bin/ns[0x841dc8a]
    /usr/local/bin/ns(TclCompEvalObj+0xdd)[0x842225d]
    /usr/local/bin/ns(TclObjInterpProc+0x2a7)[0x844c487]
    /usr/local/bin/ns(TclProcInterpProc+0x80)[0x844c940]
    /usr/local/bin/ns[0x83ecf87]
    /usr/local/bin/ns(TclInvokeStringCommand+0x6e)[0x83efa2e]
    /usr/local/bin/ns(TclEvalObjvInternal+0x35b)[0x83f173b]
    /usr/local/bin/ns(Tcl_EvalEx+0x4fc)[0x83f23dc]
    /usr/local/bin/ns(Tcl_FSEvalFile+0x243)[0x843b583]
    /usr/local/bin/ns(Tcl_Main+0x357)[0x843ec17]
    /usr/local/bin/ns(nslibmain+0x20)[0x83e6198]
    /usr/local/bin/ns(main+0x1b)[0x83e630b]
    /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7c10b56]
    /usr/local/bin/ns[0x81af881]
    ======= Memory map: ========
    08048000-0858d000 r-xp 00000000 08:11 45         /usr/local/bin/ns
    0858e000-0858f000 r--p 00545000 08:11 45         /usr/local/bin/ns
    0858f000-0862a000 rw-p 00546000 08:11 45         /usr/local/bin/ns
    0862a000-0953c000 rw-p 00000000 00:00 0          [heap]
    b7a00000-b7a21000 rw-p 00000000 00:00 0 
    b7a21000-b7b00000 ---p 00000000 00:00 0 
    b7b91000-b7bd0000 r--p 00000000 08:11 135713     /usr/lib/locale/fr_FR.utf8/LC_CTYPE
    b7bd0000-b7bd2000 rw-p 00000000 00:00 0 
    b7bd2000-b7bd6000 r-xp 00000000 08:11 4160       /usr/lib/libXdmcp.so.6.0.0
    b7bd6000-b7bd7000 rw-p 00003000 08:11 4160       /usr/lib/libXdmcp.so.6.0.0
    b7bd7000-b7bf3000 r-xp 00000000 08:11 5181       /usr/lib/libxcb.so.1.1.0
    b7bf3000-b7bf4000 r--p 0001c000 08:11 5181       /usr/lib/libxcb.so.1.1.0
    b7bf4000-b7bf5000 rw-p 0001d000 08:11 5181       /usr/lib/libxcb.so.1.1.0
    b7bf5000-b7bf7000 r-xp 00000000 08:11 4149       /usr/lib/libXau.so.6.0.0
    b7bf7000-b7bf8000 r--p 00001000 08:11 4149       /usr/lib/libXau.so.6.0.0
    b7bf8000-b7bf9000 rw-p 00002000 08:11 4149       /usr/lib/libXau.so.6.0.0
    b7bf9000-b7bfa000 rw-p 00000000 00:00 0 
    b7bfa000-b7d38000 r-xp 00000000 08:11 907        /lib/tls/i686/cmov/libc-2.10.1.so
    b7d38000-b7d39000 ---p 0013e000 08:11 907        /lib/tls/i686/cmov/libc-2.10.1.so
    b7d39000-b7d3b000 r--p 0013e000 08:11 907        /lib/tls/i686/cmov/libc-2.10.1.so
    b7d3b000-b7d3c000 rw-p 00140000 08:11 907        /lib/tls/i686/cmov/libc-2.10.1.so
    b7d3c000-b7d3f000 rw-p 00000000 00:00 0 
    b7d3f000-b7d5b000 r-xp 00000000 08:11 3515       /lib/libgcc_s.so.1
    b7d5b000-b7d5c000 r--p 0001b000 08:11 3515       /lib/libgcc_s.so.1
    b7d5c000-b7d5d000 rw-p 0001c000 08:11 3515       /lib/libgcc_s.so.1
    b7d5d000-b7e43000 r-xp 00000000 08:11 2396       /usr/lib/libstdc++.so.6.0.13
    b7e43000-b7e47000 r--p 000e6000 08:11 2396       /usr/lib/libstdc++.so.6.0.13
    b7e47000-b7e48000 rw-p 000ea000 08:11 2396       /usr/lib/libstdc++.so.6.0.13
    b7e48000-b7e4f000 rw-p 00000000 00:00 0 
    b7e4f000-b7e73000 r-xp 00000000 08:11 949        /lib/tls/i686/cmov/libm-2.10.1.so
    b7e73000-b7e74000 r--p 00023000 08:11 949        /lib/tls/i686/cmov/libm-2.10.1.so
    b7e74000-b7e75000 rw-p 00024000 08:11 949        /lib/tls/i686/cmov/libm-2.10.1.so
    b7e75000-b7e77000 r-xp 00000000 08:11 921        /lib/tls/i686/cmov/libdl-2.10.1.so
    b7e77000-b7e78000 r--p 00001000 08:11 921        /lib/tls/i686/cmov/libdl-2.10.1.so
    b7e78000-b7e79000 rw-p 00002000 08:11 921        /lib/tls/i686/cmov/libdl-2.10.1.so
    b7e79000-b7e8c000 r-xp 00000000 08:11 956        /lib/tls/i686/cmov/libnsl-2.10.1.so
    b7e8c000-b7e8d000 r--p 00012000 08:11 956        /lib/tls/i686/cmov/libnsl-2.10.1.so
    b7e8d000-b7e8e000 rw-p 00013000 08:11 956        /lib/tls/i686/cmov/libnsl-2.10.1.so
    b7e8e000-b7e91000 rw-p 00000000 00:00 0 
    b7e91000-b7fbb000 r-xp 00000000 08:11 4143       /usr/lib/libX11.so.6.2.0
    b7fbb000-b7fbc000 ---p 0012a000 08:11 4143       /usr/lib/libX11.so.6.2.0
    b7fbc000-b7fbd000 r--p 0012a000 08:11 4143       /usr/lib/libX11.so.6.2.0
    b7fbd000-b7fbf000 rw-p 0012b000 08:11 4143       /usr/lib/libX11.so.6.2.0
    b7fbf000-b7fc0000 rw-p 00000000 00:00 0 
    b7fc0000-b7fce000 r-xp 00000000 08:11 4162       /usr/lib/libXext.so.6.4.0
    b7fce000-b7fcf000 r--p 0000d000 08:11 4162       /usr/lib/libXext.so.6.4.0
    b7fcf000-b7fd0000 rw-p 0000e000 08:11 4162       /usr/lib/libXext.so.6.4.0
    b7fd8000-b7fd9000 rw-p 00000000 00:00 0 
    b7fd9000-b7fe0000 r--s 00000000 08:11 134424     /usr/lib/gconv/gconv-modules.cache
    b7fe0000-b7fe2000 rw-p 00000000 00:00 0 
    b7fe2000-b7fe3000 r-xp 00000000 00:00 0          [vdso]
    b7fe3000-b7ffe000 r-xp 00000000 08:11 90         /lib/ld-2.10.1.so
    b7ffe000-b7fff000 r--p 0001a000 08:11 90         /lib/ld-2.10.1.so
    b7fff000-b8000000 rw-p 0001b000 08:11 90         /lib/ld-2.10.1.so
    bffeb000-c0000000 rw-p 00000000 00:00 0          [stack]
     
    Program received signal SIGABRT, Aborted.
    0xb7fe2430 in __kernel_vsyscall ()
    (gdb) bt
    #0  0xb7fe2430 in __kernel_vsyscall ()
    #1  0xb7c244d1 in raise () from /lib/tls/i686/cmov/libc.so.6
    #2  0xb7c27932 in abort () from /lib/tls/i686/cmov/libc.so.6
    #3  0xb7c5afc5 in ?? () from /lib/tls/i686/cmov/libc.so.6
    #4  0xb7c650d1 in ?? () from /lib/tls/i686/cmov/libc.so.6
    #5  0xb7c667d2 in ?? () from /lib/tls/i686/cmov/libc.so.6
    #6  0xb7c698ad in free () from /lib/tls/i686/cmov/libc.so.6
    #7  0xb7e156f1 in operator delete(void*) () from /usr/lib/libstdc++.so.6
    #8  0x0838aca1 in __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned int) ()
    #9  0x0838a82d in std::_Vector_base<int, std::allocator<int> >::_M_deallocate(int*, unsigned int) ()
    #10 0x0838a20d in std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) ()
    #11 0x08389cc5 in std::vector<int, std::allocator<int> >::push_back(int const&) ()
    #12 0x08388448 in Ant::send_bkwant_pkt(Packet*) ()
    #13 0x08387c29 in Ant::recv_scoutant_pkt(Packet*) ()
    #14 0x08387b10 in Ant::recv_ant_pkt(Packet*) ()
    #15 0x08387ab7 in Ant::recv(Packet*, Handler*) ()
    #16 0x081bdf0c in Connector::send(Packet*, Handler*) ()
    #17 0x082adcd7 in CMUTrace::recv(Packet*, Handler*) ()
    #18 0x081c173f in Classifier::recv(Packet*, Handler*) ()
    #19 0x081c173f in Classifier::recv(Packet*, Handler*) ()
    #20 0x081b93eb in NsObject::handle(Event*) ()
    #21 0x081b617b in Scheduler::dispatch(Event*, double) ()
    #22 0x081b60ae in Scheduler::run() ()
    #23 0x081b625d in Scheduler::command(int, char const* const*) ()
    #24 0x083e713a in TclClass::dispatch_cmd(void*, Tcl_Interp*, int, char const**) ()
    #25 0x083ecf87 in OTclDispatch (cd=<value optimized out>, in=0x8636740, argc=-1073754932, argv=0xbfffd7b0) at otcl.c:434
    #26 0x083efa2e in TclInvokeStringCommand ()
    #27 0x083f173b in TclEvalObjvInternal ()
    #28 0x0841dc8a in TclExecuteByteCode ()
    #29 0x0842225d in TclCompEvalObj ()
    #30 0x0841db23 in TclExecuteByteCode ()
    #31 0x0842225d in TclCompEvalObj ()
    #32 0x0844c487 in TclObjInterpProc ()
    #33 0x0844c940 in TclProcInterpProc ()
    #34 0x083ed1af in OTclDispatch (cd=<value optimized out>, in=0x8636740, argc=2, argv=0xbfffe2d0) at otcl.c:477
    #35 0x083efa2e in TclInvokeStringCommand ()
    #36 0x083f173b in TclEvalObjvInternal ()
    #37 0x0841dc8a in TclExecuteByteCode ()
    #38 0x0842225d in TclCompEvalObj ()
    #39 0x0844c487 in TclObjInterpProc ()
    #40 0x0844c940 in TclProcInterpProc ()
    #41 0x083ecf87 in OTclDispatch (cd=<value optimized out>, in=0x8636740, argc=2, argv=0xbfffeb90) at otcl.c:434
    #42 0x083efa2e in TclInvokeStringCommand ()
    #43 0x083f173b in TclEvalObjvInternal ()
    #44 0x083f23dc in Tcl_EvalEx ()
    #45 0x0843b583 in Tcl_FSEvalFile ()
    #46 0x0843ec17 in Tcl_Main ()
    #47 0x083e6198 in nslibmain ()
    #48 0x083e630b in main ()
    (gdb)
    quelqu'un peut m'aider à figurer la source d'erreur .
    merci d'avance

  2. #2
    Membre expérimenté Avatar de Dalini71
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2008
    Messages
    181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2008
    Messages : 181
    Par défaut
    Apparemment tu libères une ressource qui l'a déjà été.

    Il parait qu'une bonne pratique est de mettre ton pointeur à 0 lorsque tu le libères.

  3. #3
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Salut,
    Citation Envoyé par Dalini71 Voir le message
    Il parait qu'une bonne pratique est de mettre ton pointeur à 0 lorsque tu le libères.
    Ca risque de ne faire que masquer un problème potentiellement plus grave. D'autant que le double delete peut peut être se faire sur la même adresse mais pas avec la même variable pointeur.

    @MounaR : faudra un peu plus de code source. Mais j'ai l'impression que le buffer de réception a été écrasé (écriture hors bornes)

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 37
    Par défaut
    le message affiché par le gdb indique le problème commence lors de l'exécusion de la méthode Ant::send_bkwant_pkt(Packet*) ()
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    #8  0x0838aca1 in __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned int) ()
    #9  0x0838a82d in std::_Vector_base<int, std::allocator<int> >::_M_deallocate(int*, unsigned int) ()
    #10 0x0838a20d in std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) ()
    #11 0x08389cc5 in std::vector<int, std::allocator<int> >::push_back(int const&) ()
    #12 0x08388448 in Ant::send_bkwant_pkt(Packet*) ()

    merci d'avance pour l aide

  5. #5
    Membre éprouvé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2011
    Messages : 59
    Par défaut
    Salut,

    est ce que les vecteurs ph->hop_list_ et ph->liste_noeuds ont été bien construits ? que fait exactement HDR_BKWANT_PKT() ? quel est leur contenu (size, max_size, data) en sortie de cette fonction ?

    je dis ça parce que j'ai déjà croisé des fonctions qui contournent le constructeur et renvoient un cast C de la mémoire brute allouée.

    ensuite pour la performance (éviter les reallocs) tu peux faire un reserve avant la boucle , un range insert ou un simple operator= si les 3 vecteurs doivent avoir le même contenu après cette boucle :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    std::vector<nsaddr_t>::iterator myIntVectorIterator;
    for(myIntVectorIterator = porg->hop_list_.begin();myIntVectorIterator != porg->hop_list_.end();myIntVectorIterator++)
    {
    	ph->hop_list_.push_back(*myIntVectorIterator);
    	ph->liste_noeuds.push_back(*myIntVectorIterator);
    }
    Cdt

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 37
    Par défaut
    les vecteurs ph->hop_list_ et ph->liste_noeuds ont été bien construits dans la structure hdr_bkwant_pkt
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    std::vector<nsaddr_t> hop_list_;	
    std::vector<nsaddr_t>  liste_noeuds ;
    HDR_BKWANT_PKT(paquet) permet de créer un paquet de type hdr_bkwant_pkt .
    pouvez-vous expliquer plus , parce que je comprends pas ce que vous venez de dire : c'est quoi le realloc ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. problème de compilation sous visual C++
    Par fabmili dans le forum MFC
    Réponses: 4
    Dernier message: 08/02/2004, 19h52
  2. problème de compil devc++ socket
    Par stefdem dans le forum Autres éditeurs
    Réponses: 2
    Dernier message: 11/12/2003, 11h33
  3. Réponses: 1
    Dernier message: 29/10/2003, 12h16
  4. Problème de compilation de la DLL du XMLRad
    Par [DreaMs] dans le forum XMLRAD
    Réponses: 2
    Dernier message: 16/04/2003, 16h46
  5. Réponses: 1
    Dernier message: 27/05/2002, 01h44

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