Skip to content

Commit 7c732a8

Browse files
committed
fix: fix SEGV when gc using streaming
1 parent c4d91af commit 7c732a8

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

ext/zstdruby/streaming_compress.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ struct streaming_compress_t {
77
size_t buf_size;
88
};
99

10-
static void
11-
streaming_compress_mark(void *p)
12-
{
13-
struct streaming_compress_t *sc = p;
14-
// rb_gc_mark((VALUE)sc->ctx);
15-
rb_gc_mark(sc->buf);
16-
rb_gc_mark(sc->buf_size);
17-
}
18-
1910
static void
2011
streaming_compress_free(void *p)
2112
{
@@ -35,7 +26,7 @@ streaming_compress_memsize(const void *p)
3526

3627
static const rb_data_type_t streaming_compress_type = {
3728
"streaming_compress",
38-
{ streaming_compress_mark, streaming_compress_free, streaming_compress_memsize, },
29+
{ 0, streaming_compress_free, streaming_compress_memsize, },
3930
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
4031
};
4132

@@ -58,7 +49,7 @@ rb_streaming_compress_initialize(int argc, VALUE *argv, VALUE obj)
5849

5950
int compression_level;
6051
if (NIL_P(compression_level_value)) {
61-
compression_level = 0; // The default. See ZSTD_CLEVEL_DEFAULT in zstd_compress.c
52+
compression_level = ZSTD_CLEVEL_DEFAULT;
6253
} else {
6354
compression_level = NUM2INT(compression_level_value);
6455
}

ext/zstdruby/streaming_decompress.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ struct streaming_decompress_t {
66
size_t buf_size;
77
};
88

9-
static void
10-
streaming_decompress_mark(void *p)
11-
{
12-
struct streaming_decompress_t *sd = p;
13-
// rb_gc_mark((VALUE)sd->ctx);
14-
rb_gc_mark(sd->buf);
15-
rb_gc_mark(sd->buf_size);
16-
}
17-
189
static void
1910
streaming_decompress_free(void *p)
2011
{
@@ -34,7 +25,7 @@ streaming_decompress_memsize(const void *p)
3425

3526
static const rb_data_type_t streaming_decompress_type = {
3627
"streaming_decompress",
37-
{ streaming_decompress_mark, streaming_decompress_free, streaming_decompress_memsize, },
28+
{ 0, streaming_decompress_free, streaming_decompress_memsize, },
3829
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
3930
};
4031

0 commit comments

Comments
 (0)