Tutorial5: de-referencing buf->datas[0].data leads to segfault
- PipeWire version (
pipewire --version
):
pipewire
Compiled with libpipewire 0.3.40
Linked with libpipewire 0.3.40
- Distribution and distribution version (
PRETTY_NAME
from/etc/os-release
):Arch Linux
- Desktop Environment:
KDE Plasma 5.23.3
- Kernel version (
uname -r
):5.15.5-arch1-1
Description of Problem:
When testing tutorial 5, a segfault is triggered by the dereference of buf->datas[0].data
pointer.
Note however that type is correctly SPA_DATA_MemPtr
, and flags & SPA_DATA_FLAG_READABLE
is true.
How Reproducible:
Always
Steps to Reproduce:
1.Add a line printf("got a frame of size %d -> %c\n", buf->datas[0].chunk->size, ((uint8_t*)buf->datas[0].data)[0]);
in on_process callback
2. Enjoy the crash
Actual Results:
Segfault:
(gdb) f 0
#0 on_process (userdata=0x7fffffffdf30) at pw.c:37
37 printf("got a frame of size %d -> %c\n", buf->datas[0].chunk->size, ((uint8_t*)buf->datas[0].data)[0]);
(gdb) p ((uint8_t*)buf->datas[0].data)[0]
Cannot access memory at address 0x7ffef6942000
(gdb)
Expected Results:
No segfault
Additional Info (as attachments):
THe issue got fixed by adding the following lines to on_param_changed callback:
uint8_t params_buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
const struct spa_pod *params = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_dataType, SPA_POD_CHOICE_FLAGS_Int((1<<SPA_DATA_MemPtr)));
pw_stream_update_params(data->stream, ¶ms, 1);
Anyway, as the stream is created with the PW_STREAM_FLAG_MAP_BUFFERS
flag, and buf->datas[0].data is not null, i'd expect i do not need to specify Buffers related params.
Moreover, i am sure it worked some months ago when i first played with it a bit; i'd say around april/may.
-
pw-dump > pw-dump.log
: pw-dump.log
Thanks for your great work and for your time!