I've been given an assignment so simulate a user-level thread library using signals, setjmp and longjmp c functions. Basically, the program include memory allocation for each 'thread', and using long jump and signals to simulate non-direct code flow and preemption.
When I run the valgrind tool, I get messages in the following form: """
Invalid write of size 8
==19100== at 0x560020F: __sigsetjmp (setjmp.S:36)
==19100== by 0x403EC3: switchThreads(bool, bool, bool) (uthreads.cpp:673)
==19100== by 0x403DE6: signalHandler(int) (uthreads.cpp:652)
==19100== by 0x56004EF: ??? (in /lib/x86_64-linux-gnu/libc-2.13.so)
==19100== by 0x404D93: t1() (tal3.cpp:23)
==19100== Address 0x5959c90 is 48 bytes inside a block of size 4,312 alloc'd
==19100== at 0x4C2851B: operator new(unsigned long, std::nothrow_t const&) (vg_replace_malloc.c:316)
==19100== by 0x402E67: uthread_spawn(void (*)()) (uthreads.cpp:358)
==19100== by 0x404DD6: main (a3.cpp:41)
"""
I've read some forums and documentation of this tool, and from my understanding, it seems the long jumps and 'setjmp' (as long as signal handling jumps) are not supported in valgrind, thus cause what seems to be as memory problems - but I couldn't come up with a definite answer.
Would appreciate your help. Thanks.