SegFault using C binding for RADOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings,

I have been attempting work with the C bindings for librados so that I
may write a set of Ruby bindings using the RubyFFI library. I was
having difficult writing to the cluster from my bindings, so I wrote a
contrived example below in an attempt to better understand the
bindings. I know my C is rusty, but the simple example should have
worked. As you can see from the snippets from my gdb session below
this sample app segfaults when attempting write. The backtrace shows
that inside of librados the fault occurs during a list append. I would
prefer to avoid having to write raw C++ if at all possible. Any help
would be greatly appreciated.

Thanks in Advance,
Daniel P. Smith

## Source##
#include <stdlib.h>
#include <stdio.h>
#include <rados/librados.h>

int main(int argc, const char **argv) {
    rados_initialize(0,NULL);

    rados_pool_t my_pool = malloc(sizeof(rados_pool_t));

    if ( rados_open_pool("testpool", &my_pool) < 0) {
        puts("Failed to open pool!");
    } else {
        puts("Success opening pool!");
        if (rados_write(my_pool, "54b0c58c7ce9f2a8b551351102ee0938",
0, "this is a test", 14) < 0) {
            puts("Failed writing to the pool!");
        }

    }

    rados_close_pool(my_pool);
    rados_deinitialize();
}


## Last step ##
14              if (rados_write(my_pool,
"54b0c58c7ce9f2a8b551351102ee0938", 0, "this is a test\0", 15) < 0) {

Program received signal SIGSEGV, Segmentation fault.
0x003cb2b0 in ?? () from /lib/libc.so.6

## Back trace ##
#0  0x003cb2b0 in ?? () from /lib/libc.so.6
#1  0x00183cee in ceph::buffer::list::append(char const*, unsigned
int) () from /usr/lib/librados.so.1
#2  0x0017c1e6 in rados_write () from /usr/lib/librados.so.1
#3  0x0804866f in main (argc=1, argv=0xbffff404) at test.c:14
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux