m32 flag - segmentation fault

Posted on 2010-08-17
Last Modified: 2012-05-10

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
Question by:zizi21
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 53

Expert Comment

ID: 33461690
>> 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.
LVL 40

Expert Comment

ID: 33462634
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]

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:

Author Comment

ID: 33462921
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 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..
LVL 40

Accepted Solution

evilrix earned 500 total points
ID: 33463006
>> 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).

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question