Commit graph

42 commits

Author SHA1 Message Date
Ashod Nakashian
1339b36575 wsd: define Log::shutdown for Mobile to avoid special casing at call sites
Change-Id: I9125df562c96b3671cb47200a36aae145cf29259
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90423
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-03-14 14:23:27 +01:00
Ashod Nakashian
3ebbc6213b wsd: avoid malloc in signal handler
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>
2019-11-19 16:13:33 +01:00
Jan Holesovsky
189cd0e389 killpoco: Get rid of Poco::Process:id() usage.
Change-Id: If060767389f9fa57deba1ceefc872bac03763498
Reviewed-on: https://gerrit.libreoffice.org/82208
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-11-07 12:24:53 +01:00
Jan Holesovsky
5d0d3a4869 killpoco: Get rid of Poco/Thread.h from the rest of the Android-related files.
Change-Id: I724230a4428cab3cc26245ac4aa43a91af2e09ce
Reviewed-on: https://gerrit.libreoffice.org/82204
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-11-07 12:24:26 +01:00
Ashod Nakashian
56b49b5000 wsd: warning logging on the console is now magenta for visibility
Change-Id: I8756a0c38d529495826131a3d2dcd1ab70d8c289
Reviewed-on: https://gerrit.libreoffice.org/81337
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 7c325c0fb32951dfc8786df98d72e72c92443088)
Reviewed-on: https://gerrit.libreoffice.org/81577
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-10-29 02:36:08 +01:00
Ashod Nakashian
5dc8e815c4 wsd: logging: color trace differently to improve readability
Change-Id: I5127061f4d62122d07bad32d4757569f1a9cc877
Reviewed-on: https://gerrit.libreoffice.org/80321
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit 48387b00077b9baa72508c05e3fc3228a4569998)
Reviewed-on: https://gerrit.libreoffice.org/81559
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-10-28 10:45:31 +01:00
Tor Lillqvist
f89264047c Fix build failure in the MOBILEAPP case
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>
2019-09-16 13:32:57 +02:00
Miklos Vajna
71a942c24b Log: rename isShutdown to isShutdownCalled
Class members that differ only in case are not great.

Change-Id: I2e54bf9b6da7e4e15e03389000a6ff86e98c16a6
2019-09-16 11:52:15 +02:00
Miklos Vajna
f8140acac7 Avoid static member access through instance
Change-Id: Ifbfdfbb0d5b6020908d041904b61a2ed3b8255c1
2019-09-11 12:23:59 +02:00
Miklos Vajna
a7d836dd7c Fix UB in unit-wopi
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
2019-09-09 15:41:09 +02:00
Ashod Nakashian
c6c673ed6f wsd: cache the logger instance to avoid costly lookups
Change-Id: Idf9261d46b44afc42a960146886c180e37d8d51f
Reviewed-on: https://gerrit.libreoffice.org/69641
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/71085
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-08-17 03:38:43 +02:00
Tor Lillqvist
199c6e2918 Revert "Get rid of use of GNU libtool" and its follow-up
The change causes problems for people on various sad distros. Oh well,
whatever.

This reverts commit bd00d9fd05.
This reverts commit 054a9cdb04.

Change-Id: Ie439e4c655d02b6f34bdd1a9c1c5b6db6048b653
2019-05-27 10:25:51 +03:00
Tor Lillqvist
bd00d9fd05 Get rid of use of GNU libtool
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>
2019-05-24 09:50:16 +02:00
Tor Lillqvist
ebda7c6b8b Use same kind of thread id as Xcode and osl_getThreadIdentifier() on iOS
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
2019-05-16 11:42:19 +03:00
Tor Lillqvist
8ae35c6348 No need to call Log::shutdown() in a mobile app
The process never exists voluntarily. It is killed by the OS when
inactive and its resources are needed.

Change-Id: I9a7fa8200a44bba8dfcd2b09882f1b87814025be
2019-05-16 11:41:08 +03:00
Michael Meeks
685709080d Revert attempts at re-using ostringstream
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>
2019-04-27 23:18:11 +02:00
Michael Meeks
c2c5bd0e3e Reset the stringstream properly.
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>
2019-04-27 23:03:16 +02:00
Ashod Nakashian
ce78fec310 wsd: reuse ostringstream when logging
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>
2019-04-23 03:01:00 +02:00
Jan Holesovsky
f76b36193d android: #if(n)def MOBILEAPP -> #if (!)MOBILEAPP for better reliability.
Change-Id: I5f9c9420b6c83601db1c8fdba4ae5a10b17b2107
2019-02-12 12:20:11 +01:00
Miklos Vajna
da8785ed50 Log::StaticNameHelper: make members private
Change-Id: I7c46dc6757b98867c4893ee019b3fd6d903020fc
2018-12-04 09:06:58 +01:00
Ashod Nakashian
00a44d6e81 wsd: flush logs before existing
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
2018-10-16 20:12:23 -04:00
Ashod Nakashian
3158d4c31c wsd: always use signal-safe calls
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
2018-10-16 20:12:23 -04:00
Tor Lillqvist
95eb849217 Still more iOS app and related Online C++ code hacking
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
2018-09-19 11:31:18 +03:00
Tor Lillqvist
83a7a6f744 s/StaticNames/StaticNameHelper
It is a container for one name (and used just once even), not several,
so no need for the plural.

