From e63c842be91d032043b742b49835ecac59c561d1 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 23 Feb 2021 11:07:27 +0100 Subject: [PATCH] core.internal.backtrace.dwarf: Fix segfault regression in case executable cannot be opened Introduced by #3322. `image.baseAddress()` must not be called if `!image.isValid()`, otherwise a segfault occurs if the executable file/image could not be opened (e.g., because of the process changing the initial working dir and https://issues.dlang.org/show_bug.cgi?id=21656). --- src/core/internal/backtrace/dwarf.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/internal/backtrace/dwarf.d b/src/core/internal/backtrace/dwarf.d index 2a172709c5..9e1b39d167 100644 --- a/src/core/internal/backtrace/dwarf.d +++ b/src/core/internal/backtrace/dwarf.d @@ -187,7 +187,7 @@ int traceHandlerOpApplyImpl(size_t numFrames, if (!image.isValid()) - return locations[startIdx .. $].processCallstack(null, image.baseAddress, dg); + return locations[startIdx .. $].processCallstack(null, 0, dg); // find address -> file, line mapping using dwarf debug_line return image.processDebugLineSectionData(