Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to init binreloc with ld >= 2.31 [CORE5955] #6210

Closed
firebird-issue-importer opened this issue Oct 30, 2018 · 8 comments
Closed

Unable to init binreloc with ld >= 2.31 [CORE5955] #6210

firebird-issue-importer opened this issue Oct 30, 2018 · 8 comments

Comments

@firebird-issue-importer

Submitted by: @romansimakov

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 http://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
"

Commits: abc09c3 4d22374

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Commented by: @aafemt

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);

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Modified by: @romansimakov

Version: 3.0.4 [ 10863 ]

Version: 4.0 Alpha 1 [ 10731 ]

description: 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 http://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 simpthom is "Missing master config file firebird.conf" if you try to run server without installation.

=>

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 http://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
"

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Modified by: @romansimakov

assignee: Roman Simakov [ roman-simakov ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Modified by: @romansimakov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 1 [ 10750 ]

Fix Version: 3.0.5 [ 10885 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Commented by: @romansimakov

Will it work for embed version where fbclient and its library is located separately?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 30, 2018

Commented by: @asfernandes

> Will it work for embed version where fbclient and its library is located separately?

No!

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 9, 2018

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Cannot be tested

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 9, 2018

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants