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