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 :

Plantage malloc en VC6


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Inscrit en
    Mars 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 7
    Par défaut Plantage malloc en VC6
    Bonjour,
    je constate un problème avec la fonction malloc sous XP SP3 32bits,
    le programme s'arrêt sans message de defaut,
    la structure BLOCKDD a une taille de 2976 octets et le programme s'arrête lors de la 111 allocation dynamique !!!
    Quelle limite est atteinte ?


    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
    DPrintf2("ReadCSVP 1d   bloc:%s found \r\n",szText15);
    safe_strncpy(memCurBlock,szCurBlock,sizeof(memCurBlock)); // memorize the block name (with the hierarchy)
    planhierarch[0]='\0';
    g_BlockIndex = ++(pBlocks->nBlock);   // nBlock = Number of readed DigDevice blocks into the readcsv file
    DPrintf2(" ReadCSVP 1e   bloc:%s found  g_BlockIndex=%d r\n",szText15,g_BlockIndex);
    unitBlockDD=(BLOCKDD*) alloc(sizeof(BLOCKDD)); // allocate memory for the new block
    DPrintf2(" ReadCSVP 1f  bloc:%s found  g_BlockIndex=%d malloc:%d\r\n",szText15,g_BlockIndex,unitBlockDD);
    pBlocks->unitBlock[g_BlockIndex-1]=(void*)unitBlockDD;
    if (unitBlockDD==0)
    {
    DPrintf("EEE ReadCSVP    !!! OUT OF MEMORY BLOCK DCD !!!\r\n");
    memset(unitBlockDD,0,sizeof(BLOCKDD)); // reset the allocated memory
    }
    
    typedef struct{
        char tagname[256];// hierarchy for tag name construction
        char     interlock_texts[DDMAXINTLOCK][DDTEXMAXLEN];// Array with 40-character strings to save the 10 interlock texts
        char    interconnection_texts[DDMAXINTLOCK][DDTEXCMAXLEN];// Array with 90-character strings to save the 10 interconnection texts
        char     logic_texts[DDMAXLOGIC][DDTEXMAXLEN];// Array with 90-character strings to save the 16 logic texts
        char    szFEEDB1[DDTEXMAXLEN];              // FEEDBACK 1
        char    szFEEDBC1[DDTEXCMAXLEN];            // FEEDBACK 1
        char    szFEEDB2[DDTEXMAXLEN];              // FEEDBACK 2
        char    szFEEDBC2[DDTEXCMAXLEN];            // FEEDBACK 2
        char    szLOCAL[DDTEXMAXLEN];              // LOCAL
        char    szLOCALC[DDTEXCMAXLEN];            // LOCAL
        char    szMTR_PROT[DDTEXMAXLEN];          // MPR_PROT
        char    szMTR_PROTC[DDTEXCMAXLEN];        // MPR_PROT
        char    szCMD1[DDTEXMAXLEN];              // CMD 1 
        char    szCMDC1[DDTEXCMAXLEN];            // CMD 1 
        char    szCMD2[DDTEXMAXLEN];              // CMD 2
        char    szCMDC2[DDTEXCMAXLEN];            // CMD 2
        char    szQMON[DDTEXCMAXLEN];            // QMON ERROR
    } BLOCKDD;    // size= 256 + 10*40 + 10*90 + 16*40 + 6*40 + 6*90 = 2976
    Détail de mon fichier Log :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    [2011-09-17 09:43] ReadCSVP 1d  bloc:DCDL_Ext found
    [2011-09-17 09:43] ReadCSVP 1e  bloc:DCDL_Ext found  g_BlockIndex=110 
    [2011-09-17 09:43] ReadCSVP 1f   bloc:DCDL_Ext found  g_BlockIndex=110  malloc:309754408
    [2011-09-17 09:43] ReadCSVP DIG_DEVICELOG_EXT_CODE   110 
    [2011-09-17 09:43] ReadCSVP 1d   bloc:DCDL_Ext found 
    [2011-09-17 09:43] ReadCSVP 1e   bloc:DCDL_Ext found g_BlockIndex=111
    le programme s'est arrêté ReadCSVP 1f n'a plus été écrit dans le log.

  2. #2
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Octobre 2008
    Messages
    1 515
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Octobre 2008
    Messages : 1 515
    Par défaut
    Si ton programme plante vraiment sur un malloc, ça veut probablement dire que tu vas corrompre le heap ailleurs dans ton code.

  3. #3
    Modérateur
    Avatar de gangsoleil
    Homme Profil pro
    Manager / Cyber Sécurité
    Inscrit en
    Mai 2004
    Messages
    10 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Manager / Cyber Sécurité

    Informations forums :
    Inscription : Mai 2004
    Messages : 10 150
    Par défaut
    Bonjour,

    alloc n'est pas une fonction C standard. Sais-tu par quelle librairie il est fourni ? Est-ce que tu as regarde si errno est attribuee par cette fonction, et si oui quelle est la valeur ?
    "La route est longue, mais le chemin est libre" -- https://framasoft.org/
    Les règles du forum

Discussions similaires

  1. Réponses: 3
    Dernier message: 23/07/2012, 11h34
  2. VC6 - Plantage Visual Studio lors du "File / Open ..."
    Par lhpp dans le forum Visual C++
    Réponses: 8
    Dernier message: 27/01/2011, 00h17
  3. plantage de free après malloc
    Par Chewbi dans le forum C
    Réponses: 4
    Dernier message: 25/08/2006, 15h16
  4. [Kylix] Plantage IDE Kylix3/Mandrake 9.0
    Par OmicroN dans le forum EDI
    Réponses: 3
    Dernier message: 28/01/2003, 23h04
  5. Réponses: 4
    Dernier message: 03/12/2002, 16h47

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