frostalf / libtorrent

Automatically exported from code.google.com/p/libtorrent
0 stars 0 forks source link

r9627 crashes when preallocation is enabled #577

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Tested with r9664 on Windows XP. Also users from Windows 7 and linux(libtorrent 
0.16.14) have reported the same issue.

When preallocation is enabled the app crashes on first write.

I can't get any useful info from WinDbg (or I don't know how to operate it 
right)

One user has included backtrace from linux:

stack trace:
/usr/lib64/libtorrent-rasterbar.so.7 : 
libtorrent::default_storage::readwritev(iovec const*, int, int, int, 
libtorrent::default_storage::fileop const&)+0x3f7 [0x7f4bad9f5727]
/usr/lib64/libtorrent-rasterbar.so.7 : 
libtorrent::default_storage::writev(iovec const*, int, int, int, int)+0x79 
[0x7f4bad9f6029]
/usr/lib64/libtorrent-rasterbar.so.7 : 
libtorrent::piece_manager::write_impl(iovec*, int, int, int)+0x103 
[0x7f4bad9fd773]
/usr/lib64/libtorrent-rasterbar.so.7 : 
libtorrent::disk_io_thread::flush_range(libtorrent::disk_io_thread::cached_piece
_entry&, int, int, boost::asio::detail::scoped_lock<boost::asio::detail
/usr/lib64/libtorrent-rasterbar.so.7 : 
libtorrent::disk_io_thread::thread_fun()+0x155b [0x7f4bad8b1ebb]
/usr/lib64/libtorrent-rasterbar.so.7 : 
boost_asio_detail_posix_thread_function()+0x34 [0x7f4bad875c14]
/lib64/libpthread.so.0 : ()+0x85b5 [0x7f4bad2495b5]
/lib64/libc.so.6 : clone()+0x6d [0x7f4babd941ad]

Removing r9627 with "svn merge -c -9627 ." I don't get a crash anymore nor does 
one of the users in the original qbt issue.

More info at: https://github.com/qbittorrent/qBittorrent/issues/1386

Original issue reported on code.google.com by hammered...@gmail.com on 6 Feb 2014 at 10:25

GoogleCodeExporter commented 9 years ago
I believe this fixes the crash:

Index: src/storage.cpp
===================================================================
--- src/storage.cpp     (revision 9683)
+++ src/storage.cpp     (working copy)
@@ -1223,7 +1223,7 @@
                        // if the file has priority 0, don't allocate it
                        int file_index = files().file_index(*file_iter);
                        if (m_allocate_files && (op.mode & file::rw_mask) != file::read_only
-                               && (m_file_priority.size() < file_index || 
m_file_priority[file_index] > 0))
+                               && (m_file_priority.size() <= file_index || 
m_file_priority[file_index] > 0))
                        {
                                TORRENT_ASSERT(m_file_created.size() == files().num_files());
                                if (m_file_created[file_index] == false)

Original comment by arvid.no...@gmail.com on 7 Feb 2014 at 6:37

GoogleCodeExporter commented 9 years ago
thanks for the report. fixed in RC_0_16. Please let me know if you still 
experience a crash.

Original comment by arvid.no...@gmail.com on 7 Feb 2014 at 8:54

GoogleCodeExporter commented 9 years ago
Yes it works. Thanks.

Original comment by hammered...@gmail.com on 7 Feb 2014 at 11:33