Note that there are some explanatory texts on larger screens.

plurals
  1. POmalloc.c "sYSMALLOC: Assertion" in execution with C++ project
    primarykey
    data
    text
    <p><strong>FINAL_EDIT: Found the problem, in a for loop the counter, that was used as an index as well, was greater than the number of the elements of the array. The weird thing about it, was that I wasn't receiving segmentation fault and instead the error I've mentioned. Why was that?</strong></p> <p><strong>Thank you for your help!<br> <em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>_</strong></p> <p>I have a project in C++ and am getting this error (NOT ALWAYS) and if a specific global variable that acts as a size of an <code>int</code> array. </p> <p><strong>NEW EDIT_1->I haven't used the <code>new</code> operator at all except for the main function that I am declaring a new array of pointers to objects of a class. Like this:</strong></p> <pre><code>Student* test[NUM_AM]; for(int i=0; i&lt;NUM_AM; i++) { test[i] = new Student(random_elements); } </code></pre> <p>Is there any way to find the line that causes this? </p> <p>The error is this (copied the output of gdb):</p> <pre><code>malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &amp;((av)-&gt;bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) &amp;&amp; old_size == 0) || ((unsigned long) (old_size) &gt;= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) &amp; ~((2 * (sizeof(size_t))) - 1))) &amp;&amp; ((old_top)-&gt;size &amp; 0x1) &amp;&amp; ((unsigned long)old_end &amp; pagemask) == 0)' failed. Program received signal SIGABRT, Aborted. 0x00007ffff75563a5 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. in ../nptl/sysdeps/unix/sysv/linux/raise.c </code></pre> <p>Also valgrind gives this:</p> <pre><code>==6775== HEAP SUMMARY: ==6775== in use at exit: 560 bytes in 35 blocks ==6775== total heap usage: 35 allocs, 0 frees, 560 bytes allocated ==6775== ==6775== LEAK SUMMARY: ==6775== definitely lost: 560 bytes in 35 blocks ==6775== indirectly lost: 0 bytes in 0 blocks ==6775== possibly lost: 0 bytes in 0 blocks ==6775== still reachable: 0 bytes in 0 blocks ==6775== suppressed: 0 bytes in 0 blocks ==6775== Rerun with --leak-check=full to see details of leaked memory ==6775== ==6775== For counts of detected and suppressed errors, rerun with: -v ==6775== Use --track-origins=yes to see where uninitialised values come from ==6775== ERROR SUMMARY: 806 errors from 2 contexts (suppressed: 4 from 4) </code></pre> <p>Thank you for your time.</p> <p><strong>NEW_EDIT2:</strong> I ran the application with:</p> <pre><code>valgrind --leak-check=full --track-origins=yes ./out and NUM_AM = 25; </code></pre> <p>This is the output I got is here at pastebin: <a href="http://pastebin.com/xvkCVnCD" rel="nofollow"> here! </a></p> <p><strong>NEW_EDIT3:</strong> I should mention that the program creates students with an ID and assigns them a true/false value at a bool array and 2 bool variables. The variable NUM_AM is used as an index of the static arrays declared as class members. Also, NUM_AM is used in several functions when searching for their ID.</p> <p>With NUM_AM > 22 the error can happen even after the creation of the 1st student. With NUM_AM &lt; = 21, I haven't been able to reproduce the error with multiple serial executions of the program.</p>
    singulars
    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