# String.c の str_new4 の assert に引っかかってしまいます

sasashin\$B\$H?=\$7\$^\$9!#=iEj9F\$G\$9!#\$h\$m\$7\$/\$*4j\$\$\$7\$^\$9!#(B

\$B?t==;~4V2s\$7\$C\$Q\$J\$7\$K\$9\$k%9%/%j%W%H\$r(B 1.9.2-p290
\$B\$GF0\$+\$7\$F\$\$\$k\$N\$G\$9\$,!"(B
\$B\$^\$l\$K0J2<\$N%(%i!<\$,=P\$F0[>o=N;\$7\$F\$7\$^\$&\$3\$H\$,\$"\$j\$^\$9!#(B
\$B2s\$7\$J\$
\$9\$H%(%i!<\$,=P\$J\$/\$J\$k\$N\$G!":F8=>r7o\$ODO\$a\$F\$\$\$^\$;\$s!#(B

## ruby: string.c:663: str_new4: Assertion `(!!((!(((VALUE)((shared)) & RUBY_IMMEDIATE_MASK) || !(((VALUE)((shared)) & ~((VALUE)RUBY_Qnil)) != 0)) && (int)(((struct RBasic*)((shared)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((struct RBasic*)((shared)))->flags&((((VALUE)1)<<11))):0))’ failed.

string.c \$B\$NEv3:2U=j\$r8+\$F\$_\$k\$H!"(Bstr_new4 \$B\$NCf\$N(B assert \$B\$K(B
\$B0z\$C\$+\$+\$C\$F\$\$\$k\$3\$H\$,\$o\$+\$j\$^\$7\$?!#(B

static VALUE
str_new4(VALUE klass, VALUE str)
{
VALUE str2;

``````str2 = str_alloc(klass);
STR_SET_NOEMBED(str2);
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
if (STR_SHARED_P(str)) {
VALUE shared = RSTRING(str)->as.heap.aux.shared;
assert(OBJ_FROZEN(shared));                            <===
``````

## \$B\$3\$3\$,(B663\$B9TL(B FL_SET(str2, ELTS_SHARED); RSTRING(str2)->as.heap.aux.shared = shared; } else { FL_SET(str, ELTS_SHARED); RSTRING(str)->as.heap.aux.shared = str2; } rb_enc_cr_str_exact_copy(str2, str); OBJ_INFECT(str2, str); return str2; }

\$B\$3\$N(B assert \$B\$O!“0J2<\$N%3%%C%H\$G(B string.c
\$B\$KDI2C\$5\$l\$F\$\$\$^\$7\$?!#(B
[email protected]\$7!"\$3\$N%3%
%C%H\$G(B str_new4 \$B\$,JQ99\$5\$l\$?\$N\$O(B assert
[email protected]\$1\$G!”(B
\$B=hM}\$=\$N\$b\$N\$OJQ99\$5\$l\$F\$\$\$J\$\$\$h\$&\$G\$9!#(B
\$B\$^\$?!"(B1.9.3-p194 \$B\$G\$b(B str_new4 \$B\$O>e5-\$N%3!<%I\$N\$^\$^\$G\$9!#(B

commit 7915aed8752566f355ab4b19216da96836fd9589
Author: nobu [email protected]
Date: Thu Jun 11 17:41:27 2009 +0000

``````* string.c (str_replace_shared): shared target must be frozen.
[ruby-core:23727]``````

(2012/09/19 17:20), Sasaki Shingo wrote:

sasashin\$B\$H?=\$7\$^\$9!#=iEj9F\$G\$9!#\$h\$m\$7\$/\$*4j\$\$\$7\$^\$9!#(B

\$B?t==;~4V2s\$7\$C\$Q\$J\$7\$K\$9\$k%9%/%j%W%H\$r(B 1.9.2-p290
\$B\$GF0\$+\$7\$F\$\$\$k\$N\$G\$9\$,!"(B
\$B\$^\$l\$K0J2<\$N%(%i!<\$,=P\$F0[>o=N;\$7\$F\$7\$^\$&\$3\$H\$,\$"\$j\$^\$9!#(B
\$B2s\$7\$J\$
\$9\$H%(%i!<\$,=P\$J\$/\$J\$k\$N\$G!":F8=>r7o\$ODO\$a\$F\$\$\$^\$;\$s!#(B
\$B!JN,!K(B

\$B\$3\$N=hM}\$r8+\$k\$H(B assert [email protected]\$7\$\$\$h\$&\$K8+\$(\$^\$9!%(B
freeze \$B\$r30\$7\$F\$7\$^\$&0-\$\$;R\$,\$\$\$k\$N\$+\$b\$7\$l\$^\$;\$s!%(B

Q. \$B3HD%%i%\$%V%i%j\$OMxMQ\$7\$F\$\$\$^\$9\$G\$7\$g\$&\$+!%(B
Q. \$B:F8=%W%m%0%i%`\$rD:\$/\$3\$H\$O\$G\$-\$^\$;\$s\$G\$7\$g\$&\$+!%(B

Q. \$B3HD%%i%\$%V%i%j\$OMxMQ\$7\$F\$\$\$^\$9\$G\$7\$g\$&\$+!%(B

\$B!!(Bnokogiri (1.5.0)
\$B!!(Bsqlite3 (1.3.5)
\$B!!(Btokyocabinet (1.29)

\$B\$r;H\$C\$F\$\$\$^\$9!#(B

\$BG0\$N\$?\$a(B require \$B\$7\$F\$\$\$k\$N\$rA4It=q\$/\$H!"(B
cgi, csv, date, httpclient, net/http, nkf, nokogiri, optparse, pp,
rubygems, set, sqlite3, thread, tokyocabinet, uri
\$B\$G\$9!#(B

Q. \$B:F8=%W%m%0%i%`\$rD:\$/\$3\$H\$O\$G\$-\$^\$;\$s\$G\$7\$g\$&\$+!%(B

\$B\$9\$\$^\$;\$s!"\$3\$C\$A\$O\$9\$0\$K\$OFq\$7\$\$46\$8\$G\$9!#(B
[email protected]%9%/%j%W%H(B \$B!
(B
\$B?t==(BGB\$B\$N%F%-%9%H%U%!%\$%k(B \$B!_(B \$B?t==;~4V\$NO"B3F0:n(B
\$B\$G\$h\$&\$d\$/(B3\$B2sH/@8\$9\$k\$/\$i\$\$\$NIQEY\$J\$N\$G!"(B
\$B\$I\$N\$"\$?\$j\$N%3!<%I\$,%/%5%\$\$N\$+\$b9J\$j9~\$a\$F\$*\$j\$^\$;\$s!D!#(B