Memory Fault

Hello All,

I am porting some C code developed in Windows to QNX. The code works fine in
the Windows environment however in QNX I get a memory fault. I believe I
have pinpointed the error to a free statement, but I could be wrong. Is
there any thing I should know about memory allocations that might be
different from the way memory is allocated, if so, what would be a good
resource to check out.

Thanks in advance,

Elmer Thomas
Computer Engineer
University of California, Riverside
ethomas@cs.ucr.edu

Is this Windows or Windows/NT ?

There is a very fundamental difference between Windows and QNX, and that
is that QNX is a tight VM (very few holes); windows OTOH operates with
such a loose VM that it can essentially be categorized as having no VM.
Windows NT also, has it’s share of holes, but W2K should run a pretty
tight ship. Have you tried your code on W2K ? There is a good chance
that it will fail there also.

If indeed you are getting a fault in free() it is almost certainly
indicative of heap corruption. You can download the dmalloc library,
which is a pretty nifty heap checker tool from www.dmalloc.org (IIRC -
can’t check the URL right now). It compiles out-of-the-box for QNX4.
Good luck.

-----Original Message-----
From: Elmer Thomas [mailto:ethomas@cs.ucr.edu]
Posted At: Monday, June 25, 2001 10:23 AM
Posted To: devtools
Conversation: Memory Fault
Subject: Memory Fault


Hello All,

I am porting some C code developed in Windows to QNX. The code works
fine in
the Windows environment however in QNX I get a memory fault. I believe
I
have pinpointed the error to a free statement, but I could be wrong. Is
there any thing I should know about memory allocations that might be
different from the way memory is allocated, if so, what would be a good
resource to check out.

Thanks in advance,

Elmer Thomas
Computer Engineer
University of California, Riverside
ethomas@cs.ucr.edu

I ran into a problem while I was porting software from windows into QNX.

The windows software was a series of device API function calls and they used
a LOT of global variables.

My QNX application had mulitple processes and I called the device API’s from
a couple of different processes.

In QNX each process has it’s own address space, so once I "fork"ed my main
process the “Global” variables were no longer “Global” they were only global
within that process. So in process A I would open the device and in process
B I would try to close the device. It would cause a segmentation violation
or it would tell me that the device wasn’t open.

To fix the problem I created a Shared Memory Area and stored any necessary
globals there and made any non-essential globals into API function
paramenters.

“Elmer Thomas” <ethomas@cs.ucr.edu> wrote in message
news:9h7s2m$ok6$1@inn.qnx.com

Hello All,

I am porting some C code developed in Windows to QNX. The code works fine
in
the Windows environment however in QNX I get a memory fault. I believe I
have pinpointed the error to a free statement, but I could be wrong. Is
there any thing I should know about memory allocations that might be
different from the way memory is allocated, if so, what would be a good
resource to check out.

Thanks in advance,

Elmer Thomas
Computer Engineer
University of California, Riverside
ethomas@cs.ucr.edu