Skip to content
Snippets Groups Projects
  1. Sep 26, 2013
  2. Sep 25, 2013
    • Nadav Har'El's avatar
      signal() off-by-one argument check · 9871d993
      Nadav Har'El authored
      
      signal() verified that its argument is not >nsigs, but it should be >=nsigs
      because nsigs itself is already illegal (0...nsigs-1 are valid signals).
      
      Discovered by Coverity.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      9871d993
    • 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
      Dynamic linker: run finalizers when unloading shared object · bf0688f4
      Nadav Har'El authored
      
      ELF allows specifying initializers - functions to be run after loading a
      a shared object, in DT_INIT_ARRAY, and also finalizers - functions to be
      run before unloading a shared objects, in DT_FINI_ARRAY. The existing code
      ran the initializers, but forgot to run the finalizers, and this patch
      fixes this oversight.
      
      This fix is necessary for destructors of static objects defined in the
      shared object. But this fix is not sufficient for C++ destructors - see
      also the next patch.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      bf0688f4
    • 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
    • Nadav Har'El's avatar
      Fix bug in "cscope" make target · 0159034a
      Nadav Har'El authored
      
      The "cscope" make target piped a list of files into "cscope -bq", but
      this command doesn't read its input. The command should be "cscope -bq -i-"
      which reads the list of files from stdin.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      0159034a
    • Dmitry Fleytman's avatar
  3. Sep 24, 2013
  4. Sep 23, 2013
    • Nadav Har'El's avatar
      Makefile: Don't hide Gradle's progress · c0ae1bbe
      Nadav Har'El authored
      
      Currently, OSv's "make" builds both the kernel, using a normal Makefile,
      and the sample management framework, using the "Gradle" tool.
      
      We carefully hid Gradle's progress under one output line "GRADLE", but
      this leads to the "make" process hanging for a long time - up to several
      minutes, and all the puzzled user sees is the line "GRADLE". Users who
      didn't go for coffee will likely kill the build at this point ;-) Even
      worse, when Gradle fails, or just hangs (e.g., a bad or slow network
      connection), the user won't even know why.
      
      So let's just run Gradle normally, and let the user see its full output.
      This output is rather pretty and organized, so no real reason to hide it.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      c0ae1bbe
    • Nadav Har'El's avatar
      Clean up "tags" and "TAGS" target · ea6a0dca
      Nadav Har'El authored
      
      Each of the "tags" and "TAGS" make targets was done in a different way,
      causing each to have a different problem:
      
       1. "tags" (ctags) used the "-L" option which turns out is nonportable
          (only available in Exuberant Ctags).
       2. "TAGS" (etags) ran the etags command separately for each source file,
          slowing it down.
      
      The best of both worlds is to use xargs to have ctags/etags operate on
      multiple files in each run using xargs. Because we cannot be sure xargs
      will run ctags/etags only once, we must delete the file first and use
       the "-a" (append) option.
      
      Also, this patch reduces code duplication - there is now one rule for
      both "tags" and "TAGS" targets that uses the correct tool (ctags or etags,
      respectively).
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      ea6a0dca
    • Nadav Har'El's avatar
      Merge pull request #41 from jnider/master · f771d2cf
      Nadav Har'El authored
      Update devices-and-drivers.txt
      f771d2cf
    • Nadav Har'El's avatar
      Our select() function is emulated using poll(), which is a sensible thing · b53d39ac
      Nadav Har'El authored
      to do. However, it did several things wrong that this patch fixes. Thanks
      to Paolo Bonzini for finding these problems (see issue #35).
      
      1. When poll() returned a bare POLLHUP, without POLLIN, our select() didn't
      return a read event. But nothing in the manpages guarantees that POLLHUP
      is accompanied by POLLIN, and some special file implementations might
      forget it. As an example, in Linux POLLHUP without POLLIN is common.
      But POLLHUP on its own already means that there's nothing more to read,
      so a read() will return immediately without blocking - and therefore
      select() needs to turn on the readable bit for this fd.
      
      2. Similarly, a bare POLLRDHUP should turn on the writable bit: The
      reader on this file hug up, so a write will fail immediately.
      
      3. Our poll() and select() confused what POLLERR means. POLLERR does not
      mean poll() found a bad file descriptor - there is POLLNVAL for that.
      So this patch fixes poll() to set POLLNVAL, not POLLERR, and select()
      to return with errno=EBADF when it sees POLLNVAL, not POLLERR.
      
      4. Rather, POLLERR means the file descriptor is in an error state, so every
      read() or write() will return immediately (with an error). So when we see
      it, we need to turn on both read and write bits in this case.
      
      5. The meaning of "exceptfds" isn't clear in any manual page, and it
      seems there're a lot of opinions on what it might mean. In this patch I
      did what Paolo suggested, which is to set the except bit when POLLPRI.
      (I don't set exceptfds on POLLERR, or any other case).
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      b53d39ac
  5. Sep 22, 2013
  6. Sep 21, 2013
  7. Sep 20, 2013
Loading