Corrupted data, threadsafe issue or not?

Several times now I’ve seen strings show up as some random integer,
followed by double underscores, followed by what the string should be.
For example ‘test_string’ starts getting transformed into
‘02__test_string’.

I assumed this was because of some non threadsafe code, because in
every instance until now I was able to identify that I had non
threadsafe code. But it makes me wonder because the pattern is
always the same, I assumed I would have ended up with something more
random? Thoughts?

Chris

On Fri, Feb 17, 2012 at 12:06 PM, snacktime [email protected] wrote:

Several times now I’ve seen strings show up as some random integer,
followed by double underscores, followed by what the string should be.
For example ‘test_string’ starts getting transformed into
‘02__test_string’.

I assumed this was because of some non threadsafe code, because in
every instance until now I was able to identify that I had non
threadsafe code. But it makes me wonder because the pattern is
always the same, I assumed I would have ended up with something more
random? Thoughts?

That is a very interesting pattern. Can you think of any data in your
system that might look like that before parsing? Often what we see
with thread-unsafe use of Strings is that the copy-on-write offsets
get screwed up. In those cases, the strings end up containing more or
less data than they’re supposed to, and might contain data that would
have been split/split!/sub/sub!'ed off.

Any other examples? Maybe there’s an obvious pattern aside from the
leading characters.

  • Charlie

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs