Partage
  • Partager sur Facebook
  • Partager sur Twitter

problème affichage des lignes avec valgrind

trouver segfault et abort

    10 septembre 2020 à 21:08:02

    Bonjour, 

    Je ne sais pas si j ai fait une erreur mais je cherche à trouver où mon programme me renvoi sigabort ou segfault. Voila mon ce que me renvoi mon programme sans valgrind : 

    cub3d(14889,0x116b9edc0) malloc: Incorrect checksum for freed object 0x7f9306cad828: probably modified after being freed.
    Corrupt value: 0xff000000ff0000
    cub3d(14889,0x116b9edc0) malloc: *** set a breakpoint in malloc_error_break to debug
    zsh: abort      ./cub3d m/test_R10.cub
    

    Du coup quand je lance valgrind (j ai compilé avec -g), ça ne me donne pas les lignes pour m'aider à trouver le problème, même si j ajoute le flag --track-origins=yes. 

    J'ai eu ce même problème pour trouver mes leaks.

    Pour info, mon programme prend un fichier en paramètre. 

    Voila ce que me renvoi valgrind : 

    ==14927== Memcheck, a memory error detector
    ==14927== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==14927== Using Valgrind-3.17.0.GIT and LibVEX; rerun with -h for copyright info
    ==14927== Command: ./cub3d m/test_R10.cub
    ==14927== 
    ==14927== Conditional jump or move depends on uninitialised value(s)
    ==14927==    at 0x1062371DF: ??? (in /usr/lib/system/libsystem_platform.dylib)
    ==14927==    by 0x105FE47B4: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927==    by 0x105FECCCB: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927==    by 0x106011AD2: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927==    by 0x105FEA2B1: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927==    by 0x105FE841D: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927==    by 0x100003CE0: check_fd (check_fd.c:71)
    ==14927==    by 0x100001F2A: main (cub3d.c:148)
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x105FEA39B: ??? (in /usr/lib/system/libsystem_c.dylib)
    ==14927== 
    map lo 14, map la 33
    ==14927== Use of uninitialised value of size 8
    ==14927==    at 0x100002083: fill_map (build_map.c:39)
    ==14927==    by 0x1000021CC: check_map (build_map.c:66)
    ==14927==    by 0x1000040B4: ft_read_fd (check_fd.c:118)
    ==14927==    by 0x100001F85: main (cub3d.c:151)
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x100003B80: check_fd (check_fd.c:46)
    ==14927== 
    ==14927== Use of uninitialised value of size 8
    ==14927==    at 0x100002083: fill_map (build_map.c:39)
    ==14927==    by 0x100002254: check_map (build_map.c:73)
    ==14927==    by 0x1000040B4: ft_read_fd (check_fd.c:118)
    ==14927==    by 0x100001F85: main (cub3d.c:151)
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x100003B80: check_fd (check_fd.c:46)
    ==14927== 
    ==14927== Use of uninitialised value of size 8
    ==14927==    at 0x100002052: fill_map (build_map.c:34)
    ==14927==    by 0x100002254: check_map (build_map.c:73)
    ==14927==    by 0x1000040B4: ft_read_fd (check_fd.c:118)
    ==14927==    by 0x100001F85: main (cub3d.c:151)
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x100003B80: check_fd (check_fd.c:46)
    ==14927== 
    ==14927== Syscall param mach_msg(trailer->msgh_trailer_type) points to uninitialised byte(s)
    ==14927==    at 0x1061EADFA: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061EB16F: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061C612C: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C4597: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C20F1: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x101A3D224: _CFPrefsExtractQuadrupleFromPathIfPossible (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x105E6B657: ??? (in /usr/lib/system/libdispatch.dylib)
    ==14927==    by 0x105E6C7DD: ??? (in /usr/lib/system/libdispatch.dylib)
    ==14927==    by 0x101A3C84B: -[CFPrefsSearchListSource copyCloudConfigurationWithURL:outConfigFileSource:outStoreName:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101A3C495: -[CFPrefsPlistSource setDomainIdentifier:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101B90E85: -[CFPrefsSearchListSource alreadylocked_copyKeyList] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101A369D0: -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==  Address 0x104939110 is on thread 1's stack
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x1061C5E3D: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927== 
    ==14927== Syscall param mach_msg(trailer->msgh_trailer_size) points to uninitialised byte(s)
    ==14927==    at 0x1061EADFA: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061EB16F: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061C612C: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C4597: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C20F1: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x101A3D224: _CFPrefsExtractQuadrupleFromPathIfPossible (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x105E6B657: ??? (in /usr/lib/system/libdispatch.dylib)
    ==14927==    by 0x105E6C7DD: ??? (in /usr/lib/system/libdispatch.dylib)
    ==14927==    by 0x101A3C84B: -[CFPrefsSearchListSource copyCloudConfigurationWithURL:outConfigFileSource:outStoreName:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101A3C495: -[CFPrefsPlistSource setDomainIdentifier:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101B90E85: -[CFPrefsSearchListSource alreadylocked_copyKeyList] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==    by 0x101A369D0: -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
    ==14927==  Address 0x104939114 is on thread 1's stack
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x1061C5E3D: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927== 
    UNKNOWN workq_ops option 1024
    ==14927== Syscall param mach_msg(trailer) points to unaddressable byte(s)
    ==14927==    at 0x1061EADFA: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061EB16F: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1062C9A2C: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1062AEB61: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1062AE9E1: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1062B0CE7: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1062B0B19: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1062AA5F1: ??? (in /usr/lib/system/libxpc.dylib)
    ==14927==    by 0x1060AE45D: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060AE30E: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060AE1F3: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADCBB: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==  Address 0x10f621000 is not stack'd, malloc'd or (recently) free'd
    ==14927== 
    ==14927== Syscall param mach_msg(trailer->msgh_trailer_type) points to uninitialised byte(s)
    ==14927==    at 0x1061EADFA: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061EB16F: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061C50F0: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C6A87: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C2BDF: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x106275370: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x106273A6E: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x10627278A: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x1060AE23A: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADCBB: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADD9E: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADCF6: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==  Address 0x10493885c is on thread 1's stack
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x1061C508D: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927== 
    ==14927== Syscall param mach_msg(trailer) points to uninitialised byte(s)
    ==14927==    at 0x1061EADFA: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061EB16F: ??? (in /usr/lib/system/libsystem_kernel.dylib)
    ==14927==    by 0x1061C50F0: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C6A87: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x1061C2BDF: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927==    by 0x106275370: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x106273A6E: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x10627278A: ??? (in /usr/lib/system/libsystem_trace.dylib)
    ==14927==    by 0x1060AE23A: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADCBB: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADD9E: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==    by 0x1060ADCF6: ??? (in /usr/lib/system/libsystem_info.dylib)
    ==14927==  Address 0x10493885c is on thread 1's stack
    ==14927==  Uninitialised value was created by a stack allocation
    ==14927==    at 0x1061C508D: ??? (in /usr/lib/system/libsystem_notify.dylib)
    ==14927== 
    ==14927== Thread 2:
    ==14927== Invalid read of size 4
    ==14927==    at 0x10624BC10: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==    by 0x10624B942: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==    by 0x10624AB76: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==  Address 0x18 is not stack'd, malloc'd or (recently) free'd
    ==14927== 
    ==14927== 
    ==14927== Process terminating with default action of signal 11 (SIGSEGV)
    ==14927==  Access not within mapped region at address 0x18
    ==14927==    at 0x10624BC10: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==    by 0x10624B942: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==    by 0x10624AB76: ??? (in /usr/lib/system/libsystem_pthread.dylib)
    ==14927==  If you believe this happened as a result of a stack
    ==14927==  overflow in your program's main thread (unlikely but
    ==14927==  possible), you can try to increase the size of the
    ==14927==  main thread stack using the --main-stacksize= flag.
    ==14927==  The main thread stack size used in this run was 8388608.
    --14927:0:schedule VG_(sema_down): read returned -4
    ==14927== 
    ==14927== HEAP SUMMARY:
    ==14927==     in use at exit: 0 bytes in 0 blocks
    ==14927==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
    ==14927== 
    ==14927== All heap blocks were freed -- no leaks are possible
    ==14927== 
    ==14927== For lists of detected and suppressed errors, rerun with: -s
    ==14927== ERROR SUMMARY: 470 errors from 10 contexts (suppressed: 53 from 4)
    zsh: segmentation fault  valgrind --track-origins=yes ./cub3d m/test_R10.cub

    Si quelqu'un peux me dire si je fais une erreur dans l'utilisation de valgrind ou si il y a une raison que j ignore. 

    Merci beaucoup. 



    • Partager sur Facebook
    • Partager sur Twitter
      10 septembre 2020 à 21:16:11

      Bien que valgrind puisse te donner l'indication, c'est avec un debugger que tu dois démarrer ton programme pour savoir où ça a planté. Il t'indiquera la pile d'appel et l'endroit exact où ça a planté avec les variables locales.

      • Partager sur Facebook
      • Partager sur Twitter

      git is great because Linus did it, mercurial is better because he didn't.

        10 septembre 2020 à 22:37:18

        Je te remercie, j ai suivi ton conseil, je suis pas très a l'aise avec le debuggeur et comme le programme est assez gros et que je ne savais pas où etait le problème ça m'a pris tellement de temps de faire étape par étape... J'ai trouvé dans quelle fonction ça merdait !! Merci pour ton conseil !! Je suis sure que j'aurai pu faire plus rapide, mais il me faut encore de l'entrainement.

        Du coup le retour de valgrind est normal pour toi ?? Ça pourra me servir pour mes prochains programmes !! 

        En tous ca spour ce programme c'est réglé !!

        • Partager sur Facebook
        • Partager sur Twitter
          12 septembre 2020 à 23:27:12

          Bonjour,

          Valgrind signale de très nombreux problèmes (il y aurait des variables jamais initialisées qui seraient passées en paramètre.) Ça semble des problèmes que le compilateur devrait voir et les signaler par des Warnings. As-tu bien activé les Warnings, et il faut penser à les lire?

          • Partager sur Facebook
          • Partager sur Twitter

          En recherche d'emploi.

            25 septembre 2020 à 18:15:44

            Bonjour,

            J'utilise le flag -Werror, il me semble que ça passe les warning en erreur, alors si c etait le cas mon prog ne compilerai pas du tout. Je sais pas mais sur ce projet, valgrind me dit plein de trucs chelous et pas forcément vrai apparemment. 

            • Partager sur Facebook
            • Partager sur Twitter

            problème affichage des lignes avec valgrind

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown