# Imap.fetch results in segfault (Ubuntu Dapper LTS, amd64)

**URL:** <https://www.ruby-forum.com/t/imap-fetch-results-in-segfault-ubuntu-dapper-lts-amd64/134504>\
**Category:** Ruby\
**Created:** [April 11, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/imap-fetch-results-in-segfault-ubuntu-dapper-lts-amd64/134504 "2008-04-11T14:41:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alangano](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@alangano](https://www.ruby-forum.com/u/alangano)\
**Post date:** [April 11, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/imap-fetch-results-in-segfault-ubuntu-dapper-lts-amd64/134504/1 "2008-04-11T14:41:22Z")

</div>

Hi all, I have a Dapper LTS box (amd64) and since I’ve applied this  
update ([USN-596-1: Ruby vulnerabilities | Ubuntu security notices | Ubuntu](http://www.ubuntu.com/usn/usn-596-1)) a mail script I have that  
has worked for a while now pauses for a minute or two while talking to a  
Dovecot IMAP server, then segfaults. Basically the code is this:

…stuff snipped…

loop do  
imap = Net::IMAP.new(server, 993, true)  
imap.login(user, pass)  
imap.select(folder)  
imap.search([“NOT”, “SEEN”]).each do |msg\_id|  
env = imap.fetch(msg\_id, “ENVELOPE”)[0].attr[“ENVELOPE”]

…stuff snipped…

With some debugging output it freezes on the above imap.fetch line for  
the very first email (of usually many). If I drop down to non-TLS  
logins, it does the same thing. For kicks I’ve even tried using a  
version of the /usr/lib/ruby/1.8/net/imap.rb file from a Debian Etch  
box, and still the same thing. strace output doesn’t show anything  
useful to me, though my low level chops are very rusty these days.

The thing is, the fetch appears to at least partially work from the mail  
server’s POV since Dovecot moves the messages from “new” to “cur”, so at  
least part of it is working.

Has anyone else run across this (and better yet, anyone got a  
workaround?)

Thanks.
