Skip to content

Commit 20e6e2f

Browse files
authored
Merge pull request #1275 from microsoft/core-pattern
Update wslgd to use the new wsl coredump infrastructure
2 parents c8f6e52 + 3c845fa commit 20e6e2f

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ body:
6363
id: dumps
6464
attributes:
6565
label: "WSL dumps:"
66-
description: "Attach any dump files from `/mnt/wslg/dumps`, such as core.weston, if exists."
66+
description: "Attach any dump files from `%tmp%\wsl-crashes`, such as core.weston, if exists. If running an older version, the dump files can be found in `/mnt/wslg/dumps`"
6767
validations:
6868
required: false
6969
- type: textarea

WSLGd/main.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ constexpr auto c_x11RuntimeDir = SHARE_PATH "/.X11-unix";
2727
constexpr auto c_xdgRuntimeDir = SHARE_PATH "/runtime-dir";
2828
constexpr auto c_stdErrLogFile = SHARE_PATH "/stderr.log";
2929

30-
constexpr auto c_coreDir = SHARE_PATH "/dumps";
31-
constexpr auto c_corePatternDefault = "core.%e";
32-
constexpr auto c_corePatternFile = "/proc/sys/kernel/core_pattern";
33-
constexpr auto c_corePatternEnv = "WSL2_WSLG_CORE_PATTERN";
34-
3530
constexpr auto c_sharedMemoryMountPoint = "/mnt/shared_memory";
3631
constexpr auto c_sharedMemoryMountPointEnv = "WSL2_SHARED_MEMORY_MOUNT_POINT";
3732
constexpr auto c_sharedMemoryObDirectoryPathEnv = "WSL2_SHARED_MEMORY_OB_DIRECTORY";
@@ -346,38 +341,11 @@ try {
346341
std::string serviceIdEnvString("WSLG_SERVICE_ID=");
347342
serviceIdEnvString += ToServiceId(address.svm_port);
348343

349-
// "ulimits -c unlimited" for core dumps.
350344
struct rlimit limit;
351-
limit.rlim_cur = RLIM_INFINITY;
352-
limit.rlim_max = RLIM_INFINITY;
353-
THROW_LAST_ERROR_IF(setrlimit(RLIMIT_CORE, &limit) < 0);
354-
355345
THROW_LAST_ERROR_IF(getrlimit(RLIMIT_NOFILE, &limit) < 0);
356346
limit.rlim_cur = limit.rlim_max;
357347
THROW_LAST_ERROR_IF(setrlimit(RLIMIT_NOFILE, &limit) < 0);
358348

359-
// create folder to store core files.
360-
std::filesystem::create_directories(c_coreDir);
361-
THROW_LAST_ERROR_IF(chmod(c_coreDir, 0777) < 0);
362-
363-
// update core_pattern.
364-
{
365-
wil::unique_file corePatternFile(fopen(c_corePatternFile, "w"));
366-
if (corePatternFile.get()) {
367-
// combine folder path and core pattern.
368-
std::string corePatternFullPath(c_coreDir);
369-
corePatternFullPath += "/";
370-
auto corePattern = getenv(c_corePatternEnv);
371-
if (corePattern) {
372-
corePatternFullPath += corePattern;
373-
} else {
374-
corePatternFullPath += c_corePatternDefault; // set to default core_pattern.
375-
}
376-
// write to core_pattern file.
377-
THROW_LAST_ERROR_IF(fprintf(corePatternFile.get(), "%s", corePatternFullPath.c_str()) < 0);
378-
}
379-
}
380-
381349
// Set shared memory mount point to env when available.
382350
if (!isSharedMemoryMounted ||
383351
(setenv(c_sharedMemoryMountPointEnv, c_sharedMemoryMountPoint, true) < 0)) {

0 commit comments

Comments
 (0)