Turns out the pragma
fix was just co-incidental.
I did a couple of other tests.
This time I printed the complete memory mapping as follows in cfg_clone_global
:
LOG(L_ERR,"START");
LOG(L_ERR,"block address: %p",(void *)block);
LOG(L_ERR,"vars address: %p",(void *)(block->vars));
LOG(L_ERR,"Total allocated size: %d",(sizeof(cfg_block_t)+cfg_block_size-1));
int count = 0;
for (group = cfg_group;
group;
group=group->next
){
count = count + 1;
LOG(L_ERR,"Group number: %d", count);
LOG(L_ERR,"Group location from start %d",(int)(((void *)(CFG_GROUP_DATA(block, group)))-((void *)block)));
LOG(L_ERR,"Group size: %d", group->size);
}
I did two tests:
Test 1: With pragma block around cfg_block_t only
Test 2: With the complete patch applied
Test1 output:
Memory mapping (with pragma for cfg_block_t)
============================================
(Error persists and variables takes random values)
## All the locations below assume that the address starts at 0
START
block address: 0x7f6c37550d98
vars address: 0x7f6c37550d9c
Total allocated size: 1160
Group number: 1
Group location from start 20
Group size: 248
Group number: 2
Group location from start 284
Group size: 56
Group number: 3
Group location from start 356
Group size: 4
Group number: 4
Group location from start 380
Group size: 4
Group number: 5
Group location from start 404
Group size: 4
Group number: 6
Group location from start 428
Group size: 176
Group number: 7
Group location from start 620
Group size: 104
Group number: 8
Group location from start 740
Group size: 200
Group number: 9
Group location from start 956
Group size: 16
Group number: 10
Group location from start 988
Group size: 172
## still one extra byte
As you can see 988+172=1160 but the address is starting from 0 here so we should have assigned 1161 bytes of memory.
Test2 output:
Memory mapping (with the complete patch applied)
================================================
(Error persists and variables takes random values)
## All the locations below assume that the address starts at 0
START
block address: 0x7fc1537af4b8
vars address: 0x7fc1537af4bc
Total allocated size: 1160
Group number: 1
Group location from start 20
Group size: 248
Group number: 2
Group location from start 284
Group size: 56
Group number: 3
Group location from start 356
Group size: 4
Group number: 4
Group location from start 380
Group size: 4
Group number: 5
Group location from start 404
Group size: 4
Group number: 6
Group location from start 428
Group size: 176
Group number: 7
Group location from start 620
Group size: 104
Group number: 8
Group location from start 740
Group size: 200
Group number: 9
Group location from start 956
Group size: 16
Group number: 10
Group location from start 988
Group size: 172
## still one extra byte
Not sure why the first group starts from location 20 but I can say with confidence that using pragma
blocks doesn't solve this issue.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.