Program terminated with signal 11, Segmentation fault


#1

Postby romalin99 » Wed Aug 20, 2014 5:18 am

0 0x000000000041e267 in cl_compile (info1=0, info2=1, info3=0, ns=, set=, key=0x0, digest=0x7fff6fafd1d1, values=0x7fff6ef0b340, operator=CL_OP_WRITE, operations=0x0, n_values=3, buf_r=0x7fff6ef0b250, buf_sz_r=0x7fff6ef0b248, cl_w_p=0x7fff6ef0b410, d_ret=0x7fff6ef0b210, trid=0, scan_param_field=0x0, call=0x0, udf_type=0 ‘\000’) at src/main/citrusleaf/citrusleaf.c:870 870 src/main/citrusleaf/citrusleaf.c: No such file or directory. in src/main/citrusleaf/citrusleaf.c Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.132.el6_5.3.x86_64 keyutils-libs-1.4-4.el6.x86_64 krb5-libs-1.10.3-15.el6_5.1.x86_64 libcom_err-1.41.12-18.el6_5.1.x86_64 libselinux-2.0.94-5.3.el6_4.1.x86_64 lua-5.1.4-4.1.el6.x86_64 openssl-1.0.1e-16.el6_5.15.x86_64 zlib-1.2.3-29.el6.x86_64 (gdb) bt

0 0x000000000041e267 in cl_compile (info1=0, info2=1, info3=0, ns=, set=, key=0x0, digest=0x7fff6fafd1d1, values=0x7fff6ef0b340, operator=CL_OP_WRITE, operations=0x0, n_values=3, buf_r=0x7fff6ef0b250, buf_sz_r=0x7fff6ef0b248, cl_w_p=0x7fff6ef0b410, d_ret=0x7fff6ef0b210, trid=0, scan_param_field=0x0, call=0x0, udf_type=0 ‘\000’) at src/main/citrusleaf/citrusleaf.c:870 1 0x000000000041ecdf in do_the_full_monte (asc=0x158d030, info1=0, info2=1, info3=, ns=0x7fff6fafd141 “test”, set=, key=0x0, digest=0x7fff6fafd1d1, values=0x7fff6ef0b308, operator=CL_OP_WRITE, operations=0x0, n_values=0x7fff6ef0b304, cl_gen=0x0, cl_w_p=0x7fff6ef0b410, trid=0x7fff6ef0b318, setname_r=0x0, call=0x0, cl_ttl=0x0) at src/main/citrusleaf/citrusleaf.c:1322 2 0x000000000041fdb5 in citrusleaf_put_digest_with_setname (asc=, ns=, set=, digest=, values=0x7fff6ef0b340, n_values=3, cl_w_p=0x7fff6ef0b410) at src/main/citrusleaf/citrusleaf.c:1658 3 0x000000000040c31e in aerospike_key_put (as=0x7fff6fafd8f0, err=0x7fff6fafd4d0, policy=, key=0x7fff6fafd140, rec=0x7fff6fafd060) at src/main/aerospike/aerospike_key.c:339 4 0x000000000040afee in main (argc=1, argv=0x7fff6fb00058) at test1.c:151

codes: for(unsigned long i=0;i<500000;i++) { char keybuf[100]={0}; snprintf(keybuf,sizeof(keybuf),“ro%010lu”,i); as_key keytmp; as_key_init_str(&keytmp,“test”,“demo-set2”,keybuf);

as_record rectmp; as_record_inita(&rectmp,3); as_record_set_int64(&rectmp,“bin1”,i); as_record_set_int64(&rectmp,“bin2”,i+10); as_record_set_int64(&rectmp,“bin3”,i+20); //as_record_set_str(&rectmp,“bin3”,data1);

if( AEROSPIKE_OK != aerospike_key_put(&as, &err,NULL,&keytmp,&rectmp) ) { fprintf(stderr,“err(%d) %s at [%s:%d]\n”, err.code, err.message, err.file, err.line); cleanup(&as); exit(-1); } } only 65271 keys putted, subsequently Segmentation fault (core dumped). please help me . and thanks.


#2

by devops02 » Wed Aug 20, 2014 10:16 am

Hi,

