You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems when a stigmergy message causes an onconflict to be called, memory is leaked from the system, which eventually can cause an out of memory error. The error is probably caused in the following lines. I tried to investigate what was leaking memory exactly, but I'm not familiar enough with the garbage collection of the vm yet.
Here is the C code to reproduce
#defineFILE_TEST5 "resources/5_Onconflict.bbo"
TEST(vm_onconflict) {
// Init VMvm=&vmObj;
uint16_trobot=0;
bbzvm_construct(robot);
bbzvm_set_error_receiver(&set_last_error);
fbcode=fopen(FILE_TEST5, "rb");
REQUIRE(fbcode!=NULL);
REQUIRE(fseek(fbcode, 0, SEEK_END) ==0);
fsize=ftell(fbcode);
REQUIRE(fsize>0);
REQUIRE(fseek(fbcode, 0, SEEK_SET) >= 0);
bbzvm_set_bcode(&testBcode, fsize);
REQUIRE(vm->state==BBZVM_STATE_READY);
REQUIRE(bbzvm_register_functions() >= 0); // If this fails, it means that the heap doesn't have enough memory allocated to execute this test.// Stepping through scriptwhile (vm->state==BBZVM_STATE_READY) {
#ifdefDEBUGuint8_tinstr=*vm->bcode_fetch_fun(vm->pc,1);
if (instr>BBZVM_INSTR_CALLS) {
printf("[%d: %s %d]\n", vm->pc, instr_desc[instr], *(int16_t*)vm->bcode_fetch_fun(vm->pc+1,2));
}
else {
printf("[%d: %s]\n", vm->pc, instr_desc[instr]);
}
#endifbbzvm_step();
ASSERT(vm->state!=BBZVM_STATE_ERROR);
}
ASSERT_EQUAL(vm->state, BBZVM_STATE_DONE);
ASSERT_EQUAL(vm->error, BBZVM_ERROR_NONE);
vm->state=BBZVM_STATE_READY;
// Sending stigmergy message, will leak memory and eventually get an memory erroruint8_ti=0;
while (1) {
i++;
bbzmsg_payload_tpayload;
uint8_tbuff[] = {1, i, 0, __BBZSTRID_data, 0, 57, 2, 0, 1};
bbzringbuf_construct(&payload, buff, 1, 16);
payload.elsize=1;
payload.capacity=10;
payload.datastart=0;
payload.dataend=9;
bbzinmsg_queue_append(&payload);
bbzvm_process_inmsgs();
if(vm->error==BBZVM_ERROR_MEM){
break;
}
bbzvm_gc();
}
// Runs out of memoryASSERT_EQUAL(vm->state, BBZVM_STATE_ERROR);
ASSERT_EQUAL(vm->error, BBZVM_ERROR_MEM);
bbzvm_destruct();
fclose(fbcode);
}
Here is the buzz code from ressources/5_Onconflict.bzz
I did not test on Buzz, we only use BittyBuzz since we are on an embedded controller. It's been some time since I've checked this issues, I can try to reproduce it on Buzz
It seems when a stigmergy message causes an onconflict to be called, memory is leaked from the system, which eventually can cause an out of memory error. The error is probably caused in the following lines. I tried to investigate what was leaking memory exactly, but I'm not familiar enough with the garbage collection of the vm yet.
Here is the C code to reproduce
Here is the buzz code from
ressources/5_Onconflict.bzz
The text was updated successfully, but these errors were encountered: