System: Jetson AGX Xavier, example ubuntu image from NVIDIA, Kernel 4.9.140, JetPack 4.4 (L4T R32.4.3).
Following minimalized code example reproduces it:
#include <iostream
>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;
// Minimalized example out of QProcess (Qt 5.14.2)
void forker()
{
pid_t pid = fork();
if (pid == 0)
{
cout << “PID child process: " << getpid() << endl;
char* argv[]
= {”/bin/ls", “-l”, “/home/ “, NULL};
execv(”/bin/ls”, argv);
exit(0);
}
else if (pid>
0)
{
cout << "PID parent process: " << getpid() << endl;
wait(NULL);
}
else
{
cerr << “Error!”;
exit(1);
}
}static void initValues(unsigned char result[10])
{
for (int i = 0; i<
10; i++) {
result[i] = 3;
}
}int main(int, const char * const
[]
)
{
static unsigned char data1[10];
initValues(data1);cudaFree(0);
unsigned char(*gpu_ptr_1)[10UL];
cudaMalloc(&gpu_ptr_1, 10UL);
cudaMemcpy(*gpu_ptr_1, data1, 10UL, cudaMemcpyHostToDevice);cout << " after first malloc " << endl;
sleep(2);
forker();
sleep(2);cout << " after forker " << endl;
static unsigned char data2[10];
initValues(data2);unsigned char(*gpu_ptr_2)[10UL];
cudaMalloc(&gpu_ptr_2, 10UL);
cudaMemcpy(*gpu_ptr_2, data2, 10UL, cudaMemcpyHostToDevice);cout << " after last malloc " << endl;
}