I was wondering what version of Aerospike Community are you using? Also just to confirm are you using the C client?

Jerry


#3

by romalin99 » Wed Aug 20, 2014 7:17 pm

Thanks to you answer for my the request firstly,

machine os-platform : cetos6.5 the server package: aerospike-server-community-3.3.12-1.el6.x86_64.rpm tools-packages: aerospike-tools-3.3.13-1.el6.x86_64.rpm client packages: aerospike-client-c-3.0.72-1.el6.x86_64.rpm aerospike-client-c-devel-3.0.72-1.el6.x86_64.rpm


the whole codes as follows:

include <stdio.h> include <string.h> include <stdbool.h> include <stdlib.h> include <stdint.h> include <unistd.h> include <aerospike/aerospike.h> include <aerospike/aerospike_index.h> include <aerospike/aerospike_key.h> include <aerospike/aerospike_udf.h> include <aerospike/as_bin.h> include <aerospike/as_bytes.h> include <aerospike/as_error.h> include <aerospike/as_config.h> include <aerospike/as_key.h> include <aerospike/as_operations.h> include <aerospike/as_record.h> include <aerospike/as_record_iterator.h> include <aerospike/as_status.h> include <aerospike/as_val.h>

//#include <> //using namespace std; define LOG(_fmt, _args…) { printf(_fmt “\n”, ## _args); fflush(stdout); } static void cleanup(aerospike* p_as) { as_error err; aerospike_close(p_as, &err); aerospike_destroy(p_as); } static void dump_bin(const as_bin* p_bin) { if (! p_bin) { LOG(" null as_bin object"); return; }

char* val_as_str = as_val_tostring(as_bin_get_value(p_bin));

LOG(" %s : %s", as_bin_get_name(p_bin), val_as_str);

free(val_as_str); } void dump_record(const as_record* p_rec) { if (! p_rec) { LOG(" null as_record object"); return; }

if (p_rec->key.valuep) { char* key_val_as_str = as_val_tostring(p_rec->key.valuep); LOG(" key: %s", key_val_as_str); free(key_val_as_str); }

uint16_t num_bins = as_record_numbins(p_rec);

LOG(" generation %u, ttl %u, %u bin%s", p_rec->gen, p_rec->ttl, num_bins, num_bins == 0 ? “s” : (num_bins == 1 ? “:” : “s:”));

as_record_iterator it; as_record_iterator_init(&it, p_rec);

while (as_record_iterator_has_next(&it)) { dump_bin(as_record_iterator_next(&it)); }

as_record_iterator_destroy(&it); }


#4

