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

SDL Discussion :

valgrind: Conditional jump or move depends on uninitialised value(s) [SDL 2.0]


Sujet :

SDL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Ouvrier
    Inscrit en
    Août 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : Ouvrier

    Informations forums :
    Inscription : Août 2016
    Messages : 4
    Par défaut valgrind: Conditional jump or move depends on uninitialised value(s)
    Bonjour,
    j'ai fait un programme qui fonctionne mais pas trés clair. Valgrind ne me détecte pas d'erreur.
    Je refais ce programme pour mieux le structurer en utilisant des structures initialisation dans fonction etc, je n'ai pas fini et valgrind me détecte déjà 141 erreurs. J'ai fait un petit programme qui reproduit cela.
    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
    #include <SDL2/SDL.h>
    #include <stdio.h>
    #include <stdlib.h>
     
    #define LARGEUR    200
    #define HAUTEUR    200
     
    typedef struct
    {
        SDL_Window *fenetre;
        SDL_Renderer *rendu;
        SDL_Texture *cellule;
        SDL_Rect pos;
    } ComposantsJeu;
     
    int initialisation(ComposantsJeu *composant);
    SDL_Texture *cellules(ComposantsJeu *composant);
     
    int main(int argc, char *argv[])
    {
        int statut = EXIT_FAILURE;
     
        ComposantsJeu composant = {0};
     
        if(0 != initialisation(&composant))
            goto Quit;
     
        SDL_RenderCopy(composant.rendu, composant.cellule, NULL, &composant.pos);
     
        SDL_RenderPresent(composant.rendu);
     
        SDL_Delay(3000);
     
        statut = EXIT_SUCCESS;
    Quit:
        if(NULL != composant.cellule)
            SDL_DestroyTexture(composant.cellule);
        if(NULL != composant.rendu)
            SDL_DestroyRenderer(composant.rendu);
        if(NULL != composant.fenetre)
            SDL_DestroyWindow(composant.fenetre);
        SDL_Quit();
        return statut;
    }
     
    int initialisation(ComposantsJeu *composant)
    {
        if(0 != SDL_Init(SDL_INIT_VIDEO))
        {
            fprintf(stderr, "Erreur SDL_Init : %s", SDL_GetError());
            return -1;
        }
     
        if(0 != SDL_CreateWindowAndRenderer(LARGEUR, HAUTEUR, SDL_WINDOW_RESIZABLE,
                                            &composant->fenetre, &composant->rendu))
        {
            fprintf(stderr, "Erreur SDL_CreateWindowAndRenderer : %s", SDL_GetError());
            return -1;
        }
     
        if(0 != SDL_SetRenderDrawColor(composant->rendu, 242, 243, 244, 255))
        {
            fprintf(stderr, "Erreur color: %s", SDL_GetError());
            return -1;
        }
        if(0 != SDL_RenderClear(composant->rendu))
        {
            fprintf(stderr, "Erreur SDL_render clear : %s", SDL_GetError());
            return -1;
        }
     
        composant->pos.x = composant->pos.y = 95;
        composant->pos.w = composant->pos.h = 10;
     
        composant->cellule = cellules(composant);
        if(NULL == composant->cellule) return -1;
     
        return 0;
    }
     
    SDL_Texture *cellules(ComposantsJeu *composant)
    {
        SDL_Texture *texture = NULL;
        texture = SDL_CreateTexture(composant->rendu, SDL_PIXELFORMAT_RGBA8888,
                  SDL_TEXTUREACCESS_TARGET, composant->pos.w, composant->pos.h);
     
        if(NULL == texture)
            goto Erreur;
     
        if(0 != SDL_SetRenderTarget(composant->rendu, texture))
            goto Erreur;
     
        if(0 != SDL_SetRenderDrawColor(composant->rendu, 21, 67, 96, 255)) /* bleu Belize hole*/
            goto Erreur;
     
        if(0 != SDL_RenderFillRect(composant->rendu, NULL))
            goto Erreur;
     
        if(0 != SDL_SetRenderTarget(composant->rendu, NULL))
            goto Erreur;
     
        return texture;
     
    Erreur:
        fprintf(stderr, "Erreur SDL, Fonction cellules, fichier main.c : %s\n", SDL_GetError());
        return NULL;
    }
    Valgrind :
    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
    ==2163== Memcheck, a memory error detector
    ==2163== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==2163== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
    ==2163== Command: ./jeu
    ==2163== 
    ==2163== Conditional jump or move depends on uninitialised value(s)
    ==2163==    at 0xB357D5D: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB2B8838: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB2BA4F3: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB786527: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB69DF55: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB69D7FB: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB64C00A: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0x4E76A00: ??? (in /usr/lib/libSDL2-2.0.so.0.8.0)
    ==2163==    by 0x4E719FE: ??? (in /usr/lib/libSDL2-2.0.so.0.8.0)
    ==2163==    by 0x400F27: cellules (main.c:100)
    ==2163==    by 0x400E4B: initialisation (main.c:75)
    ==2163==    by 0x400C3A: main (main.c:25)
    ==2163== 
    ==2163== Conditional jump or move depends on uninitialised value(s)
    ==2163==    at 0xB35B5A7: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB2BA4CF: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB786527: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB69DF55: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB69D7FB: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0xB64C00A: ??? (in /usr/lib/dri/r600_dri.so)
    ==2163==    by 0x4E76A00: ??? (in /usr/lib/libSDL2-2.0.so.0.8.0)
    ==2163==    by 0x4E719FE: ??? (in /usr/lib/libSDL2-2.0.so.0.8.0)
    ==2163==    by 0x400F27: cellules (main.c:100)
    ==2163==    by 0x400E4B: initialisation (main.c:75)
    ==2163==    by 0x400C3A: main (main.c:25)
    ==2163== 
    ==2163== 
    ==2163== HEAP SUMMARY:
    ==2163==     in use at exit: 249,051 bytes in 2,058 blocks
    ==2163==   total heap usage: 34,970 allocs, 32,912 frees, 11,128,723 bytes allocated
    ==2163== 
    ==2163== LEAK SUMMARY:
    ==2163==    definitely lost: 1,961 bytes in 26 blocks
    ==2163==    indirectly lost: 3,781 bytes in 51 blocks
    ==2163==      possibly lost: 0 bytes in 0 blocks
    ==2163==    still reachable: 243,309 bytes in 1,981 blocks
    ==2163==         suppressed: 0 bytes in 0 blocks
    ==2163== Rerun with --leak-check=full to see details of leaked memory
    ==2163== 
    ==2163== For counts of detected and suppressed errors, rerun with: -v
    ==2163== Use --track-origins=yes to see where uninitialised values come from
    ==2163== ERROR SUMMARY: 7 errors from 2 contexts (suppressed: 5 from 1)
    Je compile avec gcc et l'option -g
    Tout est initialisé.
    Auriez vous une idée ?
    Merci

  2. #2
    Nouveau membre du Club
    Homme Profil pro
    Ouvrier
    Inscrit en
    Août 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : Ouvrier

    Informations forums :
    Inscription : Août 2016
    Messages : 4
    Par défaut
    Re,

    Alors j'avais des problèmes d'affichage qui m'ont obligé à prendre le drapeau SDL_RENDERER_SOFTWARE, pour utiliser le CPU (mon pc doit avoir 9 ans).

    Or là, je refaisais mon programme avec le drapeau par defaut de SDL_CreateWindowAndRenderer ,SDL_RENDERER_ACCELERATED. En repassant à SDL_RENDERER_SOFTWARE plus aucune erreur Conditional jump or move depends on uninitialised value(s). Je pense à un petit souci avec ma carte graphique.

    Merci

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/01/2017, 22h49
  2. Réponses: 4
    Dernier message: 01/03/2016, 15h45
  3. Valgrind Conditional jump obscure
    Par Waether dans le forum C
    Réponses: 4
    Dernier message: 07/03/2015, 21h03
  4. strtok_r: Conditional jump or move depends on uninitialised value
    Par ikuzar dans le forum Bibliothèque standard
    Réponses: 2
    Dernier message: 19/03/2013, 15h36
  5. Réponses: 8
    Dernier message: 17/05/2010, 11h34

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