Change-Id: I6d8b22f071d5136fb854e6f2c5a6be8b4572b535
2018-09-13 12:06:23 +03:00
Tor Lillqvist
75438baa70 More mobile app stuff, very much early state of work in progress
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.
2018-09-10 15:13:43 +03:00
Tor Lillqvist
d3f0179c96 Make this file compile for iOS 2018-08-29 20:39:26 +03:00
Miklos Vajna
9ed7c1065c common, kit, test, wsd: these parameters are copied for each invocation ...
... but passing by const ref is enough
2018-08-13 09:26:15 +02:00
Tor Lillqvist
eae43a262b Drop unused LogPrefix variable
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
2018-07-19 12:16:19 +03:00
Ashod Nakashian
b59f5c2c65 wsd: log proper ISO date in YYYY-MM-DD format
Change-Id: I8851c044bad43a03a99f7471be97ea77c58f7be8
Reviewed-on: https://gerrit.libreoffice.org/53266
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/53316
(cherry picked from commit d50850337b1cad5ce93678079085a97316f1f48e)
Reviewed-on: https://gerrit.libreoffice.org/53318
2018-04-23 11:53:23 +02:00
Ashod Nakashian
c06376cc1d wsd: cleanup logging and remove unused helpers
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>
2018-01-19 00:33:40 +01:00
Pranav Kant
f63858433b loplugin:includeform
Change-Id: Ib62a7aa61062f00698aa3e8a144438de5c57e53d
2017-12-20 21:21:05 +05:30
Pranav Kant
af13e5927d Open the log channel explicitly to avoid file creation inside jail
Change-Id: Ida66861e0e1c5925dbbf53d564a829eaf0fd15c7
2017-07-12 15:14:58 +05:30
Michael Meeks
08c70f1315 Signal safe number logging (lame but useful).
Change-Id: I0b6095fc08dcc237a224b5942ab5a09e6820e43f
2017-04-28 19:05:45 +01:00
Michael Meeks
ae0dba1088 Cleanup prctl / gettid system-call thrash on logging.
Makes the strace look much prettier.
2017-03-30 18:14:40 +01:00
Michael Meeks
0eaef6c896 config.h - get includes right: must always be the first include. 2017-03-10 10:47:43 +01:00
Ashod Nakashian
c22e69e9e6 wsd: correct logging of thread ID in log entries
Change-Id: I10aaeeea8df2757362482a405b7525542d150178
Reviewed-on: https://gerrit.libreoffice.org/33857
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:05:06 +00:00
Ashod Nakashian
ffe092f5ce wsd: log cleanup
Change-Id: I569f7a81fa80686810c4d5aa65e03b02be189db7
Reviewed-on: https://gerrit.libreoffice.org/33417
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:34:38 +00:00
Ashod Nakashian
b9c900d459 wsd: format the time directly in the log prefix
Change-Id: I6ad5faf8fdfa16831863bf4b8fa0568e88d0d0f8
Reviewed-on: https://gerrit.libreoffice.org/33416
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:33:09 +00:00
Jan Holesovsky
4416c836d0 Log the time in wall-clock time, instead of since the process start.
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
2017-01-13 16:14:13 +01:00
Ashod Nakashian
89bd85fbba wsd: put_time is not supported by gcc4.8
Change-Id: Ib3b6a115ba669051474e327944cb4677575d15f3
Reviewed-on: https://gerrit.libreoffice.org/32917
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-10 05:39:48 +00:00
Ashod Nakashian
fe9e95dfa3 wsd: log the time when initializing the logger
Change-Id: I785c2a6a13dedbecf10a96a593f05e13980ea1e6
Reviewed-on: https://gerrit.libreoffice.org/32863
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:20:08 +00:00
Michael Meeks
cca657c8f2 Apply the pre-branch rename script to re-organize the source. 2016-11-25 09:58:48 +00:00
Renamed from loolwsd/Log.cpp (Browse further)