Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 72a2e1bcc9f6
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 31c1d67ff986
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 18, 2014

  1. Copy the full SHA
    93ad8c5 View commit details
  2. Copy the full SHA
    31c1d67 View commit details
Showing with 145 additions and 27 deletions.
  1. +22 −14 library/rubinius/configuration.rb
  2. +12 −4 vm/console.cpp
  3. +2 −2 vm/environment.cpp
  4. +107 −7 vm/signal.cpp
  5. +2 −0 vm/signal.hpp
36 changes: 22 additions & 14 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
@@ -167,25 +167,33 @@
c.vm_variable "system.tmp", "$TMPDIR",
"Default temp/fallback directory for the process"

c.vm_variable "system.fsapi_path", "$TMPDIR",
"Base directory of the Rubinius File System API files"
c.section "system" do |s|
s.vm_variable "fsapi.path", "$TMPDIR",
"Base directory of the Rubinius File System API files"

c.vm_variable "system.log", "/var/log/$PROGRAM_NAME.log",
"Logging facility to use: 'syslog', 'console', or path"
s.vm_variable "fsapi.access", 0750,
"Permissions on the Rubinius File System API directory"

c.vm_variable "system.log.level", "warn",
"Logging level: fatal, error, warn, info, debug"
s.vm_variable "console.access", 0660,
"Permissions on the Rubinius Console files"

c.vm_variable "system.metrics.interval", 10000,
"Number of milliseconds between aggregation of VM metrics"
s.vm_variable "log", "/var/log/$PROGRAM_NAME.log",
"Logging facility to use: 'syslog', 'console', or path"

c.vm_variable "system.metrics.target", "none",
"Location to send metrics every interval: 'statsd', 'disk'"
s.vm_variable "log.level", "warn",
"Logging level: fatal, error, warn, info, debug"

c.vm_variable "system.metrics.statsd.server", "localhost:8125",
"The [host:]port of the StatsD server"
s.vm_variable "metrics.interval", 10000,
"Number of milliseconds between aggregation of VM metrics"

c.vm_variable "system.metrics.statsd.prefix", "host.$nodename.app.rbx",
"Prefix for StatsD metric names"
s.vm_variable "metrics.target", "none",
"Location to send metrics every interval: 'statsd', 'disk'"

s.vm_variable "metrics.statsd.server", "localhost:8125",
"The [host:]port of the StatsD server"

s.vm_variable "metrics.statsd.prefix", "host.$nodename.app.rbx",
"Prefix for StatsD metric names"
end
end

16 changes: 12 additions & 4 deletions vm/console.cpp
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@

#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>

#include <stdio.h>

@@ -129,19 +131,25 @@ namespace rubinius {
String::create(state, response_path_.c_str()));
}

