# Marshalling problem

**URL:** <https://rubytalk.org/t/marshalling-problem/22795>\
**Category:** ruby-talk\
**Created:** [26 November 2005 17:27 UTC](https://rubytalk.org/t/marshalling-problem/22795 "2005-11-26T17:27:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hampton](https://avatars.discourse-cdn.com/v4/letter/h/8edcca/32.png) [@Hampton](https://rubytalk.org/u/Hampton)\
**Post date:** [26 November 2005 17:27 UTC](https://rubytalk.org/t/marshalling-problem/22795/1 "2005-11-26T17:27:27Z")

</div>

Ok, I've already posted this once, but that was 10 hours ago and it  
still hasn't shown up in the group, so i'm reposting it. Apologizes if  
its already shown up for anyone else...

> **···**
>
> -----------
> 
> Alright, so I've been scratching my head about this along with some  
> folks over at #ruby-lang.
> 
> This may be a known problem, but after spending a few minutes  
> searching, I can't find any reference... so I'll document it here.
> 
> If you take some object and marshal it, then try and concat that  
> string, it produces some funny results.
> 
> Here is the test case that I've discovered. I'm thinking this is  
> happening because Marshal sends back some weird characters that are  
> screwing up the string methods. But, I would still classify that as a  
> bug, because when an object returns a string, that should always be a  
> fairly safe string to handle or it should be returning something else.  
> That would be an invalid or misformed string if you can't even use the  
> regular expressions on it.
> 
> Any help would be greatly appreciated.
> 
> #I'm running ruby 1.8.3 on ubuntu  
> #email hcatlin at [gmail.com](http://gmail.com) with any help
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class MyObject  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def initialize  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@name = "testvar"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@array = Array.new  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test = MyObject.new  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dumpresult = Marshal.dump(test)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'Result: ' \<\< dumpresult # Expected: "Result: MYOBJECTDUMP"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'Result=' \<\< Marshal.dump(test) #Expected  
> "Result=MYOBJECTDUMP"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'Result: ' + dumpresult # Expected: "Result: MYOBJECTDUMP"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'Result=' + Marshal.dump(test) #Expected  
> "Result=MYOBJECTDUMP"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "U=" \<\< Marshal.dump(test) # Expected "U=MYOBJECTDUMP"
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#My result is this code below.
> 
> #MyObject:  
> # @array[:  
> #@name"  
> #testvar  
> #MyObject:  
> # @array[:  
> #@name"  
> #testvar  
> #MyObject:  
> # @array[:  
> #@name"  
> #testvar  
> #MyObject:  
> # @array[:  
> #@name"  
> #testvar  
> #MyObject:  
> # @array[:  
> #@name"  
> #testvar

---

<div class="post-metadata">

**Author:** ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)\
**Post date:** [26 November 2005 17:43 UTC](https://rubytalk.org/t/marshalling-problem/22795/2 "2005-11-26T17:43:54Z")

</div>

Hi --

> **···**
>
> On Sun, 27 Nov 2005, Hampton wrote:
> 
> > Ok, I've already posted this once, but that was 10 hours ago and it  
> > still hasn't shown up in the group, so i'm reposting it. Apologizes if  
> > its already shown up for anyone else...
> 
> It has shown up, as have some responses.
> 
> David
> 
> --  
> David A. Black  
> dblack@wobblini.net
