segmentation fault on simple example program due to null pointer reference
Hi, trying Vuda for the first time here. To get the simple example to compile, I had to fix a few errors in the inc folder that my g++ (version 12.2) was complaining about. I'll file those changes as a PR later, they are minor and not relevant.
But the main problem i'm running into getting the examples to work is that I get a segfault when using cudaMemcpy.
This is the backtrace from GDB:
(gdb) backtrace
#0 __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:496
#1 0x0000555555575cfb in vuda::detail::logical_device::memcpyToDevice(std::thread::id, void*, void const*, unsigned long, unsigned int) ()
#2 0x0000555555578bd7 in vuda::memcpy(void*, void const*, unsigned long, vuda::memcpyKind, unsigned int) ()
#3 0x0000555555578cda in cudaMemcpy(void*, void const*, unsigned long, vuda::memcpyKind) ()
#4 0x000055555555c7d0 in main ()
Using printf, i further pinpointed the issue to the std::memcpy line here:
https://github.com/jgbit/vuda/blob/7e7c3348fafa111098c7ec36cc71d4d864753f87/inc/state/logicaldevice.inl#L490-L496
Apparently src_ptr is non-null, but src_ptr->get_memptr() is returning null. Internally this returns m_ptrMemBlock->get_ptr(), which returns a private class member void* m_ptr.
My first thought was that maybe one of the cudaMalloc calls failed, so I tried checking the cudaError_t return values, but everything is returning cudaSuccess. So this seems like an internal bug, but i'm not sure how to fix it, because I don't know how this pointer is supposed to be populated. Everywhere my print statements show it just gets set to null.