int buf_sz = rados_pool_list(clu,NULL,0);
char buf[buf_sz];
With some compilers, that won't assign buf_sz chars to buf.
I would expect that, on such compilers, that piece of code would cause an error - and the module would not compile.
However, if it didn't throw a compile-time exception, then you would most likely experience a runtime segfault.
It's safer, IMO, to assign the memory dynamically - something like (UNTESTED):
use Inline C => Config =>
BUILD_NOISY => 1;
__C__
void list_pools_c (rados_t clu) {
Inline_Stack_Vars;
int buf_sz = rados_pool_list(clu,NULL,0);
char *b;
int r;
Newx(b, buf_sz, char);
r = rados_pool_list(clu,b,buf_sz);
if (r != buf_sz) {
printf("buffer size mismatch: got %d the first time, but %d "
"the second.\n", buf_sz, r);
}
Inline_Stack_Reset;
while(1) {
if(b[0] == '\0') {
Inline_Stack_Done;
Safefree(b);
break;
}
Inline_Stack_Push(sv_2mortal(newSVpv(b,0)));
b += strlen(b) +1;
}
}
I've moved the
Inline_Stack_Vars to the top as is my usual practice - though I don't think that matters here.
And I've also added the BUILD_NOISY option so that any warnings from the compilation of the C code can be seen. (FAIK, the module might already have turned BUILD_NOISY on, in which case my re-iteration of it can be removed.)
Not sure if any of that will help - if it doesn't you could try inserting
printf("Got to A\n"); statements into the C code in order to locate the segfault more precisely.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.