Note that there are some explanatory texts on larger screens.

plurals
  1. POReading from stdin blocks at approx. 60 kB
    primarykey
    data
    text
    <p>When transforming files with a self-implemented burrows-wheeler algorithm my program gets stuck when reading files with filesize above 59 kB. Basically I'm starting my program in terminal:</p> <pre><code>./BW encode 4 &lt; test </code></pre> <p>where 4 stands for 4*1024 bytes. As told before when processing files (raw data, textfiles etc.) with filesize under 59 kB no problems occure.</p> <p>code where data is processed and send to stdout:</p> <pre><code>void encodeBlock(unsigned char* str,long length){ unsigned int i, out_rownum; unsigned char **str_matr, *out_str, *prnt_rt_str2, *prnt_rt_str1; str_matr = (unsigned char**) calloc(length,sizeof(unsigned char*)); out_str = (unsigned char*) calloc(length+1,sizeof(unsigned char)); // make matrix with rotationstrings of str (by saving pointer to first character) for(i=0;i&lt;(unsigned int) length;i++){ str_matr[i] = &amp;str[i]; } // sorting matrix glob_strt = &amp;str[0]; glob_length = length; qsort(str_matr,length,sizeof(unsigned char*),strCmpEnc); out_str[length] = '\0'; for(i=0;i&lt;(unsigned int) length;i++){ prnt_rt_str1 = printRotStr(length,&amp;str[0],str_matr[i]); prnt_rt_str2 = printRotStr(length,&amp;prnt_rt_str1[0],&amp;prnt_rt_str1[length-1]); if(memcmp(str,prnt_rt_str2,length) == 0){ out_rownum = i; } out_str[i] = prnt_rt_str1[length-1]; } printf("(%d ",out_rownum); fwrite((unsigned char*) out_str, 1, length, stdout); printf(")\n"); free(prnt_rt_str1); free(prnt_rt_str2); free(str_matr); free(out_str); } </code></pre> <p>and code where data is received from stdin</p> <pre><code>void encode(unsigned short int num, unsigned int block_size){ long b_length,length; unsigned char* buffer; freopen(NULL, "rb", stdin); buffer = (unsigned char*) calloc(block_size+1,sizeof(unsigned char)); length = fread((unsigned char*) buffer, 1, block_size, stdin); if(length == 0){ // file empty }else{ b_length = length; printf("##B-W:%ld##\n",length); while(length == b_length){ buffer[block_size] = '\0'; encodeBlock(buffer,length); length = fread((unsigned char*) buffer, 1, block_size, stdin); } if(length != 0){ printf("##B-W:%ld##\n",length); buffer[length] = '\0'; encodeBlock(buffer,length); } } free(buffer); } </code></pre> <p>When it gets stuck it usually terminates and 'Killed' appears on screen. I'm working on linux OS. </p> <p>Result using valgrind: The program gets stuck and my whole system hangs. I'm not able to see any debugging result because I have to shutdown my system manually. </p> <p>UPDATE: The reason behind the blocked reading (after 59kB) was that there was no space left on the heap due of many mem leaks. I solved this problem and finally reading works fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload