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

Linux Discussion :

blocage application à cause de syslog


Sujet :

Linux

Vue hybride

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

    Informations forums :
    Inscription : Janvier 2014
    Messages : 29
    Par défaut blocage application à cause de syslog
    Bonjour,

    Je rencontre un blocage de mon programme qui m'intrigue. Cela provient de l'usage de syslog.
    ca ressemble a un problème de reentrance pourtant le premier appel de syslog est parfois bien terminé.

    Le blocage s'est d'abord produit sur une cible embarquée, mais j'ai résumé la portion de code ci après compilable en desktop avec "gcc test.c -o test -lm" et ça plante aussi.
    test.c
    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
    160
    161
    162
    #include <stdio.h>
    #include <syslog.h>
    #include <errno.h>
    #include <sys/time.h> //time.h est l'original mais ne fonctionne plus avec le sdk2. sys/time.h semble fonctionner. differences?
    #include <signal.h>
    #include <math.h>
     
     
    #define msg(level, service, ...) do{fprintf(stderr, "/");syslog(LOG_LOCAL0|LOG_DEBUG, __VA_ARGS__);fprintf(stderr, "\\");} while(0)
    #define msg2(level, service, ...) do{fprintf(stderr, "_-");syslog(LOG_LOCAL0|LOG_DEBUG, __VA_ARGS__);fprintf(stderr, "-_");} while(0)
    #define init_msg() openlog("test", LOG_CONS|LOG_PID, LOG_LOCAL0|LOG_LOCAL1|LOG_LOCAL2|LOG_LOCAL3|LOG_LOCAL4|LOG_LOCAL5|LOG_LOCAL6|LOG_LOCAL7|LOG_USER)
     
    void convFloatTimespec(struct timespec *ts, float duree) {
    float nbsec;
     
    //    nbsec = floorf(duree) ;
     
        ts->tv_sec = (time_t)nbsec ;
        ts->tv_nsec = (long)((duree - nbsec)*1000) * 1000000  ; //la milliseconde nous suffit
    }
     
    void attendre(float duree) {
        struct timespec tp, tr ;
        float restant ;
     
        convFloatTimespec(&tp, duree) ;
        if (nanosleep(&tp, &tr) != 0) {
            if (errno == EINTR) {//EINTR means "This call did not succeed because it was interrupted. However, if you try again, it will probably work."
                //In other words, EINTR is not a fatal error -- it just means you should retry whatever you were attempting.
                restant = (float)(tr.tv_sec + tr.tv_nsec/1000000000.0) ;
                msg(DEBUG, MSG_TIMESTAMP, "Attente de %f interrompue alors qu'il reste %f sec ; relancee\n", duree, restant);
                attendre(restant) ; // relance l attente
            }
            else
                msg(ERROR, MSG_TIMESTAMP, "pb attente %f secs\n", duree) ;
        }
    }
     
    void HandlerFinFils (int sig)
    {
            fprintf(stderr, "IT");
        int status=0;
        int pid =0;
    //    msg(DEBUG, MSG_TACHESON, "un processus fils terminé...");
     
        pid = wait(&status);
        if(pid == -1)
        {
                switch(errno){
                case ECHILD:
                        msg(ERROR, MSG_TACHESON, "ECHILD : (for wait()) The calling process does not have any unwaited-for children");
                        break;
                case EINTR:
                        msg(ERROR, MSG_TACHESON, "EINTR");
                        break;
                case EINVAL:
                        msg(ERROR, MSG_TACHESON, "EINVAL");
                        break;
                default:
                        msg(ERROR, MSG_TACHESON, "errno code not recognized : %d", errno);
                        break;
     
                }
        }else{
                msg(DEBUG, MSG_TACHESON, "pere recoit la fin du fils [%d]", pid);
    //            if(!WIFEXITED(status)) msg(ERROR, MSG_TACHESON, "the child NOT terminated normally, that is, by calling exit(3) or _exit(2), or by returning from main()");
    //            else msg(DEBUG, MSG_TACHESON, "exit status of the chlid is %d", WEXITSTATUS(status));
    ////            if(WIFSIGNALED(status)) msg(WARNING, MSG_TACHESON, "child process was terminated by a signal %d coredump produced : %d", WTERMSIG(status), WCOREDUMP(status));
    //            if(WIFSIGNALED(status)) msg(WARNING, MSG_TACHESON, "child process was terminated by a signal %d", WTERMSIG(status));
    //            if(WIFSTOPPED(status)) msg(WARNING, MSG_TACHESON, "child process was stopped by delivery of a signal %d", WSTOPSIG(status));//this is possible only if the call was done using WUNTRACED or when the child is being traced (see ptrace(2)).
    //            if(WIFCONTINUED(status)) msg(WARNING, MSG_TACHESON, "child process was resumed by delivery of SIGCONT");
        }
        fprintf(stderr, "ok");
        return;
    }
     
     
    static short Time_out;
     
    void timeout() {
    //passage("reçu SIGALRM");//§!!!!!!!!!!!
            Time_out = 1;
    }
     
    void init_timeout() {
    struct sigaction sa;
     
        // Activer le timeout utilisable par toutes les fonctions
        sa.sa_handler = timeout;
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = 0;
        sigaction(SIGALRM, &sa, NULL);
    }
     
    int main (int argc, char **argv)
    {
            init_msg();
            struct sigaction Action ;
            init_timeout();
            sigemptyset(&Action.sa_mask);
            Action.sa_flags = 0;
            Action.sa_handler = HandlerFinFils;
            // armement du signal
            if (sigaction(SIGCHLD,&Action,NULL) == -1)
            {
              // erreur
                    msg (ERROR, MSG_TACHESON, "pb armement signal") ;
            }
            float period;
            int i;
            int pid=0;
            int nb=0;
            for(i=250; i>0; i--)
            {
                    period = 5;
                    while(nb<500)
                    {
                            nb++;
                            attendre(period/1000.0);
                            msg(DEBUG, MSG_TACHESON, "after %.3fms fork n°%d...", period, nb);
                            pid=fork();
    //                        msg(DEBUG, MSG_TACHESON, "... fork %d pid : %d", nb, pid);
                            switch(pid)
                            {
                                case -1 :
                                        msg(FATAL, MSG_TACHESON, "Pb fork player son");
                                        attendre(10);
                                        exit(-1);
                                case 0 :
    #if WITH_APLAY
                                    msg(DEBUG, MSG_TACHESON, "lancer Aplay...");
                                    if(execl(PATH_APLAY, "aplay", "-r 22050 -q", "/home/root/data/escargot/sons/musiqueDo0.wav", (char*)0)==-1)
                                    {
                                        msg(ERROR, MSG_TACHESON, "pb lancement son");
                                        attendre(10);
                                        exit(-1);
                                    }
                                    msg(DEBUG, MSG_TACHESON, "cela ne devrait jamais s afficher selon fonctionnement d un execl()");
                                    attendre(10);
    #else // ne pas lancer aplay, juste un message
    //                                msg2(DEBUG, MSG_TACHESON, "...je suis le fils n°%d", nb);
    //                                attendre(2);
    //                                msg(DEBUG, MSG_TACHESON, "arret fils %d");
    #endif // fin alternative aplay
                                    exit(1);
     
                                default :
    //                                    msg(DEBUG, MSG_TACHESON, "je suis ton pere");
                                          break;
                            }
                            msg(DEBUG, MSG_TACHESON, "pere a créé le fils n°%d [%d]", nb, pid);
     
    //                        period /= 2;
                    }
            }
            for(i=0; i<15;i++){
                    msg(DEBUG, MSG_TACHESON, "toujours en vie");
                    attendre(3);
            }
            msg(DEBUG, MSG_TACHESON, "fermeture programme");
            return 1;
    }
    execution :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    vincent@electronic:~/eclipseProjects/desktop_program$ ./test
    /\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\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/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\/\/\IT/\okIT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\IT/\ok/\/\/\/\/\/\/\/\/\/\/\/\/IT/
    Avant chaque appel à syslog() j'affiche "/" et après "\" en debut de routine de traitement d'interruption "IT" et en fin "ok". ça ne se bloque pas à tous les coup contrairement à l'execution en embarqué qui d'ailleurs plante dès le début :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    root@imx:~# ./bin/test
    /\/\/\/\IT/\/\ok/\/\/\IT/\/\ok/\/\IT/
    Que pensez-vous de ce comportement ?

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2014
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2014
    Messages : 29
    Par défaut
    Les mots clés "syslog reentrancy" retournent des résultats intéressants sur les moteurs de recherche.
    Déjà on peut faire beaucoup plus concis comme exemple de blocage.

    En résumé, même printf n'est pas "safe" : dans un handler il est de loin conseillé de passer par un flag et le main() du programme traitera le flag.

    La liste des fonctions "Async-signal-safe" pouvant donc être directement traitées dans un handler est disponible sur la page man de signal 7.

    Il y a également danger avec un affichage dans le fils après un fork() si le père est multithread, le fils risque de copier le verrou dans un état bloqué et n'a pas (lui) un deuxième thread qui fini par le libérer. Voir explication ici.

    Est-ce que vous connaissez un bouquin qui traite ce sujet dans le contexte de Linux ? J'ai intérêt à mettre à jour mes pratiques...

    Pour la solution, si je met flag++ dans le handler (lui même interruptible par un handler je crois si une deuxième IT arrive) et flag-- dans le père est-ce que je dois protéger cette ressource par sémaphore ?
    ou Non car flag++ ou flag-- sont des opérations canoniques ? (quoiqu'avec les optimisations, j'en sais rien)

Discussions similaires

  1. Chargement application cause problèmes mémoire
    Par alex_vino dans le forum Android
    Réponses: 11
    Dernier message: 30/09/2012, 00h31
  2. Blocage même avec Application.ProcessMessages
    Par Sub0 dans le forum Delphi
    Réponses: 7
    Dernier message: 31/01/2007, 05h13
  3. Blocage cause trigger
    Par serge0934 dans le forum Développement
    Réponses: 2
    Dernier message: 10/08/2006, 16h24
  4. [WIN2000][JAVA]blocage de l'application
    Par narmataru dans le forum InterBase
    Réponses: 9
    Dernier message: 09/12/2003, 13h07

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