[MDEV-30815] Printing a stack trace leaks file descriptors. Created: 2023-03-09  Updated: 2023-07-16

Status: Stalled
Project: MariaDB Server
Component/s: Debug
Affects Version/s: 10.5
Fix Version/s: 10.5

Type: Bug Priority: Minor
Reporter: Rex Johnston Assignee: Rex Johnston
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In situations where mariadbd emits a lot of stack traces it can run out of file descriptors. Each time the pipe to the external utility addr2line is opened, those file descriptor are never closed.



 Comments   
Comment by Rex Johnston [ 2023-03-15 ]

Hi Marko, do we want this? Thanks, Rex

Comment by Marko Mäkelä [ 2023-03-20 ]

I think that this would be best reviewed by someone who has worked on this code earlier.

The main thing to ensure is that this will not cause any regression on any platform. Unfortunately, the AIX build on 10.5 was broken by something related to MDEV-30700 some time ago, and a fix still has not been merged from 10.4.

Comment by Sergei Golubchik [ 2023-03-29 ]

I don't think there should be many or "each time the pipe is opened", add2line should be executed only once, from the crash handler.

If we want to have a backtracer that can be invoked many times run-time without aborting the server, we'd likely prefer something more lightweight.

Comment by Rex Johnston [ 2023-03-30 ]

I've just downloaded and looked at libbacktrace. License is a permissive BSD and a call like this

  i = backtrace_full (state, 0, callback_mtest, error_callback_one, &data);

produces data like this

$7 = {{filename = 0x5555555692a0 "/home/rex/src/mariadb/libbacktrace/binutils-gdb/libbacktrace/mtest.c", lineno = 110, function = 0x5555555692f0 "f3"}, {
    filename = 0x555555569310 "/home/rex/src/mariadb/libbacktrace/binutils-gdb/libbacktrace/mtest.c", lineno = 94, function = 0x555555569360 "f2"}, {
    filename = 0x555555569380 "/home/rex/src/mariadb/libbacktrace/binutils-gdb/libbacktrace/mtest.c", lineno = 88, function = 0x5555555693d0 "test1"}, {
    filename = 0x5555555693f0 "/home/rex/src/mariadb/libbacktrace/binutils-gdb/libbacktrace/mtest.c", lineno = 402, function = 0x555555569440 "main"}, {
    filename = 0x0, lineno = 0, function = 0x0}, {filename = 0x0, lineno = 0, function = 0x0}, {filename = 0x0, lineno = 0, function = 0x0}, {

Comment by Vicențiu Ciorbaru [ 2023-04-18 ]

Johnston see https://github.com/MariaDB/server/pull/2536#issuecomment-1512428174

Please properly update this MDEV so I can make some sense of the actual problem and what your proposed solution is.

Generated at Thu Feb 08 10:19:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.