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 :

Valgrind: Conditional jump or move depends on uninitialised value


Sujet :

C++

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 165
    Points : 62
    Points
    62
    Par défaut Valgrind: Conditional jump or move depends on uninitialised value
    Bonjour à tous,

    Je me tourne vers vous parce que je suis devant un mur que je n'arrive pas à franchir...
    Je suis entrain de passer mon programme à valgrind pour virer toutes les erreurs/fuites mémoires.


    Je n'arrive pas à corriger un "Conditional jump..."
    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
    ==11599== Thread 8:
    ==11599== Conditional jump or move depends on uninitialised value(s)
    ==11599==    at 0x8F39903: Pcm::linear2alaw(short) (pcm.cpp:17)
    ==11599==    by 0x8F38B8A: AudioUtils::convertToAlaw(AudioStream&) (audioutils.cpp:32)
    ==11599==    by 0x8F38D30: AudioUtils::convertAndResample(AudioStream&, unsigned long const&, double const&, double const&, unsigned int const&) (audioutils.cpp:17)
    ==11599==    by 0x8F46337: SynthesisSession::handleRead(boost::system::error_code const&, unsigned long) (synthesissession.cpp:144)
    ==11599==    by 0x8F5154D: operator() (mem_fn_template.hpp:280)
    ==11599==    by 0x8F5154D: operator()<boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::rrlist2<const boost::system::error_code&, long unsigned int const&> > (bind.hpp:398)
    ==11599==    by 0x8F5154D: operator()<const boost::system::error_code&, long unsigned int const&> (bind.hpp:1318)
    ==11599==    by 0x8F5154D: operator() (bind_handler.hpp:164)
    ==11599==    by 0x8F5154D: asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int> > (handler_invoke_hook.hpp:69)
    ==11599==    by 0x8F5154D: invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> > > (handler_invoke_helpers.hpp:37)
    ==11599==    by 0x8F5154D: asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int> (bind_handler.hpp:207)
    ==11599==    by 0x8F5154D: invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int>, boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int> > (handler_invoke_helpers.hpp:37)
    ==11599==    by 0x8F5154D: dispatch<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int>, std::allocator<void> > (io_object_executor.hpp:119)
    ==11599==    by 0x8F5154D: dispatch<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int>, std::allocator<void> > (io_object_executor.hpp:108)
    ==11599==    by 0x8F5154D: complete<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, const boost::system::error_code&, long unsigned int>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, long unsigned int> > (handler_work.hpp:72)
    ==11599==    by 0x8F5154D: boost::asio::detail::reactive_socket_recv_op<boost::asio::mutable_buffers_1, boost::_bi::bind_t<void, boost::_mfi::mf2<void, SynthesisSession, boost::system::error_code const&, unsigned long>, boost::_bi::list3<boost::_bi::value<SynthesisSession*>, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::asio::detail::io_object_executor<boost::asio::executor> >::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) (reactive_socket_recv_op.hpp:123)
    ==11599==    by 0x8F49565: complete (scheduler_operation.hpp:40)
    ==11599==    by 0x8F49565: do_complete (epoll_reactor.ipp:776)
    ==11599==    by 0x8F49565: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:766)
    ==11599==    by 0x8F3C4CA: complete (scheduler_operation.hpp:40)
    ==11599==    by 0x8F3C4CA: do_run_one (scheduler.ipp:447)
    ==11599==    by 0x8F3C4CA: boost::asio::detail::scheduler::run(boost::system::error_code&) (scheduler.ipp:200)
    ==11599==    by 0x8F4308D: boost::asio::io_context::run() (io_context.ipp:63)
    ==11599==    by 0x97F1346: thread_proxy (in /usr/local/lib/libboost_thread.so.1.72.0)
    ==11599==    by 0x67D6EA4: start_thread (in /usr/lib64/libpthread-2.17.so)
    ==11599==    by 0x6DEB9FC: clone (in /usr/lib64/libc-2.17.so)
    Le code en question est le suivant :
    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
    //----------------------------------
    std::uint8_t 			Pcm::linear2alaw(std::int16_t pcmVal)
    //----------------------------------
    {
    	std::int16_t		mask, seg;
    	std::uint8_t		aval;
    
    	pcmVal = pcmVal >> 3;
    	if (pcmVal >= 0)	{
    		mask = 0xD5; // Sign (7th) bit = 1
    	}
    	else {
    		mask = 0x55; // Sign bit = 0
    		pcmVal = -pcmVal - 1;
    	}
    
    	// Convert the scaled magnitude to segment number
    	seg = search(pcmVal, seg_aend, 8);
    	// Combine the sign, segment, and quantization bits
    	if (seg >= 8)	return (std::uint8_t)(0x7F ^ mask); // Out of range, return maximum value
    	else {
    		aval = (std::uint8_t) seg << SEG_SHIFT;
    		if (seg < 2)	aval |= (pcmVal >> 1) & QUANT_MASK;
    		else			aval |= (pcmVal >> seg) & QUANT_MASK;
    		return (aval ^ mask);
    	}
    }
    
    //----------------------------------
    std::int16_t			Pcm::search(std::int16_t pcmVal, std::int16_t *table, std::int16_t size)
    //----------------------------------
    {
    	std::int16_t		i;
    
    	for (i = 0; i < size; i++)	{
    		if (pcmVal <= *table++)
    			break;
    	}
    	return i;
    }
    L'erreur est sur la ligne que j'ai mis en gras à savoir (if (pcmVal >= 0).
    Est-ce que vous auriez une idée de pourquoi cette erreur alors qu'à la ligne au dessus je n'ai aucune erreur...

    Merci d'avance

  2. #2
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2011
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

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

    Informations forums :
    Inscription : Juin 2011
    Messages : 739
    Points : 3 627
    Points
    3 627
    Par défaut
    Valgrind montre à quel moment une variable qui dépend d'une valeur non initialisée à des conséquences sur le flux du code, mais pas forcément quelle est la variable véritablement non initialisée. C’est-à-dire que le paramètre pcmVal provient d'une variable non initialisée (il faut remonter plus haut), mais que cela n'a de conséquence que sur le if.

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 165
    Points : 62
    Points
    62
    Par défaut
    Merci pour ton explication. Je ne voyais pas du tout la chose comme ça

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

Discussions similaires

  1. Réponses: 9
    Dernier message: 01/03/2021, 23h17
  2. Réponses: 1
    Dernier message: 26/06/2018, 01h17
  3. Réponses: 2
    Dernier message: 29/01/2017, 22h49
  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