1

I use default sd-bus library produce by systemd. I modify example from http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html I add this lines to create a test property on dbus

/* The vtable of our little object, implements the net.poettering.Calculator interface */
static const sd_bus_vtable calculator_vtable[] = {
        SD_BUS_VTABLE_START(0),
        SD_BUS_METHOD("Multiply", "xx", "x", method_multiply, SD_BUS_VTABLE_UNPRIVILEGED),
        SD_BUS_METHOD("Divide",   "xx", "x", method_divide,   SD_BUS_VTABLE_UNPRIVILEGED),
        SD_BUS_PROPERTY("test", "u", NULL, offsetof(struct object, u), SD_BUS_VTABLE_PROPERTY_CONST),
        SD_BUS_VTABLE_END
}; 

and add object struct

typedef struct object {
    uint32_t u;
} object;

After compiling with modifications I have a Segmentation fault Why I have it

alex
  • 11
  • 1
  • Have you tried using a [*debugger*](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) to catch the crash as it happens, and locate where in your code it happens? – Some programmer dude Sep 05 '22 at 08:06
  • Use, gdb said me this Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7f22878 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0 – alex Sep 05 '22 at 08:28
  • you need to compile with debug symbol and no optimization to get the full stack – Ôrel Sep 05 '22 at 08:49
  • gcc -g -O0 t.c -o my -lsystemd / Program received signal SIGSEGV, Segmentation fault. __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:340 340 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory. – alex Sep 05 '22 at 08:59
  • Check the callstack with the `bt` command. Walk up the callstack with the `up` command. Please [read the GDB documentation](https://sourceware.org/gdb/current/onlinedocs/gdb/). – Some programmer dude Sep 05 '22 at 09:05
  • there will be time - I will definitely read it, thanks! – alex Sep 05 '22 at 09:11

0 Answers0