'Segmentation fault (core dumped) on ubunto WSL

I am trying to access the core dumped file to start debugging but it never shows.

I tried many solutions such as:

  • Giving it a size ulimit -c unlimited
  • making the directory writable so it can create such file
  • I checked the sysctl kernel.core_pattern but ends sysctl: cannot stat /proc/sys/kernel/core_pattern: No such file or directory probably it didn't create any core files anywhere although it produces me core dumped
  • I though its a problem with system so I tried this link in which I cleared the locks and repository cache and updated the apt-get and nothing happened at the end

I dont know whats the problem if someone could explain me this and help me with a solution



Solution 1:[1]

The statement that works with g++ and C++ multithreading (with pthread.h) is :

g++ -static -pthread -D_GLIBCXX_GTHREAD_USE_WEAK=0 -std=c++0x -Wl,--whole-archive -lpthread -Wl,--no-whole-archive <yourCode.c>

Thanks to https://www.medo64.com/2021/05/segmentation-fault-using-threads-with-static-compile/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LinFelix