View previous topic :: View next topic |
Author |
Message |
gengreen Apprentice
Joined: 23 Dec 2017 Posts: 150
|
Posted: Fri Mar 16, 2018 8:15 am Post subject: [musl] qbittorrent - fatal error: execinfo.h |
|
|
Hello,
Tried to emerge qbittorrent today (3.3.16 and 4.0.4) gave this error :
Code: | k/qbittorrent-4.0.4_build/src/app/qrc_searchengine.cpp
/var/tmp/portage/net-p2p/qbittorrent-4.0.4/work/qbittorrent-4.0.4/src/app/main.cpp:60:22: fatal error: execinfo.h: No such file or directory
#include <execinfo.h>
^
compilation terminated. |
I could find this lib on my glibc Gentoo at
Code: | /usr/include/execinfo.h |
But not on my musl so I made a bit change on main.cpp of qbittorrent
https://paste.pound-python.org/show/JhrNXQCsbt9NYwJuCcTp/
And it worked, hope it will help
[Moderator edit: changed first [quote] tag to [code] tags to preserve output layout. -Hu] |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30822 Location: here
|
Posted: Fri Mar 16, 2018 9:27 am Post subject: |
|
|
You can try this patch?
If work you can submit the patch to gentoo musl project, I tested that work in a glibc system. _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
gengreen Apprentice
Joined: 23 Dec 2017 Posts: 150
|
Posted: Fri Mar 16, 2018 10:54 am Post subject: |
|
|
Almost :
Code: | diff -Naru qbittorrent-4.0.4.orig/src/app/main.cpp qbittorrent-4.0.4/src/app/main.cpp
--- qbittorrent-4.0.4.orig/src/app/main.cpp 2018-03-16 10:08:10.493478535 +0100
+++ qbittorrent-4.0.4/src/app/main.cpp 2018-03-16 10:12:21.919464628 +0100
@@ -57,8 +57,10 @@
#ifdef Q_OS_UNIX
#include <signal.h>
+#ifdef __GLIBC__
#include <execinfo.h>
#include "stacktrace.h"
+#endif // __GLIBC__
#endif // Q_OS_UNIX
#ifdef STACKTRACE_WIN
@@ -308,7 +310,9 @@
reportToUser(msg);
reportToUser(sigName);
reportToUser("\n");
+ #ifdef __GLIBC__
print_stacktrace(); // unsafe
+ #endif // __GLIBC__
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
#ifdef STACKTRACE_WIN
StraceDlg dlg; // unsafe
|
Worked
Edit : Trying to join freenode but irssi fail to build with the useflag socks5
Code: |
libtool: link: x86_64-gentoo-linux-musl-gcc -march=skylake -O2 -pipe -Wall -DSOCKS -Wl,-O1 -Wl,--as-needed -o irssi gui-entry.o gui-expandos.o gui-printtext.o gui-readline.o gui-windows.o lastlog.o mainwindows.o mainwindow-activity.o mainwindows-layout.o statusbar.o statusbar-config.o statusbar-items.o term.o term-terminfo.o terminfo-core.o textbuffer.o textbuffer-commands.o textbuffer-view.o irssi.o module-formats.o -Wl,--export-dynamic -pthread -Wl,--export-dynamic ../fe-common/irc/libfe_common_irc.a ../fe-common/irc/dcc/libfe_irc_dcc.a ../fe-common/irc/notifylist/libfe_irc_notifylist.a ../fe-common/core/libfe_common_core.a ../irc/libirc.a ../irc/core/libirc_core.a ../irc/dcc/libirc_dcc.a ../irc/flood/libirc_flood.a ../irc/notifylist/libirc_notifylist.a ../core/libcore.a ../lib-config/libirssi_config.a -lsocks -lgmodule-2.0 -lglib-2.0 -lssl -lcrypto -lncursesw -pthread
/usr/lib/gcc/x86_64-gentoo-linux-musl/6.4.0/../../../libsocks.so: undefined reference to `bindresvport'
collect2: error: ld returned 1 exit status |
Weird |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
|
Back to top |
|
|
gengreen Apprentice
Joined: 23 Dec 2017 Posts: 150
|
Posted: Fri Mar 16, 2018 11:37 am Post subject: |
|
|
Yes I read about it a while ago, I'm not dev but could another macro like "if the header file exist" is a more proper way ?
Maybe adding a sed to the ebuild to strip somes line (like sed -i 's/#include <execinfo.h>//' mainfix.cpp for example) ?
Thanks |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3309 Location: Rasi, Finland
|
Posted: Fri Mar 16, 2018 11:47 am Post subject: |
|
|
gengreen wrote: | Maybe adding a sed to the ebuild to strip somes line (like sed -i 's/#include <execinfo.h>//' mainfix.cpp for example) ? | If possible I'd probably check for if musl profile is active or if musl is installed. If it is, then use sed to drop the lines.
As to which way is the "most correct" way, I cannot tell. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
gengreen Apprentice
Joined: 23 Dec 2017 Posts: 150
|
Posted: Fri Mar 16, 2018 1:11 pm Post subject: |
|
|
I took a look on some patch made for the profile musl before to submit it in the github repo
https://github.com/gentoo/musl/issues/104
Code: | diff -Naru qbittorrent-4.0.4.orig/src/app/main.cpp qbittorrent-4.0.4/src/app/main.cpp
--- qbittorrent-4.0.4.orig/src/app/main.cpp 2018-03-16 10:08:10.493478535 +0100
+++ qbittorrent-4.0.4/src/app/main.cpp 2018-03-16 10:12:21.919464628 +0100
@@ -57,8 +57,6 @@
#ifdef Q_OS_UNIX
#include <signal.h>
-#include <execinfo.h>
-#include "stacktrace.h"
#endif // Q_OS_UNIX
#ifdef STACKTRACE_WIN
@@ -308,7 +306,6 @@
reportToUser(msg);
reportToUser(sigName);
reportToUser("\n");
- print_stacktrace(); // unsafe
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
#ifdef STACKTRACE_WIN
StraceDlg dlg; // unsafe
|
I think that can be use as a fix until someone purpose something better |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 16, 2018 1:42 pm Post subject: |
|
|
My previous post was equivocal but I have difficulties because I am not a developer yet.
The toolchain may use chunks of code (translated in machine code, a.k.a object codes) included in a library (an archive) using declarations mentioned in the source code of the software.
Typically, these declarations are included in separate source files (header files) to prevent errors (wrong arguments, typos, etc.).
I mean that the toolchain may not "recognize" some instructions if the corresponding object code is not included in the software.
Edit: fixed mistakes.
Last edited by Mr. T. on Fri Mar 16, 2018 2:20 pm; edited 2 times in total |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 16, 2018 2:09 pm Post subject: |
|
|
The fix seems correct because it removes print_stacktrace (unsafe). The header execinfo.h is normally (note) only used by the previously mentioned function.
Note: Q_OS_UNIX does not "use" other undeclared function. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3309 Location: Rasi, Finland
|
Posted: Fri Mar 16, 2018 2:33 pm Post subject: |
|
|
helecho wrote: | The fix seems correct because it removes print_stacktrace (unsafe). The header execinfo.h is normally (note) only used by the previously mentioned function. | Wait... So doing this patch actually hardens the software because its implementation of stacktrace printing is unsafe?
Also what did you meant with "(note)"? _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30822 Location: here
|
Posted: Fri Mar 16, 2018 2:34 pm Post subject: |
|
|
Thanks helecho for link _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 16, 2018 3:44 pm Post subject: |
|
|
I use the word "(note)" to give more information about the topic or add a precision.
My point of view is biased because I know the purpose of the functionality.
stacktrace.h: | /** Print a demangled stack backtrace of the caller function to FILE* out. */ |
manual wrote: | 34.1 Backtraces: info -n '(libc)Backtraces' or info -k execinfo.h
A "Bactrace" is a list of the function calls that are currently active in a thread. The usual way to inspect a backtrace of a program is to
use an external debugger such as gdb. However, sometimes it is useful to obtain a backtrace programmatically from within a program,
e.g., for the purposes of logging or diagnostics. |
The removed feature is not mandatory to run the software because print_stacktrace is used for debugging purpose.
Zucca, I do not know if the patch hardens the software because I haven't studied the definition of print_stacktrace!
Edit: My remark in the previous post may be unclear.
We notice the missing header execinfo.h is included conditionally #ifdef Q_OS_UNIX so features introduced by this header are also included conditionally.
Therefore, we search the features "inserted" in code blocks surrounded by #ifdef Q_OS_UNIX ... #endif and we determine the features included in execinfo.h.
An example:
main.cpp: | // Line 137:
#if defined(Q_OS_UNIX)
void setupDpi();
#endif // Q_OS_UNIX
...
// Line 154:
#if !defined(DISABLE_GUI) && defined(Q_OS_UNIX)
setupDpi();
#endif |
helecho |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Sat Mar 17, 2018 8:38 am Post subject: |
|
|
My description was incorrect because I forgot to mention that the interactions between the elements are also important.
main.cpp: | void sigAbnormalHandler(int signum)
{
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
const char str1[] = "\n\n*************************************************************\nCatching signal: ";
const char *sigName = sysSigName[signum];
const char str2[] = "\nPlease file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
"qBittorrent version: " QBT_VERSION "\n";
reportToUser(str1);
reportToUser(sigName);
reportToUser(str2);
print_stacktrace(); // unsafe
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
#ifdef STACKTRACE_WIN
StraceDlg dlg; // unsafe
dlg.setStacktraceString(straceWin::getBacktrace());
dlg.exec();
#endif // STACKTRACE_WIN
signal(signum, SIG_DFL);
raise(signum);
}
#endif // defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
|
stacktrace.h: | static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63) |
print_stacktrace has no return value and this function does not act on (or does not modify) sigAbnormalHandler. Then, we have to know (in general) if
print_stacktrace (the function) modify global "data" (file, variable, etc.) because these data may be used by piece of code during the execution of the software.
Conclusion: This optional feature may be removed but we have to be careful because this change can alter related features. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Fri Apr 13, 2018 7:04 pm Post subject: |
|
|
Mr. T. wrote: | This optional feature may be removed but we have to be careful because this change can alter related features. | It is marked "unsafe" because it is executing in async-signal context.
Deletion is the best option, IMO. That is simply not how you do that sort of thing.
You can get away with it for debugging, and you can argue that "it's okay" because the process is about to terminate on that signal, but the latter would be flawed, given that the only result you can count on is "undefined behaviour" (in quotes because I suggest you do a web-search on it, if you haven't heard of UB before.) |
|
Back to top |
|
|
|