I have a struct containing a list of integers (represent the graph as an array of linked lists). When I push_back an int into a list in the begining of my code I get this wonderful error:
at raise.c. function GI_raise (sig=sig@entry=6) on line 56 at abort.c. function GI_abort () on line 89 at malloc.c.
function malloc_assert ( assertion=assertion@entry=0x7ffff6b1c198
"(old_top == (((mbinptr) (((char ) &((av)->bins[((1) - 1) 2]))
- builtin_offsetof (struct malloc_chunk, fd)))) && old_size
== 0) || ((unsigned long) (old_size) >= (unsigned
long)((((__builtin_offs"..., file=file@entry=0x7ffff6b17c85 "malloc.c",
<__func__.11292> "sysmalloc") on line 293 at malloc.c. function sysmalloc (av=0x7ffff6d59620 , nb=32) on line 2369 at malloc.c. function GIlibcmalloc (bytes=24) on line 2891 at new_allocator.h. function gnu_cxx::new_allocator >::allocate (this=0x6030b0, n=1) on line 104 at stl_list.h. function std::_List_base >::_M_get_node (this=0x6030b0) on line 343 at stl_list.h. function std::list >::_M_create_node (this=0x6030b0) on line 511
I tried adding something like graph.links.push_back(3), not only does that line not crash but it removes this crash further on in the code where the links are read and added. However, it causes a bug later on cause I have no reason to add a link there like that.
I use the exact same type of thing in other problems and had no issues, what is going on? I googled around for this type of error, didn't find anything exactly like mine but the solution to the problem revoled around updating the compiler...
Edit: Found a mistake in my code, fixing it removed the problem, but I don't understand why because that bug had not much to do with the line on which the program was crashing.
Edit2: Solved using BFS (=shortest path in unweighted undirected graph). Using BFS to find closest edge of a certain criteria to the agent. I run it about 3 times to look in priority for this type of thing...in second priority for that type of thing...etc...