1. 17 Dec, 2020 2 commits
  2. 14 Mar, 2018 2 commits
    • Vincent Pelletier's avatar
      Do not use FILE *. · 1d3b463e
      Vincent Pelletier authored
      We may be called very early during runtime initialisation, so it does not
      seem wise to rely on libc-initialised structures. Instead, only rely on
      kernel-provided file descriptors.
      1d3b463e
    • Vincent Pelletier's avatar
      Tolerate open and fopen being called before our own constructor. · e42b7314
      Vincent Pelletier authored
      An easy example of this is coreutils' "ls", when linked against libselinux:
      libselinux will/may call fopen("/proc/filesystems", "re") during its own
      constructor, which may be called before our.
      Another example is inkscape, which contains static C++ classes (such as
      Inkscape::Util::UnitTable::UnitTable) which may themselves call (f)open.
      C++ runtime seems to call such static constructors before our contructor,
      leading to the same issue. GCC documentation (as of version 8.0.1) says:
        However, at present, the order in which constructors for C++ objects
        with static storage duration and functions decorated with attribute
        constructor are invoked is unspecified. In mixed declarations,
        attribute init_priority can be used to impose a specific ordering.
      e42b7314
  3. 11 Mar, 2016 2 commits
    • Julien Muchembled's avatar
    • Kazuhiko Shiozaki's avatar
      use -fPIC instead of -fPIE that causes SEGV on gcc 5. · a99ba6df
      Kazuhiko Shiozaki authored
      In my latest Ubuntu's gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2), userhosts causes SEGV. You can reproduce the issue with current SlapOS gcc-5.3.0 as well.
      
      ```
      $ gdb --args ./userhosts ls
      (gdb) run
      Starting program: /srv/slapgrid/slappart0/srv/runner/software/d65309081a071d10fa34fce376e82fd7/parts/userhosts/userhosts ls
      process 11758 is executing new program: /bin/ls
      [Thread debugging using libthread_db enabled]
      Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      COPYING  debian  Makefile  README  userhosts  userhosts.c
       
      Program received signal SIGSEGV, Segmentation fault.
      __fpending (fp=0x0) at __fpending.c:23
      23      __fpending.c: No such file or directory.
      (gdb) bt
      #0  __fpending (fp=0x0) at __fpending.c:23
      #1  0x0000000000411e4c in ?? ()
      #2  0x000000000040a075 in ?? ()
      #3  0x00007ffff7418d32 in __run_exit_handlers (status=0, listp=0x7ffff77a3698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
      #4  0x00007ffff7418d85 in __GI_exit (status=<optimised out>) at exit.c:104
      #5  0x0000000000404067 in ?? ()
      #6  0x00007ffff73ffa40 in __libc_start_main (main=0x4028a0, argc=1, argv=0x7fffffffeb48, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffeb38) at libc-start.c:289
      #7  0x0000000000404899 in ?? ()
      (gdb) bt full
      #0  __fpending (fp=0x0) at __fpending.c:23
      No locals.
      #1  0x0000000000411e4c in ?? ()
      No symbol table info available.
      #2  0x000000000040a075 in ?? ()
      No symbol table info available.
      #3  0x00007ffff7418d32 in __run_exit_handlers (status=0, listp=0x7ffff77a3698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
              atfct = <optimised out>
              onfct = <optimised out>
              cxafct = <optimised out>
              f = <optimised out>
      #4  0x00007ffff7418d85 in __GI_exit (status=<optimised out>) at exit.c:104
      No locals.
      #5  0x0000000000404067 in ?? ()
      No symbol table info available.
      #6  0x00007ffff73ffa40 in __libc_start_main (main=0x4028a0, argc=1, argv=0x7fffffffeb48, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffeb38) at libc-start.c:289
              result = <optimised out>
              unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -8764054844010181565, 4212848, 140737488350016, 0, 0, 8764055384653253699, 8764071327084268611}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x412420, 0x7fffffffeb48}, data = {prev = 0x0, cleanup = 0x0,
                    canceltype = 4269088}}}
              not_first_call = <optimised out>
      #7  0x0000000000404899 in ?? ()
      No symbol table info available.
      
      ```
      
      Using '-fPIC' instead of '-fPIE' solved the issue. I confirm that it works with this change on gcc-4.9 as well.
      
      /cc @vpelletier, @jm 
      
      /reviewed-on !1
      a99ba6df
  4. 08 Sep, 2014 1 commit
    • Vincent Pelletier's avatar
      Fix linker errors. · d3080ad4
      Vincent Pelletier authored
      Build failure reported on kubuntu 14.04:
      $ make
      cc  -O2 -s -Wall -fPIE -pie  -ldl -o userhosts userhosts.c
      /tmp/ccVLIqoI.o: In function `dlsym_or_abort.part.0':
      userhosts.c:(.text.startup+0x5): undefined reference to `dlerror'
      /tmp/ccVLIqoI.o: In function `init':
      userhosts.c:(.text.startup+0x42): undefined reference to `dlerror'
      userhosts.c:(.text.startup+0x55): undefined reference to `dlsym'
      userhosts.c:(.text.startup+0x69): undefined reference to `dlerror'
      userhosts.c:(.text.startup+0x7c): undefined reference to `dlsym'
      collect2: error: ld returned 1 exit status
      make: *** [userhosts] Error 1
      
      Fix's rationale seems to be provide -ldl *after* symbol need becomes known,
      so after source code is provided & built.
      d3080ad4
  5. 04 Sep, 2014 1 commit
  6. 29 Aug, 2014 1 commit
  7. 28 Aug, 2014 5 commits
  8. 27 Aug, 2014 3 commits
  9. 22 Aug, 2014 1 commit