polarbearzoo / maidsafe-dht

Automatically exported from code.google.com/p/maidsafe-dht
0 stars 0 forks source link

Invalid Integer::ConvertToLong() usage? #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Start the Kaddemo on Win32 (binary built with Microsoft Visual Studio)
with the parameters like specified in the Kaddemo wiki page (for example
./kaddemostatic -p 5000 --externalip 192.168.1.115 --externalport 5000
--noconsole --nodeinfopath .)
2. An bad condition in an assert is found and the debugger breaks

What version of the product are you using? On what operating system?

OS: Windows XP
Sofware version: The sourcecode of the revision 389

Please provide any additional information below.

On the random_32bit_integer() and random_32bit_uinteger(), seems that the
usage of the rand_num.AbsoluteValue().ConvertToLong() is not correct (it's
into a (!rand_num.IsConvertableToLong()) condition, and seems that the
AbsoluteValue() integer returned is also not convertable to long.

If I ignore the the assertion, the application seems to work fine. Anyway,
it should be fixed.

Note: A screenshot of the callstack has been attached

Original issue reported on code.google.com by bakt...@gmail.com on 26 Apr 2010 at 5:05

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,
I tried to reproduce the issue, but was unable to get that error.  
Kaddemostatic ran
ok.  To try to find out the problem can you answer the following questions:
1. Did you build the kaddemostatic target in Release or Debug?
2. Did this issue happen every time you ran the kaddemostatic executable?
3. Are you running it from the DOS command prompt?

I ran the unit test repeatedly for the next_transaction_id operation (where it
crashed according to your output) and it passed.  Could you please build the 
target
TESTbase and run that test to let us know the output?  To do this run:
.\TESTbase --gtest_filter=UtilsTest.BEH_BASE_NextTransactionId

Thank you for your help.

To run it repeatedly just add the following option: --gtest_repeat=<number of 
times>

Original comment by jacisner...@googlemail.com on 27 Apr 2010 at 10:41

GoogleCodeExporter commented 9 years ago
Hi,

I built an own project/solution for Microsoft Visual Studio 2005 with the 
kaddemo
sources, I'm not using MinGW/Cmake.  The build is done in Debug.

I've not Cmake installed so I can't build the Testbase now. Anyway, I think 
that I
can reproduce the problem writting a simple program.

I'll do some tests and will send new feedback to you.

Original comment by bakt...@gmail.com on 27 Apr 2010 at 10:58

GoogleCodeExporter commented 9 years ago
Yes, this is a simple program to reproduce the problem:

#include <windows.h>
#include "boost/cstdint.hpp"
namespace base 
{
    extern boost::int32_t random_32bit_integer();
};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 
lpCmdLine, int
nCmdShow)
{
    while ( true )
    {
        base::random_32bit_integer();
    }
    return 0;
}

Original comment by bakt...@gmail.com on 27 Apr 2010 at 11:07

GoogleCodeExporter commented 9 years ago
Hi,
Another question here:
Are you grabbing all the source code and using it to build one executable or 
are you
building all the libraries separately (udt, cryptopp, and maidsafe_dht)? 

I am asking this because for the random number generator we use the one in 
cryptopp
(a third party library) and we build it in the same way they distribute it (they
distribute a MSVC solution file), and it uses different compiler and linking 
flags
than the ones we use to build the maidsafe_dht library (where the function
random_32bit_integer is).

If there is the opportunity for you to build the solution/project using first 
cmake,
and you run the project, that would be of great help or if you can send the 
compiler
and linking flags you are using to build your project.

Original comment by jacisner...@googlemail.com on 27 Apr 2010 at 11:20

GoogleCodeExporter commented 9 years ago
More info about the callstack and watches in the last example

Original comment by bakt...@gmail.com on 27 Apr 2010 at 11:21

Attachments:

GoogleCodeExporter commented 9 years ago
All the sources of the libraries needed (boost modules, cryptopp, etc) are 
contained
in the same Visual Studio solution/project, so, the settings are the same for 
all.

No external libraries are linked, 1 project with all the sources.

Boost sources 1.42.0, Protobuf 2.3.0 and Gtest 1.5.0

The settings of the project:

- Static linking of the standard library (runtime library Multi-threaded debug 
/MTd)
- Character set to multi-byte
- Preprocesor words:
WIN32;_DEBUG;_WINDOWS;__WIN32__;__MSVC__;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_
MEAN;_WIN32_WINNT=0x0501;BOOST_ALL_NO_LIB

The compiler command line:
/Od /I "../Thirdparty/maidsafe/maidsafe/src" /I "../Thirdparty/boost_1_42_0" /I
"../Thirdparty/protobuf-2.3.0/src" /I "../Thirdparty/gtest-1.5.0/include" /D 
"WIN32"
/D "_DEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSVC__" /D 
"_CRT_SECURE_NO_WARNINGS"
/D "WIN32_LEAN_AND_MEAN" /D "_WIN32_WINNT=0x0501" /D "BOOST_ALL_NO_LIB" /D 
"_MBCS"
/Gm /EHsc /RTC1 /MTd /Fo"..\_output\Win32\Debug\Int\\"
/Fd"..\_output\Win32\Debug\Int\vc80.pdb" /W3 /nologo /c /Wp64 /ZI /TP 
/errorReport:prompt

Original comment by bakt...@gmail.com on 27 Apr 2010 at 11:33

GoogleCodeExporter commented 9 years ago
I think that the Absolute() call to the integer should be a Negate() one to 
change
the sign and do it Long compatible?

Because an absolute value of a positive integer number will generate the same 
number
and if the first is not convertable to Long, the second one too.

Original comment by bakt...@gmail.com on 27 Apr 2010 at 11:38

GoogleCodeExporter commented 9 years ago
Hi,
I have made some changes to the generate random number function, it shouldn't 
give
you that problem again.

Original comment by jacisner...@googlemail.com on 27 Apr 2010 at 3:42

GoogleCodeExporter commented 9 years ago

Original comment by dan.schm...@gmail.com on 28 Apr 2010 at 9:09