Signal 11 error (core)

R

rohityogi

This statement gives core dump

if( pError->pFileName[0] != '\0' )

can someone suggest why ?

This statement was failing in all our unix environments so we changed
it to:

if( !(pError->pFunctionName == NULL))

It worked for some environments then now again it failed in 1
environment.

Any idea ?

All memory allocation have been done.
 
J

Joona I Palaste

(e-mail address removed) scribbled the following:
This statement gives core dump
if( pError->pFileName[0] != '\0' )
can someone suggest why ?
This statement was failing in all our unix environments so we changed
it to:
if( !(pError->pFunctionName == NULL))

Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail. Have you read a C textbook?
It worked for some environments then now again it failed in 1
environment.

Any idea ?

Well, it could be that pError itself is NULL.
All memory allocation have been done.

And have you checked if it has succeeded?
 
B

Ben Pfaff

Joona I Palaste said:
Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail.

How does that follow?
 
J

Joona I Palaste

Ben Pfaff said:
Joona I Palaste said:
Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail.
How does that follow?

Well, if you're going to be pedantic, it doesn't. It causes UB, which
does not necessarily mean failure. But I figured that on the OP's
system, it would fail.
 
B

Ben Pfaff

Joona I Palaste said:
Ben Pfaff said:
Joona I Palaste said:
Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail.
How does that follow?

Well, if you're going to be pedantic, it doesn't. It causes UB, which
does not necessarily mean failure. But I figured that on the OP's
system, it would fail.

How does knowing that
pError->pFunctionName is a null pointer tell you that
pError->pFilename is not a valid pointer?
 
J

Joona I Palaste

Ben Pfaff said:
Joona I Palaste said:
Ben Pfaff said:
Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail.
How does that follow?

Well, if you're going to be pedantic, it doesn't. It causes UB, which
does not necessarily mean failure. But I figured that on the OP's
system, it would fail.
How does knowing that
pError->pFunctionName is a null pointer tell you that
pError->pFilename is not a valid pointer?

Argh. Now I feel stupid. I need either to get new glasses or to stop
reading comp.lang.c late in the evening.
 
C

Christopher Benson-Manica

<[email protected]>
(e-mail address removed) wrote:

I am not a guru, so add grains of salt as needed.
if( pError->pFileName[0] != '\0' )
can someone suggest why ?

1. pError->pFileName is a null pointer.
2. You free()'d pError or pError->pFileName.
if( !(pError->pFunctionName == NULL))

What's wrong with

if( pError->pFunctionName != NULL )

?
It worked for some environments then now again it failed in 1
environment.

Any idea ?

Sounds like 2) above - using a pointer after you've free()'d it causes
undefined behavior, one common manifestation of which is "works on
platform X but not on platform Y".
 
R

rohityogi

I found the problem pError->pFileName & pError->pFunctionName was not
alocated memory. Actually it is a huge code and pError is passed from
multiple places and programs so I was finding difficult to back track.
I reached a point where these two vars were not allocated memory and
now we are checking first char of string to hold '\0' which is wrong.
<[email protected]>
(e-mail address removed) wrote:

I am not a guru, so add grains of salt as needed.
if( pError->pFileName[0] != '\0' )
can someone suggest why ?

1. pError->pFileName is a null pointer.
2. You free()'d pError or pError->pFileName.
if( !(pError->pFunctionName == NULL))

What's wrong with

if( pError->pFunctionName != NULL )

?
It worked for some environments then now again it failed in 1
environment.

Any idea ?

Sounds like 2) above - using a pointer after you've free()'d it causes
undefined behavior, one common manifestation of which is "works on
platform X but not on platform Y".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,422
Latest member
LatashiaZc

Latest Threads

Top