syck 1.5.1.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +8 -3
- data/ext/syck/rubyext.c +115 -34
- data/ext/syck/yaml2byte.c +1 -3
- data/lib/syck/constants.rb +1 -1
- data/test/test_gc.rb +33 -0
- metadata +5 -4
- data/syck.gemspec +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 840b03fd443a2db94f3eb4a5a0d4b20b6d5292ce4be81f2d2390b5f23aef3f97
|
|
4
|
+
data.tar.gz: cfb7139004022b747e170e46d54c39aaecd7468ea1d3bfe6a5dba5eb18555fc9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07f844fab0e7d8fbcffc9df0b28701ffd29ed1d9fd5f2d433e65fbcfc2ed437d4a340b79591f69eb0bf8cd1d0a4e030a408ccdc80626a681821489944691e02a
|
|
7
|
+
data.tar.gz: c959e3ee17666ac383ee92d7f27ea2e6ddd037a7f7ec3b9b17cc6385ef53f533bc190af1a75efad4b01ae190f50eb9873bf2f29e7058f0c3273885b8c25335c6
|
data/README.rdoc
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
== DESCRIPTION:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
This Gem is a wrapper around {Syck}[https://github.com/indeyets/syck] (a.k.a.
|
|
8
|
+
Scripters' YAML Cobble-Yourself-a-Parser Kit), used for parsing YAML.
|
|
9
|
+
|
|
10
|
+
Syck has been removed from Ruby's stdlib, and this gem is meant to bridge the
|
|
11
|
+
gap for people that haven't updated their YAML yet.
|
|
12
|
+
|
|
13
|
+
If you are starting a new project, you probably should use
|
|
14
|
+
{Psych}[https://github.com/ruby/psych] instead.
|
|
10
15
|
|
|
11
16
|
== FEATURES/PROBLEMS:
|
|
12
17
|
|
data/ext/syck/rubyext.c
CHANGED
|
@@ -93,6 +93,75 @@ struct emitter_xtra {
|
|
|
93
93
|
VALUE port;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
/*
|
|
97
|
+
* The untyped Data API (Data_Wrap_Struct / Data_Get_Struct) has been
|
|
98
|
+
* removed from current Ruby, so every wrapper here uses the TypedData
|
|
99
|
+
* API and the rb_data_type_t definitions below.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
static void syck_node_mark(SyckNode *n);
|
|
103
|
+
static void syck_mark_parser(SyckParser *parser);
|
|
104
|
+
void rb_syck_free_parser(SyckParser *p);
|
|
105
|
+
static void syck_mark_emitter(SyckEmitter *emitter);
|
|
106
|
+
void rb_syck_free_emitter(SyckEmitter *e);
|
|
107
|
+
|
|
108
|
+
static const rb_data_type_t syck_parser_type = {
|
|
109
|
+
"syck/parser",
|
|
110
|
+
{
|
|
111
|
+
(void (*)(void *))syck_mark_parser,
|
|
112
|
+
(void (*)(void *))rb_syck_free_parser,
|
|
113
|
+
0,
|
|
114
|
+
},
|
|
115
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
static const rb_data_type_t syck_node_type = {
|
|
119
|
+
"syck/node",
|
|
120
|
+
{
|
|
121
|
+
(void (*)(void *))syck_node_mark,
|
|
122
|
+
(void (*)(void *))syck_free_node,
|
|
123
|
+
0,
|
|
124
|
+
},
|
|
125
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Nodes owned by the parser must not be freed by the GC. syck_node_type
|
|
130
|
+
* is set as the parent so a single &syck_node_type accepts either kind
|
|
131
|
+
* of node in the accessors below.
|
|
132
|
+
*/
|
|
133
|
+
static const rb_data_type_t syck_node_type_nofree = {
|
|
134
|
+
"syck/node",
|
|
135
|
+
{
|
|
136
|
+
(void (*)(void *))syck_node_mark,
|
|
137
|
+
0,
|
|
138
|
+
0,
|
|
139
|
+
},
|
|
140
|
+
&syck_node_type, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
static const rb_data_type_t syck_emitter_type = {
|
|
144
|
+
"syck/emitter",
|
|
145
|
+
{
|
|
146
|
+
(void (*)(void *))syck_mark_emitter,
|
|
147
|
+
(void (*)(void *))rb_syck_free_emitter,
|
|
148
|
+
0,
|
|
149
|
+
},
|
|
150
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* The taint API (OBJ_TAINT / OBJ_TAINTED) has also been removed from
|
|
155
|
+
* current Ruby, while older supported versions still provide it; shim
|
|
156
|
+
* it to a no-op where Ruby no longer defines it.
|
|
157
|
+
*/
|
|
158
|
+
#ifndef OBJ_TAINT
|
|
159
|
+
#define OBJ_TAINT(obj) ((void)(obj))
|
|
160
|
+
#endif
|
|
161
|
+
#ifndef OBJ_TAINTED
|
|
162
|
+
#define OBJ_TAINTED(obj) (0)
|
|
163
|
+
#endif
|
|
164
|
+
|
|
96
165
|
/*
|
|
97
166
|
* Convert YAML to bytecode
|
|
98
167
|
*/
|
|
@@ -645,6 +714,7 @@ SYMID
|
|
|
645
714
|
rb_syck_load_handler(SyckParser *p, SyckNode *n)
|
|
646
715
|
{
|
|
647
716
|
VALUE obj = Qnil;
|
|
717
|
+
VALUE node_wrapper;
|
|
648
718
|
struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
|
|
649
719
|
VALUE resolver = bonus->resolver;
|
|
650
720
|
if ( NIL_P( resolver ) )
|
|
@@ -655,7 +725,17 @@ rb_syck_load_handler(SyckParser *p, SyckNode *n)
|
|
|
655
725
|
/*
|
|
656
726
|
* Create node,
|
|
657
727
|
*/
|
|
658
|
-
|
|
728
|
+
node_wrapper = TypedData_Wrap_Struct( cNode, &syck_node_type_nofree, n );
|
|
729
|
+
obj = rb_funcall( resolver, s_node_import, 1, node_wrapper );
|
|
730
|
+
|
|
731
|
+
/*
|
|
732
|
+
* syck_hdlr_add_node frees `n` as soon as we return (handler.c:25, when
|
|
733
|
+
* the node has no anchor). Ruby may still keep `node_wrapper` reachable
|
|
734
|
+
* via a conservative GC root on the machine stack, so the next GC would
|
|
735
|
+
* call syck_node_mark() with a dangling SyckNode*. Zero the wrapper's
|
|
736
|
+
* data pointer to make the mark a no-op. See ruby/syck#50.
|
|
737
|
+
*/
|
|
738
|
+
DATA_PTR( node_wrapper ) = NULL;
|
|
659
739
|
|
|
660
740
|
/*
|
|
661
741
|
* ID already set, let's alter the symbol table to accept the new object
|
|
@@ -701,7 +781,7 @@ rb_syck_bad_anchor_handler(SyckParser *p, char *a)
|
|
|
701
781
|
{
|
|
702
782
|
VALUE anchor_name = rb_str_new2( a );
|
|
703
783
|
SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name );
|
|
704
|
-
badanc->type_id = syck_strndup( "tag:ruby.yaml.org,2002:object:YAML::Syck::BadAlias",
|
|
784
|
+
badanc->type_id = syck_strndup( "tag:ruby.yaml.org,2002:object:YAML::Syck::BadAlias", 50 );
|
|
705
785
|
return badanc;
|
|
706
786
|
}
|
|
707
787
|
|
|
@@ -712,7 +792,7 @@ void
|
|
|
712
792
|
syck_set_model(VALUE p, VALUE input, VALUE model)
|
|
713
793
|
{
|
|
714
794
|
SyckParser *parser;
|
|
715
|
-
|
|
795
|
+
TypedData_Get_Struct(p, SyckParser, &syck_parser_type, parser);
|
|
716
796
|
syck_parser_handler( parser, rb_syck_load_handler );
|
|
717
797
|
/* WARN: gonna be obsoleted soon!! */
|
|
718
798
|
if ( model == sym_generic )
|
|
@@ -791,7 +871,7 @@ syck_parser_s_alloc(VALUE class)
|
|
|
791
871
|
parser->bonus = S_ALLOC( struct parser_xtra );
|
|
792
872
|
S_MEMZERO( parser->bonus, struct parser_xtra, 1 );
|
|
793
873
|
|
|
794
|
-
pobj =
|
|
874
|
+
pobj = TypedData_Wrap_Struct( class, &syck_parser_type, parser );
|
|
795
875
|
|
|
796
876
|
syck_parser_set_root_on_error( parser, Qnil );
|
|
797
877
|
|
|
@@ -828,7 +908,7 @@ syck_parser_bufsize_set(VALUE self, VALUE size)
|
|
|
828
908
|
|
|
829
909
|
if ( rb_respond_to( size, s_to_i ) ) {
|
|
830
910
|
int n = NUM2INT(rb_funcall(size, s_to_i, 0));
|
|
831
|
-
|
|
911
|
+
TypedData_Get_Struct(self, SyckParser, &syck_parser_type, parser);
|
|
832
912
|
parser->bufsize = n;
|
|
833
913
|
}
|
|
834
914
|
return self;
|
|
@@ -842,7 +922,7 @@ syck_parser_bufsize_get(VALUE self)
|
|
|
842
922
|
{
|
|
843
923
|
SyckParser *parser;
|
|
844
924
|
|
|
845
|
-
|
|
925
|
+
TypedData_Get_Struct(self, SyckParser, &syck_parser_type, parser);
|
|
846
926
|
return INT2FIX( parser->bufsize );
|
|
847
927
|
}
|
|
848
928
|
|
|
@@ -860,7 +940,7 @@ syck_parser_load(int argc, VALUE *argv, VALUE self)
|
|
|
860
940
|
|
|
861
941
|
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
|
|
862
942
|
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
|
|
863
|
-
|
|
943
|
+
TypedData_Get_Struct(self, SyckParser, &syck_parser_type, parser);
|
|
864
944
|
syck_set_model( self, input, model );
|
|
865
945
|
|
|
866
946
|
bonus = (struct parser_xtra *)parser->bonus;
|
|
@@ -887,7 +967,7 @@ syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
|
|
|
887
967
|
|
|
888
968
|
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
|
|
889
969
|
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
|
|
890
|
-
|
|
970
|
+
TypedData_Get_Struct(self, SyckParser, &syck_parser_type, parser);
|
|
891
971
|
syck_set_model( self, input, model );
|
|
892
972
|
|
|
893
973
|
bonus = (struct parser_xtra *)parser->bonus;
|
|
@@ -973,7 +1053,7 @@ syck_resolver_node_import(VALUE self, VALUE node)
|
|
|
973
1053
|
SyckNode *n;
|
|
974
1054
|
VALUE obj = Qnil;
|
|
975
1055
|
int i = 0;
|
|
976
|
-
|
|
1056
|
+
TypedData_Get_Struct(node, SyckNode, &syck_node_type, n);
|
|
977
1057
|
|
|
978
1058
|
switch (n->kind)
|
|
979
1059
|
{
|
|
@@ -1264,7 +1344,7 @@ syck_defaultresolver_node_import(VALUE self, VALUE node)
|
|
|
1264
1344
|
{
|
|
1265
1345
|
SyckNode *n;
|
|
1266
1346
|
VALUE obj;
|
|
1267
|
-
|
|
1347
|
+
TypedData_Get_Struct( node, SyckNode, &syck_node_type, n );
|
|
1268
1348
|
if ( !yaml_org_handler( n, &obj ) )
|
|
1269
1349
|
{
|
|
1270
1350
|
obj = rb_funcall( self, s_transfer, 2, rb_str_new2( n->type_id ), obj );
|
|
@@ -1281,7 +1361,7 @@ syck_genericresolver_node_import(VALUE self, VALUE node)
|
|
|
1281
1361
|
SyckNode *n;
|
|
1282
1362
|
int i = 0;
|
|
1283
1363
|
VALUE t = Qnil, obj = Qnil, v = Qnil, style = Qnil;
|
|
1284
|
-
|
|
1364
|
+
TypedData_Get_Struct(node, SyckNode, &syck_node_type, n);
|
|
1285
1365
|
|
|
1286
1366
|
if ( n->type_id != NULL )
|
|
1287
1367
|
{
|
|
@@ -1413,6 +1493,7 @@ static void
|
|
|
1413
1493
|
syck_node_mark(SyckNode *n)
|
|
1414
1494
|
{
|
|
1415
1495
|
int i;
|
|
1496
|
+
if ( n == NULL ) return;
|
|
1416
1497
|
rb_gc_mark_maybe( n->id );
|
|
1417
1498
|
switch ( n->kind )
|
|
1418
1499
|
{
|
|
@@ -1448,7 +1529,7 @@ VALUE
|
|
|
1448
1529
|
syck_scalar_alloc(VALUE class)
|
|
1449
1530
|
{
|
|
1450
1531
|
SyckNode *node = syck_alloc_str();
|
|
1451
|
-
VALUE obj =
|
|
1532
|
+
VALUE obj = TypedData_Wrap_Struct( class, &syck_node_type, node );
|
|
1452
1533
|
node->id = obj;
|
|
1453
1534
|
return obj;
|
|
1454
1535
|
}
|
|
@@ -1473,7 +1554,7 @@ VALUE
|
|
|
1473
1554
|
syck_scalar_style_set(VALUE self, VALUE style)
|
|
1474
1555
|
{
|
|
1475
1556
|
SyckNode *node;
|
|
1476
|
-
|
|
1557
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1477
1558
|
|
|
1478
1559
|
if ( NIL_P( style ) )
|
|
1479
1560
|
{
|
|
@@ -1511,7 +1592,7 @@ VALUE
|
|
|
1511
1592
|
syck_scalar_value_set(VALUE self, VALUE val)
|
|
1512
1593
|
{
|
|
1513
1594
|
SyckNode *node;
|
|
1514
|
-
|
|
1595
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1515
1596
|
|
|
1516
1597
|
StringValue( val );
|
|
1517
1598
|
node->data.str->ptr = syck_strndup( RSTRING_PTR(val), RSTRING_LEN(val) );
|
|
@@ -1531,7 +1612,7 @@ syck_seq_alloc(VALUE class)
|
|
|
1531
1612
|
SyckNode *node;
|
|
1532
1613
|
VALUE obj;
|
|
1533
1614
|
node = syck_alloc_seq();
|
|
1534
|
-
obj =
|
|
1615
|
+
obj = TypedData_Wrap_Struct( class, &syck_node_type, node );
|
|
1535
1616
|
node->id = obj;
|
|
1536
1617
|
return obj;
|
|
1537
1618
|
}
|
|
@@ -1543,7 +1624,7 @@ VALUE
|
|
|
1543
1624
|
syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
|
|
1544
1625
|
{
|
|
1545
1626
|
SyckNode *node;
|
|
1546
|
-
|
|
1627
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1547
1628
|
|
|
1548
1629
|
rb_iv_set( self, "@kind", sym_seq );
|
|
1549
1630
|
rb_funcall( self, s_type_id_set, 1, type_id );
|
|
@@ -1559,7 +1640,7 @@ VALUE
|
|
|
1559
1640
|
syck_seq_value_set(VALUE self, VALUE val)
|
|
1560
1641
|
{
|
|
1561
1642
|
SyckNode *node;
|
|
1562
|
-
|
|
1643
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1563
1644
|
|
|
1564
1645
|
val = rb_check_array_type( val );
|
|
1565
1646
|
if ( !NIL_P( val ) ) {
|
|
@@ -1583,7 +1664,7 @@ syck_seq_add_m(VALUE self, VALUE val)
|
|
|
1583
1664
|
{
|
|
1584
1665
|
SyckNode *node;
|
|
1585
1666
|
VALUE emitter = rb_ivar_get( self, s_emitter );
|
|
1586
|
-
|
|
1667
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1587
1668
|
|
|
1588
1669
|
if ( rb_respond_to( emitter, s_node_export ) ) {
|
|
1589
1670
|
val = rb_funcall( emitter, s_node_export, 1, val );
|
|
@@ -1601,7 +1682,7 @@ VALUE
|
|
|
1601
1682
|
syck_seq_style_set(VALUE self, VALUE style)
|
|
1602
1683
|
{
|
|
1603
1684
|
SyckNode *node;
|
|
1604
|
-
|
|
1685
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1605
1686
|
|
|
1606
1687
|
if ( style == sym_inline )
|
|
1607
1688
|
{
|
|
@@ -1625,7 +1706,7 @@ syck_map_alloc(VALUE class)
|
|
|
1625
1706
|
SyckNode *node;
|
|
1626
1707
|
VALUE obj;
|
|
1627
1708
|
node = syck_alloc_map();
|
|
1628
|
-
obj =
|
|
1709
|
+
obj = TypedData_Wrap_Struct( class, &syck_node_type, node );
|
|
1629
1710
|
node->id = obj;
|
|
1630
1711
|
return obj;
|
|
1631
1712
|
}
|
|
@@ -1637,7 +1718,7 @@ VALUE
|
|
|
1637
1718
|
syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
|
|
1638
1719
|
{
|
|
1639
1720
|
SyckNode *node;
|
|
1640
|
-
|
|
1721
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1641
1722
|
|
|
1642
1723
|
if ( !NIL_P( val ) )
|
|
1643
1724
|
{
|
|
@@ -1671,7 +1752,7 @@ VALUE
|
|
|
1671
1752
|
syck_map_value_set(VALUE self, VALUE val)
|
|
1672
1753
|
{
|
|
1673
1754
|
SyckNode *node;
|
|
1674
|
-
|
|
1755
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1675
1756
|
|
|
1676
1757
|
if ( !NIL_P( val ) )
|
|
1677
1758
|
{
|
|
@@ -1704,7 +1785,7 @@ syck_map_add_m(VALUE self, VALUE key, VALUE val)
|
|
|
1704
1785
|
{
|
|
1705
1786
|
SyckNode *node;
|
|
1706
1787
|
VALUE emitter = rb_ivar_get( self, s_emitter );
|
|
1707
|
-
|
|
1788
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1708
1789
|
|
|
1709
1790
|
if ( rb_respond_to( emitter, s_node_export ) ) {
|
|
1710
1791
|
key = rb_funcall( emitter, s_node_export, 1, key );
|
|
@@ -1723,7 +1804,7 @@ VALUE
|
|
|
1723
1804
|
syck_map_style_set(VALUE self, VALUE style)
|
|
1724
1805
|
{
|
|
1725
1806
|
SyckNode *node;
|
|
1726
|
-
|
|
1807
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1727
1808
|
|
|
1728
1809
|
if ( style == sym_inline )
|
|
1729
1810
|
{
|
|
@@ -1756,8 +1837,8 @@ syck_node_init_copy(VALUE copy, VALUE orig)
|
|
|
1756
1837
|
rb_raise( rb_eTypeError, "wrong argument type" );
|
|
1757
1838
|
}
|
|
1758
1839
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1840
|
+
TypedData_Get_Struct( orig, SyckNode, &syck_node_type, orig_n );
|
|
1841
|
+
TypedData_Get_Struct( copy, SyckNode, &syck_node_type, copy_n );
|
|
1761
1842
|
MEMCPY( copy_n, orig_n, SyckNode, 1 );
|
|
1762
1843
|
return copy;
|
|
1763
1844
|
}
|
|
@@ -1770,7 +1851,7 @@ VALUE
|
|
|
1770
1851
|
syck_node_type_id_set(VALUE self, VALUE type_id)
|
|
1771
1852
|
{
|
|
1772
1853
|
SyckNode *node;
|
|
1773
|
-
|
|
1854
|
+
TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );
|
|
1774
1855
|
|
|
1775
1856
|
S_FREE( node->type_id );
|
|
1776
1857
|
|
|
@@ -1792,8 +1873,8 @@ syck_node_transform(VALUE self)
|
|
|
1792
1873
|
VALUE t;
|
|
1793
1874
|
SyckNode *n = NULL;
|
|
1794
1875
|
SyckNode *orig_n;
|
|
1795
|
-
|
|
1796
|
-
t =
|
|
1876
|
+
TypedData_Get_Struct(self, SyckNode, &syck_node_type, orig_n);
|
|
1877
|
+
t = TypedData_Wrap_Struct( cNode, &syck_node_type, 0 );
|
|
1797
1878
|
|
|
1798
1879
|
switch (orig_n->kind)
|
|
1799
1880
|
{
|
|
@@ -1846,7 +1927,7 @@ void
|
|
|
1846
1927
|
rb_syck_emitter_handler(SyckEmitter *e, st_data_t data)
|
|
1847
1928
|
{
|
|
1848
1929
|
SyckNode *n;
|
|
1849
|
-
|
|
1930
|
+
TypedData_Get_Struct((VALUE)data, SyckNode, &syck_node_type, n);
|
|
1850
1931
|
|
|
1851
1932
|
switch (n->kind)
|
|
1852
1933
|
{
|
|
@@ -1907,7 +1988,7 @@ syck_out_mark(VALUE emitter, VALUE node)
|
|
|
1907
1988
|
{
|
|
1908
1989
|
SyckEmitter *emitterPtr;
|
|
1909
1990
|
struct emitter_xtra *bonus;
|
|
1910
|
-
|
|
1991
|
+
TypedData_Get_Struct(emitter, SyckEmitter, &syck_emitter_type, emitterPtr);
|
|
1911
1992
|
bonus = (struct emitter_xtra *)emitterPtr->bonus;
|
|
1912
1993
|
rb_ivar_set( node, s_emitter, emitter );
|
|
1913
1994
|
/* syck_emitter_mark_node( emitterPtr, (st_data_t)node ); */
|
|
@@ -1951,7 +2032,7 @@ syck_emitter_s_alloc(VALUE class)
|
|
|
1951
2032
|
emitter->bonus = S_ALLOC( struct emitter_xtra );
|
|
1952
2033
|
S_MEMZERO( emitter->bonus, struct emitter_xtra, 1 );
|
|
1953
2034
|
|
|
1954
|
-
pobj =
|
|
2035
|
+
pobj = TypedData_Wrap_Struct( class, &syck_emitter_type, emitter );
|
|
1955
2036
|
syck_emitter_handler( emitter, rb_syck_emitter_handler );
|
|
1956
2037
|
syck_output_handler( emitter, rb_syck_output_handler );
|
|
1957
2038
|
|
|
@@ -1978,7 +2059,7 @@ syck_emitter_reset(int argc, VALUE *argv, VALUE self)
|
|
|
1978
2059
|
SyckEmitter *emitter;
|
|
1979
2060
|
struct emitter_xtra *bonus;
|
|
1980
2061
|
|
|
1981
|
-
|
|
2062
|
+
TypedData_Get_Struct(self, SyckEmitter, &syck_emitter_type, emitter);
|
|
1982
2063
|
bonus = (struct emitter_xtra *)emitter->bonus;
|
|
1983
2064
|
|
|
1984
2065
|
bonus->oid = Qnil;
|
|
@@ -2024,7 +2105,7 @@ syck_emitter_emit(int argc, VALUE *argv, VALUE self)
|
|
|
2024
2105
|
rb_ivar_set(self, s_level, INT2FIX(level));
|
|
2025
2106
|
|
|
2026
2107
|
rb_scan_args(argc, argv, "1&", &oid, &proc);
|
|
2027
|
-
|
|
2108
|
+
TypedData_Get_Struct(self, SyckEmitter, &syck_emitter_type, emitter);
|
|
2028
2109
|
bonus = (struct emitter_xtra *)emitter->bonus;
|
|
2029
2110
|
|
|
2030
2111
|
/* Calculate anchors, normalize nodes, build a simpler symbol table */
|
data/ext/syck/yaml2byte.c
CHANGED
|
@@ -115,9 +115,7 @@ void bytestring_extend(bytestring_t *str, bytestring_t *ext)
|
|
|
115
115
|
|
|
116
116
|
/* convert SyckNode into yamlbyte_buffer_t objects */
|
|
117
117
|
SYMID
|
|
118
|
-
syck_yaml2byte_handler(p, n)
|
|
119
|
-
SyckParser *p;
|
|
120
|
-
SyckNode *n;
|
|
118
|
+
syck_yaml2byte_handler(SyckParser *p, SyckNode *n)
|
|
121
119
|
{
|
|
122
120
|
SYMID oid;
|
|
123
121
|
long i;
|
data/lib/syck/constants.rb
CHANGED
data/test/test_gc.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative "helper"
|
|
2
|
+
|
|
3
|
+
# Regression test for ruby/syck#50 - heap-use-after-free in syck_node_mark
|
|
4
|
+
# when GC runs between syck_hdlr_add_node freeing a SyckNode and the Ruby
|
|
5
|
+
# Data wrapper that pointed at it being collected.
|
|
6
|
+
#
|
|
7
|
+
# GC.stress forces a full GC on every allocation, so if the fix regresses
|
|
8
|
+
# this test will segfault (or fire under ASAN/valgrind).
|
|
9
|
+
class TestGC < Test::Unit::TestCase
|
|
10
|
+
def test_load_under_gc_stress
|
|
11
|
+
yaml = ({}.tap { |h| 50.times { |i| h["k#{i}"] = "v" * 64 } }).to_yaml
|
|
12
|
+
|
|
13
|
+
GC.stress = true
|
|
14
|
+
begin
|
|
15
|
+
3.times { Syck.load(yaml) }
|
|
16
|
+
ensure
|
|
17
|
+
GC.stress = false
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_load_many_documents_under_gc_stress
|
|
22
|
+
docs = Array.new(5) do |i|
|
|
23
|
+
({}.tap { |h| 30.times { |k| h["k_#{i}_#{k}"] = "v_#{i}_#{k}" } }).to_yaml
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
GC.stress = true
|
|
27
|
+
begin
|
|
28
|
+
docs.each { |d| Syck.load(d) }
|
|
29
|
+
ensure
|
|
30
|
+
GC.stress = false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: syck
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroshi SHIBATA
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
- Mat Brown
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -100,12 +100,12 @@ files:
|
|
|
100
100
|
- lib/syck/yamlnode.rb
|
|
101
101
|
- lib/syck/ypath.rb
|
|
102
102
|
- lib/yaml/syck.rb
|
|
103
|
-
- syck.gemspec
|
|
104
103
|
- test/helper.rb
|
|
105
104
|
- test/test_array.rb
|
|
106
105
|
- test/test_boolean.rb
|
|
107
106
|
- test/test_class.rb
|
|
108
107
|
- test/test_exception.rb
|
|
108
|
+
- test/test_gc.rb
|
|
109
109
|
- test/test_hash.rb
|
|
110
110
|
- test/test_null.rb
|
|
111
111
|
- test/test_omap.rb
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
137
|
version: 0.9.5
|
|
138
138
|
requirements: []
|
|
139
|
-
rubygems_version: 3.6.
|
|
139
|
+
rubygems_version: 3.6.9
|
|
140
140
|
specification_version: 4
|
|
141
141
|
summary: A gemified version of Syck from Ruby's stdlib
|
|
142
142
|
test_files:
|
|
@@ -145,6 +145,7 @@ test_files:
|
|
|
145
145
|
- test/test_boolean.rb
|
|
146
146
|
- test/test_class.rb
|
|
147
147
|
- test/test_exception.rb
|
|
148
|
+
- test/test_gc.rb
|
|
148
149
|
- test/test_hash.rb
|
|
149
150
|
- test/test_null.rb
|
|
150
151
|
- test/test_omap.rb
|
data/syck.gemspec
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |s|
|
|
4
|
-
s.name = "syck"
|
|
5
|
-
s.version = "1.5.1.1"
|
|
6
|
-
|
|
7
|
-
s.summary = "A gemified version of Syck from Ruby's stdlib"
|
|
8
|
-
s.description = "A gemified version of Syck from Ruby's stdlib. Syck has been removed from\nRuby's stdlib, and this gem is meant to bridge the gap for people that haven't\nupdated their YAML yet."
|
|
9
|
-
s.authors = ["Hiroshi SHIBATA", "Aaron Patterson", "Mat Brown"]
|
|
10
|
-
s.email = ["hsbt@ruby-lang.org", "aaron@tenderlovemaking.com"]
|
|
11
|
-
s.homepage = "https://github.com/ruby/syck"
|
|
12
|
-
s.license = "MIT"
|
|
13
|
-
s.require_paths = ["lib"]
|
|
14
|
-
s.extensions = ["ext/syck/extconf.rb"]
|
|
15
|
-
s.files = Dir["[A-Z]*", "ext/**/*", "lib/**/*.rb", "test/**/*.rb"] - %w[Gemfile.lock ext/syck/gram.y]
|
|
16
|
-
s.extra_rdoc_files = ["README.rdoc"]
|
|
17
|
-
s.test_files = Dir["test/**/*.rb"]
|
|
18
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
|
19
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
|
|
20
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0.9.5")
|
|
21
|
-
s.rubygems_version = "2.0.3"
|
|
22
|
-
|
|
23
|
-
s.add_development_dependency(%q<bundler>)
|
|
24
|
-
s.add_development_dependency(%q<test-unit>)
|
|
25
|
-
s.add_development_dependency(%q<rake-compiler>)
|
|
26
|
-
end
|