From: Heather McIntyre <hsm2@rice.edu>
To: elfutils-devel@sourceware.org
Subject: Deadlock from --enable-thread-safety
Date: Fri, 4 Aug 2023 09:21:09 -0500 [thread overview]
Message-ID: <CAK-+vz3WaYB7satybYyZeLPuCtE3y9iacpUFxzTbndPh0b7eKQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2112 bytes --]
I've been making --enable-thread-safety (USE_LOCKS) more viable by fixing
deadlocks throughout the libelf library. This has required minimal code
changes so far. However, I've hit a snag where "__elf64_updatenull_wrlock"
calls "elf64_getchdr," which leads to "elf64_getshdr." This sequence
attempts to acquire a read lock under a write lock and fails. Similarly,
"elf64_getchdr" calls "elf_getdata," which also tries and fails to
implement a read lock.
Unfortunately, fixing this particular deadlock requires more than minimal
code changes. From what I understand, I may have a few options on how to
fix this:
1) Create copies of the getchdr and elf_getdata functions, renaming them
getchdr_wrlock and elf_getdata_wrlock. However, multiple copies of these
functions could bloat the code, which may not be ideal.
2) Some type of write lock flag to indicate when a write lock is active.
Either within the locking macro in eu-config.h or passed as an argument in
the functions.
Ultimately, I thought others may want to look into this to see if there
might be options for a better solution. Here is the backtrace:
Program received signal SIGABRT, Aborted.
0x00007ffff7837aff in raise () from /lib64/libc.so.6
#0 0x00007ffff7837aff in raise () from /lib64/libc.so.6
#1 0x00007ffff780aea5 in abort () from /lib64/libc.so.6
#2 0x00007ffff780ad79 in __assert_fail_base.cold.0 () from /lib64/libc.so.6
#3 0x00007ffff78304c9 in __assert_perror_fail () from /lib64/libc.so.6
#4 0x00007ffff7fda554 in elf64_getshdr (scn=0x40fc20) at
../../libelf/elf32_getshdr.c:292
#5 0x00007ffff7fe9590 in elf64_getchdr (scn=0x40fc20) at
../../libelf/elf32_getchdr.c:45
#6 0x00007ffff7fdf690 in __elf64_updatenull_wrlock (elf=0x40d880,
change_bop=0x7fffffffac60, shnum=30) at ../../libelf/elf32_updatenull.c:407
#7 0x00007ffff7fdd83d in elf_update (elf=0x40d880, cmd=ELF_C_WRITE) at
../../libelf/elf_update.c:211
#8 0x0000000000405d9e in process_file (fname=0x7fffffffbb96
"testfile-s390x-hash-both") at ../../src/elfcompress.c:1336
#9 0x0000000000406232 in main (argc=7, argv=0x7fffffffb768) at
../../src/elfcompress.c:1458
next reply other threads:[~2023-08-04 14:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 14:21 Heather McIntyre [this message]
2023-08-04 14:46 ` John Mellor-Crummey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK-+vz3WaYB7satybYyZeLPuCtE3y9iacpUFxzTbndPh0b7eKQ@mail.gmail.com \
--to=hsm2@rice.edu \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).