Opened 10 years ago
Closed 9 years ago
#2738 closed bug (Fixed)
Illegal argument to libtorrent set_max_connections
Reported by: | Bro | Owned by: | Bro |
---|---|---|---|
Priority: | minor | Milestone: | 1.3.13 |
Component: | libtorrent | Version: | develop |
Keywords: | Cc: | Bro |
Description
When testing a debug build of libtorrent I noticed that it fails on an assert statement that tests for valid input to the torrent_handle.set_max_connections
Libtorrent docs says that
This must be at least 2. The default is unlimited number of connections. If -1 is given to the function, it means unlimited.
During startup, deluge passes 0 to this function for some of the torrents. Oddly enough, lt actually treats 0 and -1 equally:
if (limit <= 0) limit = (1<<24)-1;
I'm not sure what really happens when passing in 1.
There are two different asserts:
set_max_connections (torrent_handle.cpp)
TORRENT_ASSERT_PRECOND(max_connections >= 2 || max_connections == -1);
set_max_connections (torrent.cpp)
TORRENT_ASSERT(limit >= -1);
This could indicate that it's only a bug in the lt doc and the assert in torrent_handle.cpp, i.e., 1 and 0 are also valid values.
Change History (6)
comment:1 by , 10 years ago
comment:2 by , 9 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 9 years ago
Component: | Core → libtorrent |
---|---|
Milestone: | Future → 2.0 |
comment:4 by , 9 years ago
I opened a libtorrent issue github but we didn't conclude on anything (it seems). Also I believe we may disagree about how asserts should be used.
I guess the simplest solution to fix this in deluge is to ensure that the values passed to libtorrent calls are valid. In the case of set_max_connections, 0 and 1 are not valid input values (according to docs) and gives an assert error when compiled in debug mode. When not in debug mode, 0 is actually treated as -1 and means unlimited. I don't know what happens when passing in 1, but presumably it should be avoided since docs says it must be minimum 2.
comment:6 by , 9 years ago
Milestone: | 2.0 → 1.3.13 |
---|---|
Resolution: | → Fixed |
Status: | assigned → closed |
Fixed in develop [27bf05f2fe7b26988] and 1.3 [a58ce30e7b8d56d789]
I didn't realise you meant a debug libtorrent build, could you clarify it with Arvid and then we can fix it in Deluge.