Skip to content
Snippets Groups Projects
  1. Jan 02, 2014
  2. Dec 30, 2013
  3. Dec 18, 2013
  4. Dec 15, 2013
  5. Dec 12, 2013
  6. Dec 09, 2013
  7. Dec 05, 2013
  8. Nov 26, 2013
  9. Oct 24, 2013
  10. Oct 23, 2013
  11. Oct 14, 2013
  12. Oct 07, 2013
  13. Sep 25, 2013
    • Nadav Har'El's avatar
      C++ runtime: shared-object static destructors · 4bc7f599
      Nadav Har'El authored
      
      GCC implements static destructors in shared-objects (DSO) by registering a
      single finalization function, __cxa_finalize(), to run when the DSO is
      unloaded, and each constructor calls __cxa_atexit() to register a destructor
      which __cxa_finalize() should call.
      
      This patch implements the missing __cxa_finalize() and __cxa_atexit()
      functions. The do-nothing stubs we had never registered, and never ran,
      destructors. The implementation in this patch is amazingly simple to
      write in C++11 :-)
      
      Before this fix, we had a crash when running tst-tracepoint.so twice:
      The first run ran the tracepoints' constructors, which added to the global
      linked list of tracepoints pointers into the mapped DSO. When the DSO
      was later unmapped but destructors not run, the linked list of tracepoints
      was left with pointers to unmapped memory. When we ran the test again,
      and it wanted to construct more tracepoints, it accessed the broken linked
      list and crashed.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      4bc7f599
    • Nadav Har'El's avatar
      Add stub setresuid(), setresgid() · b0aa3470
      Nadav Har'El authored
      
      Add to libc/user.cc stub setresgid(), setresgid(), which as usual in
      OSv only allow user and group 0. These functions are used by Rogue ;-)
      
      Also move getuid() and friends from runtime.cc to libc/user.cc, where
      they feel more at home.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      b0aa3470
  14. Sep 17, 2013
    • Nadav Har'El's avatar
      Remove unnecessarily copied structure · b0c8bf2a
      Nadav Har'El authored
      runtime.cc included a verbatim copy of the structure __locale_data
      from glibc. We don't need it (not to mention that we're not supposed
      to copy anything from glibc, it has the wrong license).
      
      We previously believed that libstdc++ pokes into this structure, so it
      needs to be in the exact format of glibc, but now I believe this is not
      the case, and it only uses __nl_langinfo_l, which in our implementation
      doesn't even adhere to the locale, and just uses the C locale.
      b0c8bf2a
  15. Sep 15, 2013
  16. Sep 14, 2013
  17. Aug 27, 2013
    • Nadav Har'El's avatar
      Fix mincore() on non-mmap()ed memory · 6924f7db
      Nadav Har'El authored
      Commit 65afd075 fixed mincore() to recognize
      unmapped addresses. However, it used mmu::ismapped() which just checks for
      mmap()'ed addresses, and doesn't know about malloc()ed memory. This causes
      trouble for libunwind (which we use for backtrace()) which tests mincore()
      on an on-stack variable, and for non-pthread threads, this stack might be
      malloc'ed, not mmap'ed.
      
      So this patch adds mmu::isreadable(), which checks that a given memory range
      is all readable (this memory can be mmapped, malloced, stack, whatever).
      mincore() now uses that.
      
      mmu::isreadable() is implemented, following Avi's idea, by trying to read,
      with safe_load(), one byte from every page in the range. This approach is
      faster than page-table-walking especially for one-byte checks (which all
      libunwind uses anyway), and also very simple.
      6924f7db
  18. Aug 26, 2013
    • Pekka Enberg's avatar
      runtime: Fix mincore() on an unmapped address · 65afd075
      Pekka Enberg authored
      Fix mincore() to deal with unmapped addresses like msync() does.
      
      This fixes a SIGSEGV in libunwind's access_mem() when leak detector is
      enabled:
      
         (gdb) bt
        #0  page_fault (ef=0xffffc0003ffe7008) at ../../core/mmu.cc:871
        #1  <signal handler called>
        #2  ContiguousSpace::block_start_const (this=<optimized out>, p=0x77d2f3968)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/oops/oop.inline.hpp:411
        #3  0x00001000008ae16c in GenerationBlockStartClosure::do_space (this=0x2000001f9100, s=<optimized out>)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/generation.cpp:242
        #4  0x00001000007f097c in DefNewGeneration::space_iterate (this=0xffffc0003fb68c00, blk=0x2000001f9100, usedOnly=<optimized out>)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/defNewGeneration.cpp:480
        #5  0x00001000008aca0e in Generation::block_start (this=<optimized out>, p=<optimized out>)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/generation.cpp:251
        #6  0x0000100000b06d2f in os::print_location (st=st@entry=0x2000001f9560, x=32165017960, verbose=verbose@entry=false)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/runtime/os.cpp:868
        #7  0x0000100000b11b5b in os::print_register_info (st=0x2000001f9560, context=0x2000001f9740)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:839
        #8  0x0000100000c6cde8 in VMError::report (this=0x2000001f9610, st=st@entry=0x2000001f9560)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:551
        #9  0x0000100000c6da3b in VMError::report_and_die (this=this@entry=0x2000001f9610)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:984
        #10 0x0000100000b1109f in JVM_handle_linux_signal (sig=11, info=0x2000001f9bb8, ucVoid=0x2000001f9740,
            abort_if_unrecognized=<optimized out>)
            at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:528
        #11 0x000000000039f242 in call_signal_handler (frame=0x2000001f9b10) at ../../arch/x64/signal.cc:69
        #12 <signal handler called>
        #13 0x000000000057d721 in access_mem ()
        #14 0x000000000057cb1d in dwarf_get ()
        #15 0x000000000057ce51 in _ULx86_64_step ()
        #16 0x00000000004315fd in backtrace (buffer=0x1ff9d80 <memory::alloc_tracker::remember(void*, int)::bt>, size=20)
            at ../../libc/misc/backtrace.cc:16
        #17 0x00000000003b8d99 in memory::alloc_tracker::remember (this=0x1777ae0 <memory::tracker>, addr=0xffffc0004508de00, size=54)
            at ../../core/alloctracker.cc:59
        #18 0x00000000003b0504 in memory::tracker_remember (addr=0xffffc0004508de00, size=54) at ../../core/mempool.cc:43
        #19 0x00000000003b2152 in std_malloc (size=54) at ../../core/mempool.cc:723
        #20 0x00000000003b259c in malloc (size=54) at ../../core/mempool.cc:856
        #21 0x0000100001615e4c in JNU_GetStringPlatformChars (env=env@entry=0xffffc0003a4dc1d8, jstr=jstr@entry=0xffffc0004591b800,
            isCopy=isCopy@entry=0x0) at ../../../src/share/native/common/jni_util.c:801
        #22 0x000010000161ada6 in Java_java_io_UnixFileSystem_getBooleanAttributes0 (env=0xffffc0003a4dc1d8, this=<optimized out>,
            file=<optimized out>) at ../../../src/solaris/native/java/io/UnixFileSystem_md.c:111
        #23 0x000020000021ed8e in ?? ()
        #24 0x00002000001faa58 in ?? ()
        #25 0x00002000001faac0 in ?? ()
        #26 0x00002000001faa50 in ?? ()
        #27 0x0000000000000000 in ?? ()
      
      Spotted by Avi Kivity.
      65afd075
  19. Aug 22, 2013
  20. Aug 14, 2013
  21. Aug 12, 2013
    • Avi Kivity's avatar
      build: link libstdc++, libgcc_s only once · c9e61d4a
      Avi Kivity authored
      Currently we statically link to libstdc++ and libgcc_s, and also dynamically
      link to the same libraries (since the payload requires them).  This causes
      some symbols to be available from both the static and dynamic version.
      
      With the resolution order change introduced by 82513d41, we can
      resolve the same symbol to different addresses at different times.  This
      violates the One Definition Rule, and in fact breaks std::string's
      destructor.
      
      Fix by only linking in the libraries statically.  We use ld's --whole-archive
      flag to bring in all symbols, including those that may be used by the payload
      but not by the kernel.
      
      Some symbols now become duplicates; we drop our version.
      c9e61d4a
    • Avi Kivity's avatar
      runtime: add get_nprocs() · 286dd7a0
      Avi Kivity authored
      Needed to link the entirety of libstdc++.a.
      286dd7a0
  22. Aug 06, 2013
  23. Jul 27, 2013
    • Glauber Costa's avatar
      stub fork and vfork · 60a5b5fa
      Glauber Costa authored
      We will never implement them as is. But some code will still insist in calling them.
      Our best effort is to return an error, and hope the code copes well with it.
      60a5b5fa
  24. Jul 11, 2013
    • Glauber Costa's avatar
      stub mlock and mlockall · e0948398
      Glauber Costa authored
      No plans in sight to page out anonymous memory, so for now, stub this.
      We may have to revisit this once we support proper mmap semantics, specially
      with ranged mlock/munlock
      e0948398
  25. Jun 09, 2013
    • Nadav Har'El's avatar
      Add, and use, new abort(msg) function · e6208f1e
      Nadav Har'El authored
      Recently Guy fixed abort() so it will *really* not infinitely recurse trying
      to print a message, using a lock, causing a new abort, ad infinitum.
      
      Unfortunately, that didn't fix one remaining case: DUMMY_HANDLER (see
      exceptions.cc) used the idiom
      
              debug(....); abort();
      
      which can again cause infinite recursion - a #GP calls debug() which causes a
      new #GP, which again calls debug, etc.
      
      Instead of the above broken idiom, created a new function abort(msg), which is
      just like the familiar abort(), just changes the "Aborted" message to some
      other message (a constant string). Like abort(), the new variant abort(msg) will
      only print the message once even if called recursively - and uses a lockless
      version of debug().
      
      Note that the new abort(msg) is a C++-only API. C will only see the abort(void)
      which is extern "C". At first I wanted to call the new function panic(msg) and
      export it to C, but gave when I saw the name panic() was already in use in a
      bunch of BSD code.
      e6208f1e
  26. May 29, 2013
    • Nadav Har'El's avatar
      Don't abort on unknown sysconf. · 05c34106
      Nadav Har'El authored
      Don't abort on an unimplemented sysconf parameter. One of the documented
      functions of sysconf(3) is to "test ... whether certain options are
      supported", so programs are free to test for features we don't support
      yet, and we're supposed to return -1 with errno set to EINVAL.
      
      For example, Boost tested _SC_THREAD_SAFE_FUNCTIONS which we didn't
      support. It would have been fine if we set EINVAL (it would switch
      from *_r functions to the non-reenatrant ones) - but it wasn't fine
      that we abort()ed because of this test :-)
      
      To be on the safe side, this patch still prints a message if we see an
      unknown sysconf - in case in the future we'll come across a new one we
      must treat. But eventually, the message should go away too.
      05c34106
    • Nadav Har'El's avatar
      Implement _SC_THREAD_SAFE_FUNCTIONS sysconf · a25cb86b
      Nadav Har'El authored
      Implement the _SC_THREAD_SAFE_FUNCTIONS sysconf, returning 1.
      
      _SC_THREAD_SAFE_FUNCTIONS is defined in Posix 1003.1c ("posix threads"),
      and is supposed to return 1 if the thread-safe functions option is
      supported (*_r() functions). Since we do implement those, we should return
      1 for this sysconf.
      
      Boost's system library uses this sysconf, and if it sees it is not
      available, restorts to the _r()-less variants, for no good reason.
      a25cb86b
  27. May 27, 2013
    • Guy Zana's avatar
      debug: introduce debug_ll() and use it in abort() · 6ebb582e
      Guy Zana authored
      the debug() console function is taking a lock before it access the console driver,
      it does that by acquiring a mutex which may sleep.
      
      since we want to be able to debug (and abort) in contexts where it's not possible sleep,
      such as in page_fault, a lockless debug print method is introduced.
      
      previousely to this patch, any abort on page_fault would cause an "endless" recursive
      abort() loop which hanged the system in a peculiar state.
      6ebb582e
    • Guy Zana's avatar
      abort: debug() may cause an abort() as well · 9ef87755
      Guy Zana authored
      the current code handles the case of recursive aborts incorrectly, while
      the existing comment is very precise :)
      9ef87755
  28. May 22, 2013
    • Nadav Har'El's avatar
      Use osv::hang() in abort() · 17a79e66
      Nadav Har'El authored
      abort() did the same thing as the new osv::hang(), so let's just use
      osv::hang(). Note that it's important that osv::hang() doesn't print
      anything - abort() does, but avoids infinite recursion that can happen
      when abort()'s printing itself causes a crash, and another abort().
      17a79e66
  29. May 18, 2013
  30. May 02, 2013
  31. Apr 24, 2013
Loading