WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Core dump file is unavailable

Open stakemura opened this issue 10 years ago • 36 comments

  • A brief description Core dump file is not exported.
  • Expected results Core dump file is located on the current(+writable) directory. (based on general UNIX behavior)
  • Actual results (with terminal output if applicable) No file
  • Your Windows build number Build 14951 (Ubuntu 16.04)
  • Steps / All commands required to reproduce the error from a brand new installation
ulimit -c unlimited
echo "main(){raise(11);}" > test.c; gcc  -g -o test.o test.c; strace ./test.o
  • Strace of the failing command (without some GCC warnings)
execve("./test.o", ["./test.o"], [/* 16 vars */]) = 0                                                               
brk(NULL)                               = 0x14c9000                                                                 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)                                     
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6ec8e70000                           
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)                                     
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3                                                                    
fstat(3, {st_mode=S_IFREG|0644, st_size=24473, ...}) = 0                                                            
mmap(NULL, 24473, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f6ec8e6a000                                                    
close(3)                                = 0                                                                         
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)                                     
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3                                                     
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832                              
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0                                                          
mmap(NULL, 3967488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f6ec8830000                          
mprotect(0x7f6ec89f0000, 2093056, PROT_NONE) = 0                                                                    
mmap(0x7f6ec8bef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f6ec8bef000
mmap(0x7f6ec8bf5000, 14848, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f6ec8bf5000      
close(3)                                = 0                                                                         
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6ec8e60000                           
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6ec8e50000                           
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6ec8e40000                           
arch_prctl(ARCH_SET_FS, 0x7f6ec8e50700) = 0                                                                         
mprotect(0x7f6ec8bef000, 16384, PROT_READ) = 0                                                                      
mprotect(0x600000, 4096, PROT_READ)     = 0                                                                         
mprotect(0x7f6ec8e25000, 4096, PROT_READ) = 0                                                                       
munmap(0x7f6ec8e6a000, 24473)           = 0                                                                         
gettid()                                = 4601                                                                      
tgkill(4601, 4601, SIGSEGV)             = 0                                                                         
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_TKILL, si_pid=4601, si_uid=1000} ---                                      
+++ killed by SIGSEGV (core dumped) +++                                                                             
Segmentation fault (core dumped)                                                                                    
  • Required packages and commands to install
    • build-essential

stakemura avatar Oct 24 '16 08:10 stakemura

This is a known issue that we are aware of, it is something we are investigating.

misenesi avatar Oct 24 '16 17:10 misenesi

how is the progress? can I debug on windows bash?

isfull avatar Jan 27 '17 07:01 isfull

ping -- I just hit this; it's still an issue on build 15046. (I imagine that's not too surprising, but, keeping it on peoples' radar.)

aseering avatar Mar 06 '17 15:03 aseering

Any news on this or any progress?

gurpreetshanky avatar May 21 '18 02:05 gurpreetshanky

User voice is here since it wasn't mentioned above.

therealkenc avatar May 22 '18 06:05 therealkenc

It's still an issue today, even after updating to Ubuntu 18.04..

iFanze avatar May 23 '18 12:05 iFanze

@terrywh I've just tried the vote button again this morning and it seems to work fine here (Chrome 66 on Win 7)

wolf99 avatar Jun 05 '18 11:06 wolf99

thanks, it seems something is wrong with my network(failed to load js file on that page), after using a proxy everything works fine. @wolf99

terrywh avatar Jun 05 '18 11:06 terrywh

it's been a while, and I'm running into this on build 18262... have there been any updates?

HotelCalifornia avatar Oct 27 '18 04:10 HotelCalifornia

As mentioned in https://github.com/Microsoft/WSL/issues/3657#issuecomment-437678770 there seems to be a general issue with the default signal handler(s) not operating as expected in WSL.

In my case it becomes a blocker while debugging scientific/numerical software. Typically, I enable trapping of floating-point exceptions like divide-by-zero, overflow, invalid (domain error). Then, running the software under gdb, it would normally stop at the SIGFPE signal whenever any of such conditions occurs and I can inspect the backtrace, local variables etc. and ultimately fix bugs a lot easier. In WSL, the program just exits in those cases without gdb stopping, making debugging significantly harder to the point where I have to switch to native Linux.

What's missing to get this working as it should?

letmaik avatar Nov 11 '18 16:11 letmaik

Echoing the sentiments stated by everyone here; this bug makes developing C++ programs very difficult. Are there any work-arounds for the time being?

qwergram avatar Jan 16 '19 21:01 qwergram

Only that: don't want core dumps. Or don't use WSL but go back and don't use Windows to develop then (ssh remote development or VM or Linux on desktop). Nothing else that comes into my mind just yet.

christianparpart avatar Jan 17 '19 07:01 christianparpart

Please implement that!

zxbuaa avatar Mar 22 '19 16:03 zxbuaa

Under the fast ring feature WSL2 (Ubuntu 18.04.3 LTS), the core dump file appeared. (see Installation Instructions for WSL 2) However, it appeared as an empty file in the working folder. Fortunately, the post on stackoverflow comes to rescue. (see Empty core dump file after Segmentation fault)

Use sysctl to set /proc/sys/kernel/core_pattern=/tmp/core sudo sysctl -w kernel.core_pattern=/tmp/core (see Why is editing core_pattern restricted?)

Now, the command gdb with core dump file works as expected. gdb ./testCoreDump /tmp/core

I think it is the best workaround I can find now.

grantyuc avatar Oct 28 '19 07:10 grantyuc

Any updates for this issue? Or even any way to workaround?

fly-potato-100 avatar Feb 19 '20 01:02 fly-potato-100

Under the fast ring feature WSL2 (Ubuntu 18.04.3 LTS), the core dump file appeared. (see Installation Instructions for WSL 2) However, it appeared as an empty file in the working folder. Fortunately, the post on stackoverflow comes to rescue. (see Empty core dump file after Segmentation fault)

Use sysctl to set /proc/sys/kernel/core_pattern=/tmp/core sudo sysctl -w kernel.core_pattern=/tmp/core (see Why is editing core_pattern restricted?)

Now, the command gdb with core dump file works as expected. gdb ./testCoreDump /tmp/core

I think it is the best workaround I can find now.

it works for me! you saved my day! thank you very much!

ianzone avatar Mar 25 '20 19:03 ianzone

~Doesn't work for me:~

/mnt/c $ sudo sysctl kernel.core_pattern
sysctl: cannot stat /proc/sys/kernel/core_pattern: No such file or directory
/mnt/c $ sudo sysctl -w kernel.core_pattern=/tmp/core
sysctl: cannot stat /proc/sys/kernel/core_pattern: No such file or directory

~Using WSL2. Any ideas?~

Edit: sorry I was wrong, my distro was still using WSL1. I updated to the new windows insider build and used instructions on https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel.

AndrejMitrovic avatar Mar 26 '20 03:03 AndrejMitrovic

@therealkenc "fixed in WSL2" isn't a great resolution for the many of us left on WSL 1 for the foreseeable. In fact its a pretty poor response given that WSL2 isn't even available to the vast majority of normal Windows users yet (never mind those held back to pre-1909 versions of Window due to, eg, corporate update policies)

wolf99 avatar Jun 05 '20 21:06 wolf99

@wolf99 I do agree with you, however the reality is that MS has limited resources (as do we all), and they've been shifting most of their WSL dev time to WSL2.

I'd be happy to be wrong, but reading between the lines leads me to believe that most issues such as this one which are working correctly in WSL2 won't be addressed in WSL1 anytime in the foreseeable future, if at all.

gurnec avatar Jun 05 '20 21:06 gurnec

@gurnec Thanks for the link I'd admit that if 2004 had rolled out fully or even to the majority of users, then that would be at least logical. But in reality 2004 is only in the early stages of what promises to be a pretty long roll-out.

My machine only received 1909 about March (4 months after initial "release"), if 2004 follows a similar trend I won't see 2004 until September at least. To simply abandon the majority of users seems harebrained at best.

What seems to be happening morso is development aimed at people on faster rings. While I can see those rings provide good feedback, developing solely with those foremost in mind is probably part of the issue for these troubled OS roll-outs.

wolf99 avatar Jun 05 '20 23:06 wolf99