Issue Details (XML | Word | Printable)

Key: CORE-5955
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Roman Simakov
Reporter: Roman Simakov
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Unable to init binreloc with ld >= 2.31

Created: 30/Oct/18 10:18 AM   Updated: 09/Dec/18 11:40 AM
Component/s: None
Affects Version/s: 4.0 Alpha 1, 3.0.4
Fix Version/s: 4.0 Beta 1, 3.0.5

Environment: Libux binaried built with ld >=2.31

QA Status: Cannot be tested


 Description  « Hide
See https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=ld/NEWS;hb=refs/tags/binutils-2_31 for 2.31

*Add a configure option --enable-separate-code to decide whether
  -z separate-code should be enabled in ELF linker by default. Default
  to yes for Linux/x86 targets. Note that -z separate-code can increase
  disk and memory size.

Now -z separate-code linker option is default and in /proc/self/maps we can find 6 sections for libfbclient.so

7ffff7b8d000-7ffff7c0f000 r--p 00000000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7ffff7c0f000-7ffff7da8000 r-xp 00082000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7ffff7da8000-7ffff7f83000 r--p 0021b000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7ffff7f83000-7ffff7f84000 ---p 003f6000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7ffff7f84000-7ffff7fbc000 r--p 003f6000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7ffff7fbc000-7ffff7fbe000 rw-p 0042e000 08:15 52957347 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0


Previosly we could find 4. Now "r-xp" pages contains ONLY instructions. Any data moved to separate pages "a--p".

7f8ef3f04000-7f8ef42f9000 r-xp 00000000 08:15 52957337 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7f8ef42f9000-7f8ef42fa000 ---p 003f5000 08:15 52957337 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7f8ef42fa000-7f8ef4332000 r--p 003f5000 08:15 52957337 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0
7f8ef4332000-7f8ef4334000 rw-p 0042d000 08:15 52957337 /home/roman/prj/RedDatabase/red-database/gen/Debug/firebird/lib/libfbclient.so.4.0.0

binreloc library skip any lines of /proc/self/maps except "a-xp" and it's a bug. It tries to find an address of empty constant string "" and supposes it will be allocated at the same page as instructions. Starting from ld 2.31 it's not so by default. We need to conider r--p sections as well.

A symptom is "Missing master config file firebird.conf" if you try to run server without installation.
Another one is:
"
/usr/local/firebird/security4.fdb
unavailable database
Security database error
"

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dimitry Sibiryakov added a comment - 30/Oct/18 10:36 AM
I would suggest to get rid of binreloc completely and get executable directory from /proc/self/exe like this:

char temp[PATH_SIZE];
int exe_name_len = readlink("/proc/self/exe", temp, sizeof(temp - 1);
if (exe_name_len >= 0)
{
  temp[exe_name_len] = '\0';
}
else
{
  strcpy(temp, getenv("_"));
}
PathUtils::splitLastComponent(install_dir, dummy, temp);

Roman Simakov added a comment - 30/Oct/18 10:49 AM
Will it work for embed version where fbclient and its library is located separately?

Adriano dos Santos Fernandes added a comment - 30/Oct/18 11:02 AM
> Will it work for embed version where fbclient and its library is located separately?

No!