Bug 234451 - lang/erlang-runtime21: build failure with BSD crtbegin/crtend
Summary: lang/erlang-runtime21: build failure with BSD crtbegin/crtend
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jimmy Olgeni
URL:
Keywords:
Depends on:
Blocks: 233056
  Show dependency treegraph
 
Reported: 2018-12-27 19:00 UTC by Ed Maste
Modified: 2019-01-07 14:40 UTC (History)
2 users (show)

See Also:


Attachments
Possible rtld fix (593 bytes, patch)
2018-12-28 11:53 UTC, Andrew Turner
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2018-12-27 19:00:08 UTC
gmake[5]: Entering directory '/wrkdirs/usr/ports/lang/erlang-runtime21/work/otp_src_21.2/erts/emulator'
if utils/gen_git_version i386-portbld-freebsd13.0/gen_git_version.mk; then touch beam/erl_bif_info.c; fi
echo " PROFILE beam.prof.smp"
 PROFILE beam.prof.smp
rm -f obj/i386-portbld-freebsd13.0/opt/smp/erl*.profraw
set -e; LLVM_PROFILE_FILE="obj/i386-portbld-freebsd13.0/opt/smp/erlc-%m.profraw" \
          ERL_FLAGS="-emu_type prof +S 1" erlc -W  -DPGO \
  -o obj/i386-portbld-freebsd13.0/opt/smp test/estone_SUITE.erl > obj/i386-portbld-freebsd13.0/opt/smp/PROFILE_LOG
dlsym: Resource temporarily unavailable
gmake[5]: *** [i386-portbld-freebsd13.0/Makefile:734: obj/i386-portbld-freebsd13.0/opt/smp/PROFILE] Abort trap (core dumped)
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/erlang-runtime21/work/otp_src_21.2/erts/emulator'
Comment 1 Bugzilla Automation freebsd_committer 2018-12-27 19:00:08 UTC
Maintainer informed via mail
Comment 2 Ed Maste freebsd_committer 2018-12-27 19:04:53 UTC
jilles points out on IRC that reporting errno after dlsym failure (as this is presumably doing) is invalid; the string returned by dlerror should be printed instead. The EAGAIN text likely has no direct relationship with the actual issue.
Comment 3 Andrew Turner freebsd_committer 2018-12-28 11:47:29 UTC
I've added extra debugging and found the problematic dlsym is in do_init in otp_src_21.2/erts/emulator/hipe/hipe_x86_signal.c.

This calls dlysym as follows:
  #define NEXT_SIGACTION "sigaction"
  ...
  next_sigaction = dlsym(RTLD_NEXT, NEXT_SIGACTION);

I added a printf with the dlerror string. This found the error to be:
  "Cannot determine caller's shared object"

That error is from rtld when obj_from_addr returns NULL. Looking with a debugger this seems to be because the map size is 0. This is because there is only one LOAD program header and rtld sets the size on the second and later LOAD headers.

I'm unsure why there is only one LOAD header as it is marked rwx. Adjusting the rtld logic fixes the build, however I'm unsure if we want to allow this from a security point of view (marking code as writeable).
Comment 4 Andrew Turner freebsd_committer 2018-12-28 11:53:15 UTC
Created attachment 200573 [details]
Possible rtld fix
Comment 5 Andrew Turner freebsd_committer 2019-01-07 14:40:56 UTC
This seems to be a bug in the base ld.bfd. If I link erlc with ld.lld I can complete the build, even without the rtld patch.