Memory corruption

Wondering if anybody’s had memory corruption with mingw before. This
works fine for VC and for Linux (it’s just some base rails code).
Anyway somehow or other it gets corrupted and inserts random bytes into
a “Buffer”

like \000 and EOF and random junk. It occurs in thsi snippet of erb.rb
code. Any help appreciated :slight_smile:
-Roger

 scanner.scan do |token|
   if scanner.stag.nil?
     pp "token", token
   pp "out", out
     case token

     when PercentLine
       out.push("#{@put_cmd} #{content.dump}") if content.size > 0
       content = ''
       out.push(token.to_s)
       out.cr
     when :cr
       out.cr
     when '<%', '<%=', '<%#'
       scanner.stag = token
       out.push("#{@put_cmd} #{content.dump}") if content.size > 0
       content = ''
     when "\n"
       content << "\n"
       out.push("#{@put_cmd} #{content.dump}")
       out.cr
       content = ''
     when '<%%'
       content << '<%'
     else
       content << token
     end
   else
     case token
     when '%>'
       case scanner.stag
       when '<%'
         if content[-1] == ?\n
           content.chop!
           out.push(content)
           out.cr
         else
           out.push(content)
         end
       when '<%='
         out.push("#{@insert_cmd}((#{content}).to_s)")
       when '<%#'
         # out.push("# #{content.dump}")
       end
       scanner.stag = nil
       content = ''
     when '%%>'
       content << '%>'
     else
       content << token
     end
   end
 end
 out.push("#{@put_cmd} #{content.dump}") if content.size > 0
 pp "out is", out
 out.close
 out.script

Roger P. wrote:

Wondering if anybody’s had memory corruption with mingw before. This
works fine for VC and for Linux (it’s just some base rails code).
Anyway somehow or other it gets corrupted and inserts random bytes into
a “Buffer”

like \000 and EOF and random junk. It occurs in thsi snippet of erb.rb
code. Any help appreciated :slight_smile:
-Roger

       out.push("#{@put_cmd} #{content.dump}") if content.size > 0

This line turned out to be the culprit. Rmagick on mingw still had a
‘legacy’ bug of rewriting String.dump poorly. Rewrote it and rails
works now, in case anyone wonders.
Thanks!
-Roger

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