m32 flag - segmentation fault

hi,

i am running my code on a 64 bit machine and it works fine. But, when I put m32 flag, after a while, i get segmentation faults...what could the problem be..anything is appreciated..thanks
zizi21Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
>> my question is if you use m32 flag, is there a limitation of the ram that you can use

Since the address space becomes 32 bit the maximum memory a 32 bit process can possible address is 4GB. That said, in reality the amount of user memory is a lot less (usually 1 or 2 GB) since the rest is reserve in the processes memory map for various other reasons (such as for use my the kernel to map devices - this is probably a poor example).
0
 
Infinity08Commented:
>> anything is appreciated..

That's precisely what could be the problem : anything :)

Without seeing the code, and without information about where and under which circumstances the segmentation fault occurs, there's not much to say, except guess.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Time to work on your post-mortem debugging skills (trust me it's a bit of a learning curve but it is one you really will get a great deal of payback from in the future!)...

Have you tried using your debugger to analyse the core file?

You'll need to set ulimit to allow the core to be created if you don't currently get one, setting it to unlimited is the easiest thing.

ulimit -c unlimited]

http://aplawrence.com/Linux/limit_core_files.html
http://linux.die.net/man/1/ulimit

Also, if you've not already done so you'll need to build with symbols (assuming gcc you add the -g flag).

Using GDB is pretty simple (I presume this will be the debugger you use). Open the core file using the debugger.

gdb -c

Then use the backtrace (bt) command to look at the callstack. You can then analyse different stack frames are you see fit.

Some links that looked like they might be useful:
http://linux.bytesex.org/gdb.html
http://www.network-theory.co.uk/articles/gccdebug.html
http://www.freebsd.org/doc/en/books/developers-handbook/debugging.html
http://www.yolinux.com/TUTORIALS/GDB-Commands.html
http://www.delorie.com/gnu/docs/gdb/gdb_8.html
http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html
0
 
zizi21Author Commented:
can i confirm something..if a server has a physical ram 4 gb, when m32 flag, is used, how much of memory can the program used..it is just that previously the machine was 32 bit and with top, you get 3 gb of memory and now, the operating system is reinstalled too 64 bit and the memory with top is 4 gb. my guess is that with m32 flag, you can't use 4 gb of ram but less . this is because i had a program that use 2 gb plus ram and it is fine...only when it is more than 3gb, it gets seg fault...

my question is if you use m32 flag, is there a limitation of the ram that you can use...has it been set somewhere..apologize for not explaining this earlier..
0
All Courses

From novice to tech pro — start learning today.