ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
First note: my platform is linux/x64 (Debian-8.11; libc version 2.19-18+deb8u10); php-7.4.2 compiled from source (with debug); ffi-3.3 compiled from source (with debug)
ulimit seems to be not-restrictive:
Code:
$ ulimit -S -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31533
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 31533
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Edit: yet another idea:
Code:
LD_DEBUG=all MALLOC_CHECK_=1 php somescript.php
Seems to freeze here:
Code:
(gdb) bt
#0 0x00007f51b4ed9beb in g_hash_table_lookup () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1 0x00007f51b4efb014 in g_intern_static_string () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2 0x00007f51b51bb5c0 in ?? () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#3 0x00007f51c02c7bea in ?? () from /lib64/ld-linux-x86-64.so.2
it comes from package:
Code:
ii libglib2.0-0:amd64 2.42.1-1+deb8u3 amd64 GLib library of C routines
Here is where it seems to stop (or loop for ever):
Code:
#0 0x00007f95f64bc0b5 in g_hash_table_lookup_node (hash_table=0x1f82c00, key=0x7f95f67f58d3, hash_return=0x7fff20904598)
at ghash.c:388
#1 0x00007f95f64bd08e in g_hash_table_lookup (hash_table=0x1f82c00, key=0x7f95f67f58d3) at ghash.c:1153
#2 0x00007f95f64e4e31 in quark_from_string (string=0x7f95f67f58d3 "GInterface", duplicate=0) at gquark.c:182
#3 0x00007f95f64e5072 in quark_intern_string_locked (string=0x7f95f67f58d3 "GInterface", duplicate=0) at gquark.c:313
#4 0x00007f95f64e50db in g_intern_static_string (string=0x7f95f67f58d3 "GInterface") at gquark.c:354
#5 0x00007f95f67e537e in gobject_init () at gtype.c:4408
#6 0x00007f95f67e5436 in gobject_init_ctor () at gtype.c:4488
#7 0x00007f96018c7bea in ?? () from /lib64/ld-linux-x86-64.so.2
#8 0x00007f96018c7cd3 in ?? () from /lib64/ld-linux-x86-64.so.2
#9 0x00007f96018cbe38 in ?? () from /lib64/ld-linux-x86-64.so.2
#10 0x00007f96018c7aa4 in ?? () from /lib64/ld-linux-x86-64.so.2
#11 0x00007f96018cb62b in ?? () from /lib64/ld-linux-x86-64.so.2
#12 0x00007f95ffdaa02b in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
#13 0x00007f96018c7aa4 in ?? () from /lib64/ld-linux-x86-64.so.2
#14 0x00007f95ffdaa5dd in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
#15 0x00007f95ffdaa0c1 in dlopen () from /lib/x86_64-linux-gnu/libdl.so.2
#16 0x000000000057254c in zim_FFI_cdef (execute_data=0x7f95f92130a0, return_value=0x7f95f9213080)
at /usr/local/src/php-7.4.2/ext/ffi/ffi.c:2847
#17 0x0000000000b67529 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at /usr/local/src/php-7.4.2/Zend/zend_vm_execute.h:1730
#18 execute_ex (ex=0x7f95f9213020) at /usr/local/src/php-7.4.2/Zend/zend_vm_execute.h:53821
I think the linker-loader (/lib64/ld-linux-x86-64.so.2) has just loaded file /usr/local/lib64/libglib-2.0.so, and called its constructor gtype.c:gobject_init_ctor, which calls gobject_init, etc
Interesting difference in LD_DEBUG-output:
simple test program:
Code:
1961:<--->symbol=calloc; lookup in file=/home/projects/devel/test/dltest64 [0]
1961:<--->symbol=calloc; lookup in file=/lib/x86_64-linux-gnu/libdl.so.2 [0]
1961:<--->symbol=calloc; lookup in file=/lib/x86_64-linux-gnu/libc.so.6 [0]
1961:<--->binding file /usr/local/lib64/../lib64/libglib-2.0.so.0 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
php
Code:
31988:<--->symbol=calloc; lookup in file=./libsomething.so [0]
31988:<--->symbol=calloc; lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
31988:<--->binding file /usr/local/lib64/libglib-2.0.so.0 [0] to /lib64/ld-linux-x86-64.so.2 [0]: normal symbol `calloc' [GLIBC_2.2.5]
Indeed, there is a 'calloc' in /lib64/ld-linux-x86-64.so.2:
Code:
$ nm -D /lib64/ld-linux-x86-64.so.2
0000000000015b40 W calloc
0000000000015b80 W free
0000000000015b30 W malloc
0000000000015cf0 W realloc
Other modules need 'calloc' too:
Code:
31988: binding file /opt/OraHome_Current/lib/libclntsh.so.12.1 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /lib/x86_64-linux-gnu/libdl.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file php [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /usr/local/lib64/libonig.so.5 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /usr/local/lib64/libglib-2.0.so.0 [0] to /lib64/ld-linux-x86-64.so.2 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 [0] to /lib64/ld-linux-x86-64.so.2 [0]: normal symbol `calloc' [GLIBC_2.2.5]
31988: binding file /usr/local/lib64/libglib-2.0.so.0 [0] to /lib64/ld-linux-x86-64.so.2 [0]: normal symbol `calloc' [GLIBC_2.2.5]
So something has changed with /usr/local/lib64/libglib-2.0.so.0
Okay, here is one of the problems: the shared object in question (for some linking problem I don't really get) depends on /lib64/ld-linux-x86-64.so.2, even worse, it is the first dependency:
That should be removed from the linking.
The other problem: what kind if calloc exist in ld-linux-x86-64, and it really doesn't clear the allocated memory, or some memory has been corrupted and a random piece of code is executed?
Also 'calloc' in 'ld.linux' calls 'malloc', but doesn't call 'memset' -- guess it assumes 'malloc' returns cleared memory. But for some reason it is 'malloc' from 'libc.so'that is called, not the builtin 'malloc'.
Edit: the following line seems to validate this:
Code:
binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib64/ld-linux-x86-64.so.2 [0]:
normal symbol `_r_debug'
...
binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]:
normal symbol `__libc_memalign' [GLIBC_2.2.5]
binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]:
normal symbol `malloc' [GLIBC_2.2.5]
binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]:
normal symbol `realloc' [GLIBC_2.2.5]
binding file /lib64/ld-linux-x86-64.so.2 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]:
normal symbol `free' [GLIBC_2.2.5]
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.