Module: Bug

Defined in:
ext/-test-/file/init.c,
ext/-test-/hash/init.c,
ext/-test-/iter/init.c,
ext/-test-/proc/init.c,
ext/-test-/time/init.c,
ext/-test-/class/init.c,
ext/-test-/debug/init.c,
ext/-test-/econv/init.c,
ext/-test-/float/init.c,
ext/-test-/vm/at_exit.c,
ext/-test-/bignum/init.c,
ext/-test-/method/init.c,
ext/-test-/regexp/init.c,
ext/-test-/string/init.c,
ext/-test-/struct/init.c,
ext/-test-/symbol/init.c,
ext/-test-/bug-3571/bug.c,
ext/-test-/bug-5832/bug.c,
ext/-test-/integer/init.c,
ext/-test-/rational/rat.c,
ext/-test-/exception/init.c,
ext/-test-/fatal/rb_fatal.c,
ext/-test-/notimplement/bug.c,
ext/-test-/st/foreach/foreach.c,
ext/-test-/win32/console/init.c,
ext/-test-/array/resize/resize.c,
ext/-test-/bug-14834/bug-14384.c,
ext/-test-/scan_args/scan_args.c,
ext/-test-/typeddata/typeddata.c,
ext/-test-/load/protect/protect.c,
ext/-test-/tracepoint/tracepoint.c,
ext/-test-/cxxanyargs/cxxanyargs.cpp,
ext/-test-/array/concat/to_ary_concat.c,
ext/-test-/enumerator_kw/enumerator_kw.c,
ext/-test-/postponed_job/postponed_job.c,
ext/-test-/rb_call_super_kw/rb_call_super_kw.c,
ext/-test-/gvl/call_without_gvl/call_without_gvl.c,
ext/-test-/thread/instrumentation/instrumentation.c

Defined Under Namespace

Modules: Class, Debug, EnumeratorKw, File, Iter, Method, Proc, Rational, RbCallSuperKw, ScanArgs, Thread, ThreadInstrumentation, Win32 Classes: Array, Bar, Bignum, Exception, Float, Hash, Integer, NotImplement, Regexp, String, Struct, Symbol, Time, TypedData, VM

Class Method Summary collapse

Class Method Details

.bug_14834Object

.call(*args) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'ext/-test-/printf/printf.c', line 34

static VALUE
printf_test_call(int argc, VALUE *argv, VALUE self)
{
    VALUE opt, type, num, result;
    char format[sizeof(int) * 6 + 8], *p = format, cnv;
    int n = 0;
    const char *s = 0;

    rb_scan_args(argc, argv, "2:", &type, &num, &opt);
    Check_Type(type, T_STRING);
    if (RSTRING_LEN(type) != 1) rb_raise(rb_eArgError, "wrong length(%ld)", RSTRING_LEN(type));
    switch (cnv = RSTRING_PTR(type)[0]) {
      case 'd': case 'x': case 'o': case 'X':
        n = NUM2INT(num);
        break;
      case 's':
        s = StringValueCStr(num);
        break;
      default: rb_raise(rb_eArgError, "wrong conversion(%c)", cnv);
    }
    *p++ = '%';
    if (!NIL_P(opt)) {
        VALUE v;
        Check_Type(opt, T_HASH);
        if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("space"))))) {
            *p++ = ' ';
        }
        if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("hash"))))) {
            *p++ = '#';
        }
        if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("plus"))))) {
            *p++ = '+';
        }
        if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("minus"))))) {
            *p++ = '-';
        }
        if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("zero"))))) {
            *p++ = '0';
        }
        if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("width"))))) {
            p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
        }
        if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("prec"))))) {
            *p++ = '.';
            if (FIXNUM_P(v))
                p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
        }
    }
    *p++ = cnv;
    *p++ = '\0';
    if (cnv == 's') {
        result = rb_enc_sprintf(rb_usascii_encoding(), format, s);
    }
    else {
        result = rb_enc_sprintf(rb_usascii_encoding(), format, n);
    }
    return rb_assoc_new(result, rb_usascii_str_new_cstr(format));
}

.dlntestObject



5
6
7
8
9
10
# File 'ext/-test-/win32/dln/dlntest.c', line 5

static VALUE
dln_dlntest(VALUE self)
{
    dlntest_ordinal();
    return self;
}

.funcall(*args) ⇒ Object



3
4
5
6
7
8
# File 'ext/-test-/notimplement/bug.c', line 3

static VALUE
bug_funcall(int argc, VALUE *argv, VALUE self)
{
    if (argc < 1) rb_raise(rb_eArgError, "not enough argument");
    return rb_funcallv(self, rb_to_id(*argv), argc-1, argv+1);
}

.funcall_callback(obj) ⇒ Object



3
4
5
6
7
# File 'ext/-test-/bug-5832/bug.c', line 3

static VALUE
bug_funcall_callback(VALUE self, VALUE obj)
{
    return rb_funcall(obj, rb_intern("callback"), 0);
}

