Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
require 'set'
module ActiveRecord
class Base
attr_accessor :scrooge_callsite,
:scrooge_callsite_set,
:scrooge_own_callsite_set
@@scrooge_mutex = Mutex.new
# Define an attribute reader method. Cope with nil column.
def define_read_method(symbol, attr_name, column)
cast_code = column.type_cast_code('v') if column
access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']"
unless attr_name.to_s == self.primary_key.to_s
access_code = access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ")
end
if cache_attribute?(attr_name)
VALUE
rb_obj_clone(obj)
VALUE obj;
{
VALUE clone;
if (rb_special_const_p(obj)) {
rb_raise(rb_eTypeError, "can't clone %s", rb_obj_classname(obj));
}
clone = rb_obj_alloc(rb_obj_class(obj));
(gdb) run -e 'Thread.new{ Fiber.new{} }.join'
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /Users/lourens/projects/ruby187/miniruby -e 'Thread.new{ Fiber.new{} }.join'
miniruby(29493) malloc: *** error for object 0x803e00: double free
*** set a breakpoint in malloc_error_break to debug
Breakpoint 1, 0x9452b4a9 in malloc_error_break ()
(gdb) bt
#0 0x9452b4a9 in malloc_error_break ()
(gdb) b eval.c : 10544
Breakpoint 2 at 0x330ba: file eval.c, line 10545.
(gdb) run -e 'Thread.new{ Fiber.new{p 1}.resume }'
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /Users/lourens/projects/ruby187/miniruby -e 'Thread.new{ Fiber.new{p 1}.resume }'
Breakpoint 2, rb_thread_save_context (th=0x802000) at eval.c:10545
10545 len = ruby_stack_length(&pos);
(gdb) p len
macbook-pros-computer:ruby187 lourens$ gdb miniruby
GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct 2 04:07:49 UTC 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries .... done
(gdb) break malloc_error_break
macbook-pros-computer:ruby187 lourens$ gdb miniruby
GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct 2 04:07:49 UTC 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries .... done
(gdb) break malloc_error_break
static void
fiber_link_join(rb_fiber_t *fib)
{
VALUE current_fibval = rb_fiber_current();
rb_fiber_t *current_fib;
GetFiberPtr(current_fibval, current_fib);
/* join fiber link */
fib->next_fiber = current_fib->next_fiber;
fib->prev_fiber = current_fib;
current_fib->next_fiber = fib;
def output_single(something, level=NORMAL)
@io.write(something) if (output?(level))
@io.flush
end
##
# Select whether or not to use the pretty-printer. If this option is set
# to false before any assertions are made, pp.rb will not be required.
public
def self.use_pp=(value)
AssertionMessage.use_pp = value
end