From: John Wolfe Date: Wed, 19 Aug 2020 17:01:16 +0000 (-0700) Subject: Make peeking back into the stack work for back traces X-Git-Tag: stable-11.1.5~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36367e444682d554c784c8a1ae2da5d5d52e0f92;p=thirdparty%2Fopen-vm-tools.git Make peeking back into the stack work for back traces GCC 10 doesn't like peeking back before the end of an arrary (which is used to peek into the stack). Fix this. https://github.com/vmware/open-vm-tools/issues/429 --- diff --git a/open-vm-tools/lib/user/utilBacktrace.c b/open-vm-tools/lib/user/utilBacktrace.c index dca33d267..d3acd2dd0 100644 --- a/open-vm-tools/lib/user/utilBacktrace.c +++ b/open-vm-tools/lib/user/utilBacktrace.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2013-2020 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -343,7 +343,8 @@ UtilBacktraceFromPointerWithFunc(uintptr_t *basePtr, // IN: i, x[0], x[1], dli.dli_sname, dli.dli_fname, dli.dli_fbase); } else { - outFunc(outFuncData, "SymBacktrace[%d] %#08x eip %#08x \n", i, x[0], x[1]); + outFunc(outFuncData, "SymBacktrace[%d] %#08x eip %#08x \n", i, x[0], + x[1]); } x = (uintptr_t *) x[0]; } @@ -394,6 +395,7 @@ Util_Backtrace(int bugNr) // IN *----------------------------------------------------------------------------- */ + void Util_BacktraceWithFunc(int bugNr, // IN: Util_OutputFunc outFunc, // IN: @@ -413,7 +415,7 @@ Util_BacktraceWithFunc(int bugNr, // IN: if (bugNr == 0) { outFunc(outFuncData, "Backtrace:\n"); } else { - outFunc(outFuncData, "Backtrace for bugNr=%d\n",bugNr); + outFunc(outFuncData, "Backtrace for bugNr=%d\n", bugNr); } frames = backtrace(callstack, ARRAYSIZE(callstack)); for (i = 0; i < frames; i++) { @@ -431,13 +433,14 @@ Util_BacktraceWithFunc(int bugNr, // IN: } } #else - uintptr_t *x = (uintptr_t *) &bugNr; - if (bugNr == 0) { outFunc(outFuncData, "Backtrace:\n"); } else { - outFunc(outFuncData, "Backtrace for bugNr=%d\n",bugNr); + outFunc(outFuncData, "Backtrace for bugNr=%d\n", bugNr); } - UtilBacktraceFromPointerWithFunc(&x[-2], outFunc, outFuncData); + + UtilBacktraceFromPointerWithFunc(__builtin_frame_address(0), outFunc, + outFuncData); #endif } +