The bulk of this was written on Nov 16th before I finished CS137 at UW. Most of this stuff still stands.


(Also, why I’m glad I’m using Git, why I love Stack overflow, and frak yes Valgrind)

My CS assignment 9 (the legendarily hard one that the upper years warned us about) is giving all sorts of interesting errors. “Multiple definition of functions” is the most recent one and the strangest yet to debug (Gets ridiculously tech heavy from here):

/tmp/ccfcWxYr.o: In function `polyCreate':
poly.c:19: multiple definition of `polyCreate'
/tmp/ccNDcsMm.o:poly.c:19: first defined here

The strange thing was, bisecting with Git showed only a single change that I made that generated the whole bunch of errors:

67 - double a[] = (*p).a;
67 + double *a = &(*p).a;

Which made no sense – That single line had nothing to do with multiple declarations. So I tracked down why I was getting the errors. (Stack Overflow #1) Turns out I had made a typo in my code and included my .c instead of my .h file, so the single file get double processed. (At least I now know why the header file is included rather than the main C file.)

The next error I got was the massively unreadable

poly: malloc.c:3096: sYSMALLOc: Assertion `(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_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

Stack overflow helped again (this is becoming a recurring theme), and suggested a memory bug. Whipping out valgrind, and oh hey:

==45433== Invalid write of size 8
==45433==    at 0x400CB2: polyCopy (poly.c:143)
==45433==    by 0x40105C: main (polytest.c:9)
==45433==  Address 0x5435248 is 0 bytes after a block of size 8 alloc’d

That was easy, so fixing an invalid memory access later, stuff works as it should.

Now to run & test in Marmoset. Joy joy joy.

, , ,

  1. No comments yet.
(will not be published)