bool read_test_record(aerospike* p_as,as_key* p_key) { as_error err; as_record* p_rec = NULL;

// Read the test record from the database. if (aerospike_key_get(p_as, &err, NULL, p_key, &p_rec) != AEROSPIKE_OK) { LOG(“aerospike_key_get() returned %d - %s”, err.code, err.message); return false; }

// If we didn’t get an as_record object back, something’s wrong. if (! p_rec) { LOG(“aerospike_key_get() retrieved null as_record object”); return false; }

// Log the result. LOG(“record was successfully read from database:”); dump_record(p_rec);

// Destroy the as_record object. as_record_destroy(p_rec);

return true; } int main(int argc,char* argv[]) { //step1 configuring the client as_config config; as_config_init(&config); as_config_add_host(&config,“127.0.0.1”,3000); //as_config_set_user(&cfg,"","")

//step2 initilize a client aerospike as; aerospike_init(&as,&config);

//step3 establishing a connection as_error err; if(aerospike_connect(&as,&err) != AEROSPIKE_OK) { fprintf(stderr,“err(%d) %s at [%s:%d]\n”,err.code, err.message, err.file, err.line); aerospike_destroy(&as); exit(-1); }

//dosomething as_key key;//namespace ,set key //as_key_init(&key,“test”,“demo_set”,“test_key”); as_key_init_str(&key,“test”,“demo-set”,“test-key”);

as_record rec; as_record_inita(&rec,2);//指定这条记录有几列 as_record_set_int64(&rec,“test-bin-1”,1234);//第一列设为整型 as_record_set_str(&rec,“test-bin-2”,“test-bin-2-data”);//The second bin is called “test-bin-2”, and is of type string

if( AEROSPIKE_OK != aerospike_key_put(&as, &err,NULL,&key,&rec) ) { fprintf(stderr,“err(%d) %s at [%s:%d]\n”, err.code, err.message, err.file, err.line); cleanup(&as); exit(-1); } char data1[]=“101087648756478androiapplu51-661538461533846151iPhone3G8248a74c6060ff89da9793e3d651dddc36a997f1.2.3.10Yaho876487564781407401201018489536cQ17f9Q4362Q9e0bQa9f2964bd9a067825159Q7611Q46hbQa987Q222e3164cbIAB203254.2.”; for(unsigned long i=0;i<500000;i++) { char keybuf[100]={0}; snprintf(keybuf,sizeof(keybuf),“ro%010lu”,i); printf(“key={%s}\n”,keybuf); as_key keytmp; as_key_init_str(&keytmp,“test”,“demo-set2”,keybuf);

as_record rectmp; as_record_inita(&rectmp,3); as_record_set_int64(&rectmp,“bin1”,i); as_record_set_int64(&rectmp,“bin2”,i+10); as_record_set_int64(&rectmp,“bin3”,i+20); //as_record_set_str(&rectmp,“bin3”,data1);

if( AEROSPIKE_OK != aerospike_key_put(&as, &err,NULL,&keytmp,&rectmp) ) { fprintf(stderr,“err(%d) %s at [%s:%d]\n”, err.code, err.message, err.file, err.line); cleanup(&as); exit(-1); } } //get data as_record* p_rec = NULL;

// Read the test record from the database. if (aerospike_key_get(&as, &err, NULL, &key, &p_rec) != AEROSPIKE_OK) { LOG(“aerospike_key_get() returned %d - %s”, err.code, err.message); return false; }

// If we didn’t get an as_record object back, something’s wrong. if (! p_rec) { LOG(“aerospike_key_get() retrieved null as_record object”); return false; } // Log the result. LOG(“record was successfully read from database:”); dump_record(p_rec); // Destroy the as_record object. as_record_destroy(p_rec);

// Generate another as_record object to write. as_record_inita(&rec,2); as_record_set_int64(&rec, “test-bin-2”, 2222); as_record_set_str(&rec, “test-bin-3”, “test-bin-3-data”); //dump_record(&rec); if (aerospike_key_put(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK) { LOG(“aerospike_key_put() returned %d - %s”, err.code, err.message); cleanup(&as); exit(-1); }

LOG(“write2 succeeded”); read_test_record(&as,&key);

/* if (aerospike_key_remove(&as, &err, NULL, &key) != AEROSPIKE_OK) { LOG(“aerospike_key_remove() returned %d - %s”, err.code, err.message); cleanup(&as); exit(-1); } */ //step4-0 clean up resourse as_record_destroy(&rec);//as_record_destroy() is not strictly needed.

//step5 cleanup cleanup(&as); return 0; }


#5

by wchu » Fri Aug 22, 2014 11:57 am

as_record_inita() internally uses alloca() to reserve record/bin space on stack. When this is done in a large loop, this can blow the available stack space of the calling function.

A simple solution is to move the as_record_inita() function outside of the loop:

as_record rectmp; as_record_inita(&rectmp,3);

for (unsigned long i=0;i<500000;i++) { char keybuf[100]={0}; snprintf(keybuf,sizeof(keybuf),“ro%010lu”,i); as_key keytmp; as_key_init_str(&keytmp,“test”,“demo-set2”,keybuf); as_record_set_int64(&rectmp,“bin1”,i); as_record_set_int64(&rectmp,“bin2”,i+10); as_record_set_int64(&rectmp,“bin3”,i+20);

if( AEROSPIKE_OK != aerospike_key_put(&as, &err,NULL,&keytmp,&rectmp) ) { fprintf(stderr,“err(%d) %s at [%s:%d]\n”, err.code, err.message, err.file, err.line); exit(-1); } }

Similar caution should be applied to as_query_select_inita(), as_batch_inita(), as_operations_inita() and as_scan_select_inita()


#6

by romalin99 » Sun Aug 24, 2014 7:24 pm

thanks to give my help about this problem.