Menu

#15 Memory pointers in code is wrong ?!?!?

open
nobody
5
2007-10-22
2007-10-22
Alkirah
No

Hi, I had several problems with matbuild/matprune/matsolve and I think I have figured the problem.

I'm using a 64 bits computer and every time I tried to allocate more than 2gb of ram from ggnfs suite, it failed.

I coded a little proggy and have been able to allocate 16+gb of ram (pagefile was at 16gb and 2gb of real ram).

Anyway, I checked the code and it seem that every malloc call are converted to s32 type ... exemple : (s32 *)lxmalloc(M->numCols*sizeof(s32),1);

The actual lxmalloc, lxcmalloc and lxrealloc code use type size_t type that is, for 32 bits computer, an unsigned int (32 bits) and for x64 cpu, a unsigned __int64 (64 bits).

My guess is that if you try to allocate for exemple, 2.5gb of ram, then ask for another 1gb, return value will be for exemple 0x00012345 for the first call (pointer to 2.5gb of ram) and 0x91234567 for the 2nd one (1gb pointer).

The (s32 *) there will convert that # to signed which will give a negative value, and fail. Is it ok to think that every pointer used in malloc calls should be converted to size_t type since it's the actual value that malloc return?

Is it correct to assume that limitations will be 2gb of usable ram for s32 type, 4gb for u32 and either 4gb for size_t type in 32 bits mode and something like 16tb for size_t type in 64 bits mode?

Any way to fix it fast?

Thanks

Alkirah

Discussion


Log in to post a comment.