static int open_file(std::string path) {
int fd = ::open(path.c_str(), O_CREAT | O_TRUNC | O_RDWR | O_SYNC | O_CLOEXEC, 0666);
static int open_file(STATE, std::string path) {
int perms = state->shared().config.system_console_access;
int fd = ::open(path.c_str(), O_CREAT | O_TRUNC | O_RDWR | O_SYNC | O_CLOEXEC, perms);

if(fd < 0) {
logger::error("%s: console: unable to open: %s", strerror(errno), path.c_str());
}

// The umask setting will override our permissions for open().
if(chmod(path.c_str(), perms) < 0) {
logger::error("%s: console: unable to set mode: %s", strerror(errno), path.c_str());
}

return fd;
}

void Console::setup_files(STATE) {
request_fd_ = open_file(request_path_);
response_fd_ = open_file(response_path_);
request_fd_ = open_file(state, request_path_);
response_fd_ = open_file(state, response_path_);

FSEvent* fsevent = FSEvent::create(state);
fsevent->watch_file(state, request_fd_, request_path_.c_str());
4 changes: 2 additions & 2 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -502,12 +502,12 @@ namespace rubinius {
}

void Environment::create_fsapi(STATE) {
if(mkdir(shared->fsapi_path.c_str(), 0755) < 0) {
if(mkdir(shared->fsapi_path.c_str(), shared->config.system_fsapi_access) < 0) {
utilities::logger::error("%s: unable to create FSAPI path", strerror(errno));
}

// The umask setting will override our permissions for mkdir().
if(chmod(shared->fsapi_path.c_str(), 0755) < 0) {
if(chmod(shared->fsapi_path.c_str(), shared->config.system_fsapi_access) < 0) {
utilities::logger::error("%s: unable to set mode for FSAPI path", strerror(errno));
}
}
114 changes: 107 additions & 7 deletions vm/signal.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#include "config.h"
#include "vm.hpp"
#include "call_frame.hpp"
#include "environment.hpp"
#include "signal.hpp"
#include "configuration.hpp"

#include "builtin/module.hpp"
#include "builtin/array.hpp"

#include "builtin/array.hpp"
#include "builtin/module.hpp"
#include "builtin/class.hpp"
#include "builtin/constant_scope.hpp"
#include "builtin/module.hpp"
#include "builtin/native_method.hpp"
#include "builtin/string.hpp"
#include "builtin/thread.hpp"

#include <string>
@@ -283,6 +288,97 @@ namespace rubinius {
return true;
}

void SignalHandler::print_backtraces() {
STATE = shared_.env()->state;
ThreadList* threads = shared_.threads();

for(ThreadList::iterator i = threads->begin(); i != threads->end(); ++i) {
VM* vm = (*i)->as_vm();
if(!vm) continue;

if(vm->saved_call_frame()) {
utilities::logger::fatal("--- Thread %d backtrace ---", vm->thread_id());
}

for(CallFrame* frame = vm->saved_call_frame(); frame; frame = frame->previous) {
std::ostringstream stream;

if(NativeMethodFrame* nmf = frame->native_method_frame()) {
stream << static_cast<void*>(frame) << ": ";
NativeMethod* nm = try_as<NativeMethod>(nmf->get_object(nmf->method()));
if(nm && nm->name()->symbol_p()) {
stream << "capi:" << nm->name()->debug_str(state) << " at ";
stream << nm->file()->c_str(state);
} else {
stream << "unknown capi";
}
} else if(frame->compiled_code) {
if(frame->is_block_p(state)) {
stream << "__block__";
} else {
if(SingletonClass* sc = try_as<SingletonClass>(frame->module())) {
Object* obj = sc->attached_instance();

if(Module* mod = try_as<Module>(obj)) {
stream << mod->debug_str(state) << ".";
} else {
if(obj == G(main)) {
stream << "MAIN.";
} else {
stream << "#<" << obj->class_object(state)->debug_str(state) <<
":" << (void*)obj->id(state)->to_native() << ">.";
}
}
} else if(IncludedModule* im = try_as<IncludedModule>(frame->module())) {
stream << im->module()->debug_str(state) << "#";
} else {
Symbol* name;
std::string mod_name;

if(frame->module()->nil_p()) {
mod_name = frame->constant_scope()->module()->debug_str(state);
} else {
if((name = try_as<Symbol>(frame->module()->module_name()))) {
mod_name = name->debug_str(state);
} else if((name = try_as<Symbol>(
frame->constant_scope()->module()->module_name()))) {
mod_name = name->debug_str(state);
} else {
mod_name = "<anonymous module>";
}
}
stream << mod_name << "#";
}

Symbol* name = try_as<Symbol>(frame->name());
if(name) {
stream << name->debug_str(state);
} else {
stream << frame->compiled_code->name()->debug_str(state);
}
}

stream << " in ";
if(Symbol* file_sym = try_as<Symbol>(frame->compiled_code->file())) {
stream << file_sym->debug_str(state) << ":" << frame->line(state);
} else {
stream << "<unknown>";
}

stream << " (+" << frame->ip();
if(frame->is_inline_frame()) {
stream << " inline";
} else if(frame->jitted_p()) {
stream << " jit";
}
stream << ")";
}

utilities::logger::fatal(stream.str().c_str());
}
}
}

static void null_func(int sig) {}

#ifdef USE_EXECINFO
@@ -332,12 +428,6 @@ namespace rubinius {

logger::fatal("The Rubinius process is aborting with signal: %s",
rbx_signal_string(sig));
logger::fatal("--- begin system backtrace ---");
for(i = 0; i < frames; i++) {
logger::fatal("%s", symbols[i]);
}
logger::fatal("--- end system backtrace ---");

logger::fatal("--- begin system info ---");
logger::fatal("sysname: %s", machine_info.sysname);
logger::fatal("nodename: %s", machine_info.nodename);
@@ -346,6 +436,16 @@ namespace rubinius {
logger::fatal("machine: %s", machine_info.machine);
logger::fatal("--- end system info ---");

logger::fatal("--- begin system backtrace ---");
for(i = 0; i < frames; i++) {
logger::fatal("%s", symbols[i]);
}
logger::fatal("--- end system backtrace ---");

logger::fatal("--- begin Ruby backtraces ---");
signal_handler_->print_backtraces();
logger::fatal("--- end Ruby backtraces ---");

raise(sig);
}
#endif
2 changes: 2 additions & 0 deletions vm/signal.hpp
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ namespace rubinius {

bool deliver_signals(STATE, CallFrame* call_frame);

void print_backtraces();

void open_pipes();
void start_thread(STATE);
void stop_thread(STATE);