elf_begin failed on postgresql 9.4 with dtrace enabled

Lacey Powers lacey.leanne at gmail.com
Mon Dec 22 00:44:18 UTC 2014


Hello Mark,

Thank you!

devel/libelf was linked to the postgres binary

[0]lacey at talizorah:~$ ldd /usr/local/bin/postgres
/usr/local/bin/postgres:
     libelf.so.0 => /usr/local/lib/libelf.so.0 (0x800d89000)
     libintl.so.8 => /usr/local/lib/libintl.so.8 (0x800fa2000)
     libxml2.so.2 => /usr/local/lib/libxml2.so.2 (0x8011ad000)
     libpam.so.5 => /usr/lib/libpam.so.5 (0x801541000)
     libicuuc.so.53 => /usr/local/lib/libicuuc.so.53 (0x80174d000)
     libicui18n.so.53 => /usr/local/lib/libicui18n.so.53 (0x801adf000)
     libssl.so.7 => /usr/lib/libssl.so.7 (0x801f51000)
     libcrypto.so.7 => /lib/libcrypto.so.7 (0x8021bc000)
     libm.so.5 => /lib/libm.so.5 (0x8025af000)
     libthr.so.3 => /lib/libthr.so.3 (0x8027d7000)
     libc.so.7 => /lib/libc.so.7 (0x8029fc000)
     libz.so.6 => /lib/libz.so.6 (0x802da5000)
     liblzma.so.5 => /usr/lib/liblzma.so.5 (0x802fbb000)
     libicudata.so.53 => /usr/local/lib/libicudata.so.53 (0x8031e0000)
     libc++.so.1 => /usr/lib/libc++.so.1 (0x8048c3000)
     libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x804b83000)
     libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x804d9f000)
[0]lacey at talizorah:~$


Once I removed that, and rebuilt PostgreSQL, per your suggestions, I 
have 462 dtrace probes. =)

Many thanks for your clear and prompt reply. =)

Regards,

Lacey


On 12/21/2014 15:58, Mark Johnston wrote:
> On Sun, Dec 21, 2014 at 03:22:25PM -0800, Lacey Powers wrote:
>> Hello Everyone,
>>
>> I was attempting to build and use PostgreSQL with dtrace on FreeBSD 10.1 on
>> my home workstation.
>>
>> It builds, and the binary works, but fails to register any probes.
>>
>> After double checking that I had the dtraceall kernel module loaded,
>> changing permissions on /dev/dtrace/helper (0666), verifying that
>> devel/libelf was loaded, and digging around source code and Google for debug
>> flags, I'm at a loss for what else to do.
>>
>> Here is the error:
>>
>> [pgsql at talizorah ~]$ DTRACE_DOF_INIT_DEBUG=1 /usr/local/bin/postgres -D
>> /usr/local/pgsql/9.4/data
>> dtrace DOF postgres: elf_begin failed
>> LOG:  ending log output to stderr
>> HINT:  Future log output will go to log destination "syslog".
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> ^Cdtrace DOF postgres: dtrace DOF postgres: DTrace ioctl failed to remove
>> DOF (-1)
>> DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> dtrace DOF postgres: DTrace ioctl failed to remove DOF (-1)
>> [pgsql at talizorah ~]$
> Hi Lacey,
>
> I've never seen this particular problem before. Could you post the
> output of "ldd /usr/local/bin/postgres"? I've never tried using libelf
> from ports, so perhaps there's a problem with it, assuming it is indeed
> being used (as opposed to the base system's libelf).
>
> If the ports libelf is being used (/usr/local/lib/libelf.so will show up
> in the ldd ouput if so), could you try deleting devel/libelf, rebuilding
> postgres, and trying again? If not, or if other packages require
> devel/libelf on your system, could you apply the patch below, rebuild drti,
> rebuild postgres (in that order), and try again?
>
> To rebuild drti, cd to /usr/src/cddl/lib/drti and run
> "make && make install".
>
> Thanks!
> -Mark
>
> diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
> index ccd4f9b..eafc4c6 100644
> --- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
> +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
> @@ -158,7 +158,7 @@ dtrace_dof_init(void)
>   		return;
>   	}
>   	if ((e = elf_begin(efd, ELF_C_READ, NULL)) == NULL) {
> -		dprintf(1, "elf_begin failed\n");
> +		dprintf(1, "elf_begin failed: %s\n", elf_errmsg(elf_errno()));
>   		close(efd);
>   		return;
>   	}



More information about the freebsd-dtrace mailing list