.load_protect(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'ext/-test-/load/protect/protect.c', line 3

static VALUE
load_protect(int argc, VALUE *argv, VALUE self)
{
    int state;
    VALUE path, wrap;
    rb_scan_args(argc, argv, "11", &path, &wrap);
    rb_load_protect(path, RTEST(wrap), &state);
    if (state) rb_jump_tag(state);
    return Qnil;
}

.notimplementObject

.postponed_job_call_direct(obj) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'ext/-test-/postponed_job/postponed_job.c', line 70

static VALUE
pjob_call_direct(VALUE self, VALUE obj)
{
    counter = 0;
    pjob_callback((void *)obj);
    rb_gc_start();
    counter++;
    rb_gc_start();
    counter++;
    rb_gc_start();
    counter++;
    return self;
}

.postponed_job_preregister_and_call_with_sleep(obj) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'ext/-test-/postponed_job/postponed_job.c', line 136

static VALUE
pjob_preregister_and_call_with_sleep(VALUE self, VALUE obj)
{
    counter = 0;
    rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
    counter++;
    rb_postponed_job_trigger(h);
    rb_thread_sleep(0);
    counter++;
    rb_postponed_job_trigger(h);
    rb_thread_sleep(0);
    counter++;
    rb_postponed_job_trigger(h);
    rb_thread_sleep(0);
    return self;
}

.postponed_job_preregister_and_call_without_sleep(obj) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
# File 'ext/-test-/postponed_job/postponed_job.c', line 153

static VALUE
pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
{
    counter = 0;
    rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
    counter = 3;
    rb_postponed_job_trigger(h);
    rb_postponed_job_trigger(h);
    rb_postponed_job_trigger(h);
    return self;
}

.postponed_job_preregister_calls_with_last_argumentObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'ext/-test-/postponed_job/postponed_job.c', line 191

static VALUE
pjob_preregister_calls_with_last_argument(VALUE self)
{
    VALUE ary = rb_ary_new();

    struct pjob_append_data_args arg1 = { .ary = ary, .data = INT2FIX(1) };
    struct pjob_append_data_args arg2 = { .ary = ary, .data = INT2FIX(2) };
    struct pjob_append_data_args arg3 = { .ary = ary, .data = INT2FIX(3) };
    struct pjob_append_data_args arg4 = { .ary = ary, .data = INT2FIX(4) };

    rb_postponed_job_handle_t h;
    h = rb_postponed_job_preregister(0, pjob_append_data_callback, &arg1);
    rb_postponed_job_preregister(0, pjob_append_data_callback, &arg2);
    rb_postponed_job_trigger(h);
    rb_postponed_job_preregister(0, pjob_append_data_callback, &arg3);
    rb_thread_sleep(0); // should execute with arg3

    rb_postponed_job_preregister(0, pjob_append_data_callback, &arg4);
    rb_postponed_job_trigger(h);
    rb_thread_sleep(0); // should execute with arg4

    return ary;
}

.postponed_job_preregister_multiple_timesObject



165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'ext/-test-/postponed_job/postponed_job.c', line 165

static VALUE
pjob_preregister_multiple_times(VALUE self)
{
    int r1 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
    int r2 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
    int r3 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
    VALUE ary = rb_ary_new();
    rb_ary_push(ary, INT2FIX(r1));
    rb_ary_push(ary, INT2FIX(r2));
    rb_ary_push(ary, INT2FIX(r3));
    return ary;

}

.postponed_job_register(obj) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'ext/-test-/postponed_job/postponed_job.c', line 38

static VALUE
pjob_register(VALUE self, VALUE obj)
{
    counter = 0;
    rb_postponed_job_register(0, pjob_callback, (void *)obj);
    rb_gc_start();
    counter++;
    rb_gc_start();
    counter++;
    rb_gc_start();
    counter++;
    return self;
}

.postponed_job_register_in_c_thread(obj) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'ext/-test-/postponed_job/postponed_job.c', line 112

static VALUE
pjob_register_in_c_thread(VALUE self, VALUE obj)
{
    pthread_t thread;
    if (pthread_create(&thread, NULL, pjob_register_in_c_thread_i, (void *)obj)) {
        return Qfalse;
    }

    if (pthread_join(thread, NULL)) {
        return Qfalse;
    }

    return Qtrue;
}

.postponed_job_register_one(obj) ⇒ Object



61
62
63
64
65
66
67
68
# File 'ext/-test-/postponed_job/postponed_job.c', line 61

static VALUE
pjob_register_one(VALUE self, VALUE obj)
{
    rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
    rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
    rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
    return self;
}

.postponed_job_register_one_sameObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'ext/-test-/postponed_job/postponed_job.c', line 86

static VALUE
pjob_register_one_same(VALUE self)
{
    rb_gc_start();
    int r1 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
    int r2 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
    int r3 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
    VALUE ary = rb_ary_new();
    rb_ary_push(ary, INT2FIX(r1));
    rb_ary_push(ary, INT2FIX(r2));
    rb_ary_push(ary, INT2FIX(r3));
    return ary;
}

.q(obj) ⇒ Object



16
17
18
19
20
# File 'ext/-test-/printf/printf.c', line 16

static VALUE
printf_test_q(VALUE self, VALUE obj)
{
    return rb_enc_sprintf(rb_usascii_encoding(), "[% "PRIsVALUE"]", obj);
}

.rb_fatal(msg) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'ext/-test-/fatal/rb_fatal.c', line 3

static VALUE
ruby_fatal(VALUE obj, VALUE msg)
{
    const char *cmsg = NULL;

    (void)obj;

    cmsg = RSTRING_PTR(msg);
    rb_fatal("%s", cmsg);
    return 0; /* never reached */
}

.s(obj) ⇒ Object



4
5
6
7
8
# File 'ext/-test-/printf/printf.c', line 4

static VALUE
printf_test_s(VALUE self, VALUE obj)
{
    return rb_enc_sprintf(rb_usascii_encoding(), "<%"PRIsVALUE">", obj);
}

.sncount(str) ⇒ Object



93
94
95
96
97
98
# File 'ext/-test-/printf/printf.c', line 93

static VALUE
snprintf_count(VALUE self, VALUE str)
{
    int n = ruby_snprintf(NULL, 0, "%s", StringValueCStr(str));
    return INT2FIX(n);
}

.startObject



10
11
12
13
14
15
16
# File 'ext/-test-/bug-3571/bug.c', line 10

static VALUE
bug_start(VALUE self)
{
    VALUE ary = rb_ary_new3(1, Qnil);
    rb_block_call(ary, rb_intern("map"), 0, 0, bug_i, self);
    return ary;
}

.tracepoint_specify_normal_and_internal_eventsObject



79
80
81
82
83
84
85
# File 'ext/-test-/tracepoint/tracepoint.c', line 79

static VALUE
tracepoint_specify_normal_and_internal_events(VALUE self)
{
    VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_EVENT_CALL, 0, 0);
    rb_tracepoint_enable(tpval);
    return Qnil; /* should not be reached */
}

