malloc is not signal safe, and must not be called
from signal-safe functions. If malloc itself signals,
calling it in the signal handler can deadlock.
Luckily, we only needed malloc for getting the
backtrace strings. Now we just write directly to
stderr, which is faster, cleaner, and safer.
Change-Id: I54093f45e05f2a0fd3c5cde0cc2104ffe6d81d2a
Reviewed-on: https://gerrit.libreoffice.org/83151
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
We never exit an app process intentionally, so Log::isShutdownCalled()
can always return false.
Change-Id: I6b3cce85ccac5e3ffbb7b29ca552cb9e4441df2a
Reviewed-on: https://gerrit.libreoffice.org/78979
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
net/Socket.hpp:405:9: runtime error: member call on address 0x6070007a2210 which does not point to an object of type 'Poco::Logger'
0x6070007a2210: note: object has invalid vptr
05 00 80 0e 7c 01 80 6f 3c 7f 00 00 c8 b8 0f 01 3c 7f 00 00 00 00 00 00 be be be be 38 22 7a 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior net/Socket.hpp:405:9 in
Which is use-after-free: once Poco::Logger::shutdown() is called, we
need to tolerate LOG_DBG() and other similar calls, even if they don't
go anywhere.
Change-Id: Ic76433743177dd2b604ff34e340309c506d83350
The change causes problems for people on various sad distros. Oh well,
whatever.
This reverts commit bd00d9fd05.
This reverts commit 054a9cdb04.
Change-Id: Ie439e4c655d02b6f34bdd1a9c1c5b6db6048b653
It is is complicated enough to build the iOS app. Requiring GNU
libtool brings with it the risk of polluting the command environment
as there already is a completely different command in macOS with the
same name, /usr/bin/libtool. And as GNU libtool was used only to build
the unit tests for the "normal" server-based Online that are built and
run only on Linux anyway, we don't really need any of the
"portability" that GNU libtool brings.
Without GNU libtool, we compile all the $(wsd_sources) (see
test/Makefile.am) that the unit-* tests use into a single object file,
WsdSources.o. (Because they need to be compiled as PIC we can't use
the already compiled object files for the Online server programs.)
This required some additional minor changes to a few source files.
Change-Id: I20a2c523170376fa4c1a0d9d8d6b693a9779376f
Reviewed-on: https://gerrit.libreoffice.org/72840
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Reduce the number of different kinds of identifiers for threads that
are displayed in various places. Use the number that you get with
pthread_threadid_np(), in hex, which is the same that Xcode (i.e.
lldb) displays in its "thread list" command. It also is the same
number that osl_getThreadIdentifier() returns.
Change-Id: I0c14ad99badd7e742d15b7d1f37037fa66c892b4
The process never exists voluntarily. It is killed by the OS when
inactive and its resources are needed.
Change-Id: I9a7fa8200a44bba8dfcd2b09882f1b87814025be
Cleaning up the thread variable with the shared string stream is
something of a nightmare, for a rather marginal gain.
==9296== Invalid write of size 1
...
==9296== by 0x738C092: str (sstream:195)
==9296== by 0x738C092: std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (sstream:649)
==9296== by 0x65383A: Log::beginLog[abi:cxx11](char const*) (Log.cpp:141)
==9296== by 0x551823: Admin::~Admin() (Admin.cpp:381)
==9296== by 0x7D9ECF7: __run_exit_handlers (exit.c:83)
==9296== by 0x7D9ED49: exit (exit.c:105)
==9296== by 0x7D86F50: (below main) (libc-start.c:342)
==9296== Address 0x8ba41c0 is 0 bytes inside a block of size 513 free'd
==9296== at 0x4C2FA1D: operator delete(void*) (vg_replace_malloc.c:576)
...
==9296== by 0x738784A: ~basic_stringbuf (sstream:65)
==9296== by 0x738784A: std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream() (sstream:591)
==9296== by 0x7D9F27E: __call_tls_dtors (cxa_thread_atexit_impl.c:155)
==9296== by 0x7D9EC0A: __run_exit_handlers (exit.c:41)
==9296== by 0x7D9ED49: exit (exit.c:105)
==9296== by 0x7D86F50: (below main) (libc-start.c:342)
Good to log during shutdown / exit.
This reverts commit c315d219d5967f23fb1769e78021f61b8f9da6ec.
This reverts commit ce78fec310.
Change-Id: Ia4a15be336d89d8d883530943724d48e4b0ec9fe
Reviewed-on: https://gerrit.libreoffice.org/71444
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Avoids some N^2 log-line explosion; also make the method name
more findable.
Change-Id: I3ee8c521f1ac98a939cd4d758c720b577d3bfa57
Reviewed-on: https://gerrit.libreoffice.org/71443
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
This is faster and reduces memory fragmentation.
Also, cleans up the logging macros and implementation.
Change-Id: I7fb00da041d1261c694c4b48b67a3c66ad0cbf8d
Reviewed-on: https://gerrit.libreoffice.org/71020
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This is important for when we abort with some explanation.
Often said explanation doesn't show up anywhere to be useful.
Also, issue fatal logs for abnormal exist and use SFL to log errno.
Reviewed-on: https://gerrit.libreoffice.org/57540
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit ad7964393eadb68873b820e0a620fb40f1e1b06a)
Change-Id: Ic67064ef40ef6e93d26e5847ecd32bdd49c3cc8b
The async-signal-safe functions to get thread-id
and thread-name, which cache the results, are
faster, cleaner, and signal-safe. No reason why
we shouldn't always use them.
Especially since it appears the logic was
inverted in Log::prefix, such that the signal
un-safe calls were made during signal-handling,
and the safe ones were called otherwise!
Instead of passing the signal-safe flag to
Log::prefix, we pass the buffer size, for
improved security.
Furthermore, reduce header dependencies
and reduce clutter.
Change-Id: I697689b2f0a290b6d8cce4babc3ac1e576141da6
Re-think the plumbing between the different parts of the C++ Online
code. Do try to have it work more like in real Online on all but the
lowest socket level. Except that we don't have multiple processes, but
threads inside the same process. And instead of using actual system
sockets for WebSocket traffic between the threads, we use our own
FakeSocket things, with no WebSocket framing of messages.
Reduce the amount of #ifdef MOBILEAPP a bit also by compiling in the
UnitFoo things. Hardcode that so that no unit testing is ever
attempted, though. We don't try to dlopen any library.
Corresponding changes in the app Objective-C code. Plus fixes and
functionality improvements.
Now it gets so far that the JavaScript code thinks it has the document
tiles presented, and doesn't crash. But it hangs occasionally. And all
tiles show up blank.
Anyway, progress.
Change-Id: I769497c9a46ddb74984bc7af36d132b7b43895d4
Re-think Linux vs mobile ifdefs a bit. Use #ifdef __linux only to
surround code that actually is Linux-specific. Use #ifdef MOBILEAPP
for code that is for a mobile version (with no separste wsd, forkit,
and kit processes, and with no WebSocket protocol used).
Bypass UnitFoo for mobile. Possibly we do want the UnitFoo stuff after
all on mobile, to run in some special testing mode? Hard to say, let's
skipt it for now.
Also gets rid of a potentially problematic strncpy() use that causes a
gcc warning: specified bound 256 equals destination size
[-Werror=stringop-truncation].
(Whether that would have caused a problem or not depends on how
LogPrefix would have been used, and whether it ever would have been
filled completely, without any terminating nul character, by that
strncpy().)
Change-Id: I92dba3726e3f46777d9b4c8cf88f557c02788fe0
Now all logging is done after checking if the
level in question is enabled or not (thanks to
the macros LOG_XXX), which saves unnecessary
conversions and stringification when said level
is disabled.
Change-Id: Icde31e067f60269563896f04f8b0d65643720766
Reviewed-on: https://gerrit.libreoffice.org/47885
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Otherwise we are getting completely confused times - various processes start
at various times, so for one process the epoch start can be eg. 20 minutes
later than for the other.
Change-Id: I6d87e98682a5fcd0348a584cf66f7ffa5813ca66