Computer Scientist

Saturday, 19 February 2011

Found a Bug in jBittorrentAPI

Actually, this is my first time to find some bugs in other's work.....

In it's TorrentProcessor class, it get the value of file length using a Long.inValue. The precision has been lost a lot, even if it assign it back to a long value. Because of this bug, I got a overflowed number with minus to be inserted into mysql's unsigned big int column!! Obviously, a error message is obtained.

Actually, the reason that I will use this package is that, it can read all of the files that C version's bencode program can not read. Whenever I process the files from Pirate Bay, there would be a segmentation fault sent back to me.

Good work for jBittorrentAPI.....

Change table properties in MySQL::

The most basic one is :


ALTER TABLE person MODIFY person_id SMALLINT UNSIGNED AUTO_INCREMENT;



More detailed can be found here:
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

What if you encounter an error message of "out of heap" in Java?

At this time, you need to:
 (1). check the program and find out any possibility to free the unnecessary resource.
 (2). increase your heap size to achieve more memory allocated to java.

Here I only care about the later one:

java -Xms<initial heap size> -Xmx<maximum heap size>
Defaults are:
java -Xms32m -Xmx128m


                                    

Usage of u_int32_t and size_t

Actually, the usage of these kinds of types confused me for a quite long time, because I really don't know what's the differences between these types and the C's primitive types such as 'int'?

The C's primitive types such as 'long', 'int' are machine dependent, which means different types system probably has different definition of long and int. For example, in old x86 (486), 'int' may be defined by 2 bytes. However, it is 4 bytes in most machines nowadays. In this case, 'u_int32_t' or 'int32_t' is invented to be a system independent type. In fedora, they are defined in file '/usr/include/sys/types.h', 'u_int32_t' is only  possible to be a 'int' type with 32bit (4 bytes). This will provide the program with being portable.