.tracepoint_track_objspace_eventsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'ext/-test-/tracepoint/tracepoint.c', line 56

static VALUE
tracepoint_track_objspace_events(VALUE self)
{
    struct tracepoint_track track = {0, 0, 0, 0, 0,};
    VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ |
                                    RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END_MARK |
                                    RUBY_INTERNAL_EVENT_GC_END_SWEEP,
                                    tracepoint_track_objspace_events_i, &track);
    VALUE result = rb_ary_new();

    rb_tracepoint_enable(tpval);
    rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval);

    rb_ary_push(result, SIZET2NUM(track.newobj_count));
    rb_ary_push(result, SIZET2NUM(track.free_count));
    rb_ary_push(result, SIZET2NUM(track.gc_start_count));
    rb_ary_push(result, SIZET2NUM(track.gc_end_mark_count));
    rb_ary_push(result, SIZET2NUM(track.gc_end_sweep_count));
    rb_ary_cat(result, track.objects, track.objects_count);

    return result;
}

.unp_st_foreach(test) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'ext/-test-/st/foreach/foreach.c', line 136

static VALUE
unp_fe(VALUE self, VALUE test)
{
    st_table *tbl = st_init_numtable();
    struct checker c;

    c.tbl = tbl;
    c.nr = 0;
    c.test = test;

    st_add_direct(tbl, 0, 0);

    if (tbl->bins != NULL) rb_bug("should still be packed");

    st_foreach(tbl, unp_fe_i, (st_data_t)&c);

    if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
        if (c.nr != 1) {
            rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
        }
    }
    else if (c.nr != expect_size) {
        rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)",
                (VALUE)c.nr, (VALUE)expect_size);
    }

    if (tbl->bins == NULL) rb_bug("should be unpacked");

    st_free_table(tbl);

    return Qnil;
}

.unp_st_foreach_check(test) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'ext/-test-/st/foreach/foreach.c', line 75

static VALUE
unp_fec(VALUE self, VALUE test)
{
    st_table *tbl = st_init_numtable();
    struct checker c;

    c.tbl = tbl;
    c.nr = 0;
    c.test = test;

    st_add_direct(tbl, 0, 0);

    if (tbl->bins != NULL) rb_bug("should still be packed");

    st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);

    if (c.test == ID2SYM(rb_intern("delete2"))) {
        if (c.nr != 1) {
            rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
        }
    }
    else if (c.nr != expect_size) {
        rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")",
                (VALUE)c.nr, (VALUE)expect_size);
    }

    if (tbl->bins == NULL) rb_bug("should be unpacked");

    st_free_table(tbl);

    return Qnil;
}

.v(obj) ⇒ Object



10
11
12
13
14
# File 'ext/-test-/printf/printf.c', line 10

static VALUE
printf_test_v(VALUE self, VALUE obj)
{
    return rb_enc_sprintf(rb_usascii_encoding(), "{%+"PRIsVALUE"}", obj);
}