mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 01:44:26 +00:00
BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting
This commit is contained in:
parent
573f00c66c
commit
68e30de763
@ -1,5 +1,6 @@
|
|||||||
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.3.1
|
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.3.1
|
||||||
- BUGFIX: Torrents paused due to an I/O error were displayed as queued
|
- BUGFIX: Torrents paused due to an I/O error were displayed as queued
|
||||||
|
- BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting
|
||||||
- I18N: Updated Bulgarian and Greek translations
|
- I18N: Updated Bulgarian and Greek translations
|
||||||
|
|
||||||
* Fri Jan 9 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.3.0
|
* Fri Jan 9 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.3.0
|
||||||
|
@ -6,6 +6,7 @@ arg: with-libtorrent-lib=[path], Path to libtorrent-rasterbar library files
|
|||||||
arg: with-libtorrent-static-lib=[path], Path to libtorrent-rasterbar .a file
|
arg: with-libtorrent-static-lib=[path], Path to libtorrent-rasterbar .a file
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
|
// see Conf::findPkgConfig
|
||||||
class qc_libtorrent_rasterbar : public ConfObj
|
class qc_libtorrent_rasterbar : public ConfObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -45,6 +45,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include "stacktrace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -59,6 +61,13 @@ QApplication *app;
|
|||||||
qDebug("Catching SIGTERM, exiting cleanly");
|
qDebug("Catching SIGTERM, exiting cleanly");
|
||||||
app->exit();
|
app->exit();
|
||||||
}
|
}
|
||||||
|
void sigsegvHandler(int) {
|
||||||
|
std::cerr << "\n\n*************************************************************\n";
|
||||||
|
std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n";
|
||||||
|
print_stacktrace();
|
||||||
|
std::raise(SIGINT);
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void useStyle(QApplication *app, int style){
|
void useStyle(QApplication *app, int style){
|
||||||
@ -177,6 +186,10 @@ int main(int argc, char *argv[]){
|
|||||||
app->installTranslator(&translator);
|
app->installTranslator(&translator);
|
||||||
app->setApplicationName(QString::fromUtf8("qBittorrent"));
|
app->setApplicationName(QString::fromUtf8("qBittorrent"));
|
||||||
app->setQuitOnLastWindowClosed(false);
|
app->setQuitOnLastWindowClosed(false);
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
signal(SIGTERM, sigtermHandler);
|
||||||
|
signal(SIGSEGV, sigsegvHandler);
|
||||||
|
#endif
|
||||||
// Read torrents given on command line
|
// Read torrents given on command line
|
||||||
QStringList torrentCmdLine = app->arguments();
|
QStringList torrentCmdLine = app->arguments();
|
||||||
// Remove first argument (program name)
|
// Remove first argument (program name)
|
||||||
@ -184,9 +197,6 @@ int main(int argc, char *argv[]){
|
|||||||
GUI *window = new GUI(0, torrentCmdLine);
|
GUI *window = new GUI(0, torrentCmdLine);
|
||||||
splash->finish(window);
|
splash->finish(window);
|
||||||
delete splash;
|
delete splash;
|
||||||
#ifndef Q_WS_WIN
|
|
||||||
signal(SIGTERM, sigtermHandler);
|
|
||||||
#endif
|
|
||||||
int ret = app->exec();
|
int ret = app->exec();
|
||||||
delete window;
|
delete window;
|
||||||
delete app;
|
delete app;
|
||||||
|
@ -87,6 +87,7 @@ contains(DEBUG_MODE, 0) {
|
|||||||
}
|
}
|
||||||
#QMAKE_CXXFLAGS_RELEASE += -fwrapv
|
#QMAKE_CXXFLAGS_RELEASE += -fwrapv
|
||||||
#QMAKE_CXXFLAGS_DEBUG += -fwrapv
|
#QMAKE_CXXFLAGS_DEBUG += -fwrapv
|
||||||
|
unix:QMAKE_LFLAGS_SHAPP += -rdynamic
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += "libtorrent-rasterbar libcurl"
|
PKGCONFIG += "libtorrent-rasterbar libcurl"
|
||||||
@ -177,7 +178,8 @@ HEADERS += GUI.h \
|
|||||||
TrackersAdditionDlg.h \
|
TrackersAdditionDlg.h \
|
||||||
searchTab.h \
|
searchTab.h \
|
||||||
console_imp.h \
|
console_imp.h \
|
||||||
ico.h
|
ico.h \
|
||||||
|
stacktrace.h
|
||||||
FORMS += MainWindow.ui \
|
FORMS += MainWindow.ui \
|
||||||
options.ui \
|
options.ui \
|
||||||
about.ui \
|
about.ui \
|
||||||
|
94
src/stacktrace.h
Normal file
94
src/stacktrace.h
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// stacktrace.h (c) 2008, Timo Bingmann from http://idlebox.net/
|
||||||
|
// published under the WTFPL v2.0
|
||||||
|
|
||||||
|
#ifndef _STACKTRACE_H_
|
||||||
|
#define _STACKTRACE_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <cxxabi.h>
|
||||||
|
|
||||||
|
/** Print a demangled stack backtrace of the caller function to FILE* out. */
|
||||||
|
static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63)
|
||||||
|
{
|
||||||
|
fprintf(out, "stack trace:\n");
|
||||||
|
|
||||||
|
// storage array for stack trace address data
|
||||||
|
void* addrlist[max_frames+1];
|
||||||
|
|
||||||
|
// retrieve current stack addresses
|
||||||
|
int addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*));
|
||||||
|
|
||||||
|
if (addrlen == 0) {
|
||||||
|
fprintf(out, " <empty, possibly corrupt>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolve addresses into strings containing "filename(function+address)",
|
||||||
|
// this array must be free()-ed
|
||||||
|
char** symbollist = backtrace_symbols(addrlist, addrlen);
|
||||||
|
|
||||||
|
// allocate string which will be filled with the demangled function name
|
||||||
|
size_t funcnamesize = 256;
|
||||||
|
char* funcname = (char*)malloc(funcnamesize);
|
||||||
|
|
||||||
|
// iterate over the returned symbol lines. skip the first, it is the
|
||||||
|
// address of this function.
|
||||||
|
for (int i = 2; i < addrlen; i++)
|
||||||
|
{
|
||||||
|
char *begin_name = 0, *begin_offset = 0, *end_offset = 0;
|
||||||
|
|
||||||
|
// find parentheses and +address offset surrounding the mangled name:
|
||||||
|
// ./module(function+0x15c) [0x8048a6d]
|
||||||
|
//fprintf(out, "%s TT\n", symbollist[i]);
|
||||||
|
for (char *p = symbollist[i]; *p; ++p)
|
||||||
|
{
|
||||||
|
if (*p == '(')
|
||||||
|
begin_name = p;
|
||||||
|
else if (*p == '+')
|
||||||
|
begin_offset = p;
|
||||||
|
else if (*p == ')' && begin_offset) {
|
||||||
|
end_offset = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (begin_name && begin_offset && end_offset
|
||||||
|
&& begin_name < begin_offset)
|
||||||
|
{
|
||||||
|
*begin_name++ = '\0';
|
||||||
|
*begin_offset++ = '\0';
|
||||||
|
*end_offset = '\0';
|
||||||
|
|
||||||
|
// mangled name is now in [begin_name, begin_offset) and caller
|
||||||
|
// offset in [begin_offset, end_offset). now apply
|
||||||
|
// __cxa_demangle():
|
||||||
|
|
||||||
|
int status;
|
||||||
|
char* ret = abi::__cxa_demangle(begin_name,
|
||||||
|
funcname, &funcnamesize, &status);
|
||||||
|
if (status == 0) {
|
||||||
|
funcname = ret; // use possibly realloc()-ed string
|
||||||
|
fprintf(out, " %s : %s+%s %s\n",
|
||||||
|
symbollist[i], funcname, begin_offset, ++end_offset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// demangling failed. Output function name as a C function with
|
||||||
|
// no arguments.
|
||||||
|
fprintf(out, " %s : %s()+%s %s\n",
|
||||||
|
symbollist[i], begin_name, begin_offset, ++end_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// couldn't parse the line? print the whole line.
|
||||||
|
fprintf(out, " %s\n", symbollist[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(funcname);
|
||||||
|
free(symbollist);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _STACKTRACE_H_
|
Loading…
x
Reference in New Issue
Block a user