I get pointer from user and std::move it to structure:
Code: Select all
ctrl.provider = std::move(sound); // Sound is local variable got by value
Code: Select all
xQueueSendToBack(queue, &ctrl, portMAX_DELAY);
Code: Select all
xQueueReceive(queue, &ctrl, 0) // In if, of course
sound = std::move(ctrl.provider);
chSound[channel] = sound;
Everything works fine… until I access pointer from my task or remove it.
Code: Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40085e32 PS : 0x00060933 A0 : 0x80086fef A1 : 0x3ffaf8a0
0x40085e32: uxListRemove at /home/v/compile/esp-idf/components/freertos/list.c:218
A2 : 0x3ffb8bb4 A3 : 0x00000000 A4 : 0xf44ea3fe A5 : 0x00000001
A6 : 0x00060d23 A7 : 0x00060023 A8 : 0x00000000 A9 : 0x3ffafa90
A10 : 0x3ffb3174 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000001
A14 : 0x00060920 A15 : 0x00000000 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffff
Backtrace: 0x40085e32:0x3ffaf8a0 0x40086fec:0x3ffaf8d0 0x4010a3d4:0x3ffaf900 0x401009a0:0x3ffaf930 0x400d38c1:0x3ffaf960 0x401004e3:0x3ffaf990 0x400d28b3:0x3ffaf9c0 0x400d2930:0x3ffaf9f0
0x40085e32: uxListRemove at /home/v/compile/esp-idf/components/freertos/list.c:218
0x40086fec: vTaskDelete at /home/v/compile/esp-idf/components/freertos/tasks.c:5121
0x4010a3d4: Sound::SoundProviderTask::provider_stop() at /home/v/compile/esp32-sound-test/components/esp32-sound/soundProviderTask.cpp:6
0x401009a0: SoundProviderPcm::~SoundProviderPcm() at /home/v/compile/esp32-sound-test/components/esp32-sound-pcm/soundProviderPcm.cpp:12
0x400d38c1: void __gnu_cxx::new_allocator<SoundProviderPcm>::destroy<SoundProviderPcm>(SoundProviderPcm*) at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/ext/new_allocator.h:124
(inlined by) std::enable_if<std::__and_<std::allocator_traits<std::allocator<SoundProviderPcm> >::__destroy_helper<SoundProviderPcm>::type>::value, void>::type std::allocator_traits<std::allocator<SoundProviderPcm> >::_S_destroy<SoundProviderPcm>(std::allocator<SoundProviderPcm>&, SoundProviderPcm*) at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/alloc_traits.h:285
(inlined by) void std::allocator_traits<std::allocator<SoundProviderPcm> >::destroy<SoundProviderPcm>(std::allocator<SoundProviderPcm>&, SoundProviderPcm*) at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/alloc_traits.h:414
(inlined by) std::__shared_ptr<SoundProviderPcm, (__gnu_cxx::_Lock_policy)2>::_Deleter<std::allocator<SoundProviderPcm> >::operator()(SoundProviderPcm*) at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/shared_ptr_base.h:1112
(inlined by) std::_Sp_counted_deleter<SoundProviderPcm*, std::__shared_ptr<SoundProviderPcm, (__gnu_cxx::_Lock_policy)2>::_Deleter<std::allocator<SoundProviderPcm> >, std::allocator<SoundProviderPcm>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/shared_ptr_base.h:466
0x401004e3: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() at /home/v/compile/esp32-sound-test/components/esp32-sound/soundMixer.cpp:304
(inlined by) std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/shared_ptr_base.h:659
(inlined by) std::__shared_ptr<Sound::SoundProvider, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/shared_ptr_base.h:925
(inlined by) std::shared_ptr<Sound::SoundProvider>::~shared_ptr() at /home/v/compile/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/shared_ptr.h:93
(inlined by) Sound::SoundMixer::soundCallback() at /home/v/compile/esp32-sound-test/components/esp32-sound/soundMixer.cpp:126
0x400d28b3: timer_process_alarm at /home/v/compile/esp-idf/components/esp32/esp_timer.c:413
0x400d2930: timer_task at /home/v/compile/esp-idf/components/esp32/esp_timer.c:413
What is terrible wrong here?