memory corruption

Discussion in 'Ruby' started by Roger Pack, Oct 20, 2007.

  1. Roger Pack

    Roger Pack Guest

    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 :)
    -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
    --
    Posted via http://www.ruby-forum.com/.
     
    Roger Pack, Oct 20, 2007
    #1
    1. Advertising

  2. Roger Pack

    Roger Pack Guest

    Roger Pack 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 :)
    > -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
    --
    Posted via http://www.ruby-forum.com/.
     
    Roger Pack, Oct 20, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noa Garnett

    memory corruption while debugging

    Noa Garnett, Aug 24, 2004, in forum: C++
    Replies:
    7
    Views:
    1,812
    Howard
    Aug 25, 2004
  2. Gavin Kreuiter

    Debugger "print" clears memory corruption

    Gavin Kreuiter, Dec 4, 2003, in forum: C Programming
    Replies:
    3
    Views:
    430
    Chris Torek
    Dec 5, 2003
  3. detecting memory corruption

    , Dec 26, 2004, in forum: C Programming
    Replies:
    9
    Views:
    691
    Keith Thompson
    Dec 29, 2004
  4. Sune
    Replies:
    14
    Views:
    890
    Chris Thomasson
    Aug 26, 2007
  5. Sune
    Replies:
    5
    Views:
    452
    Darko
    Jul 13, 2007
Loading...

Share This Page