473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Signal 11 error (core)

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.

Nov 14 '05 #1
8 5389
ro*******@yahoo.com 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?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Holy Banana of this, Sacred Coconut of that, Magic Axolotl of the other."
- Guardian in "Jinxter"
Nov 14 '05 #2
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Well, if pError->pFunctionName is NULL, then no wonder doing anything
at all with pError->pFileName[0] will fail.


How does that follow?
--
"This is a wonderful answer.
It's off-topic, it's incorrect, and it doesn't answer the question."
--Richard Heathfield
Nov 14 '05 #3
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"The truth is out there, man! Way out there!"
- Professor Ashfield
Nov 14 '05 #4
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
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?
--
Ben Pfaff
email: bl*@cs.stanford.edu
web: http://benpfaff.org
Nov 14 '05 #5
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Keep shooting, sooner or later you're bound to hit something."
- Misfire
Nov 14 '05 #6
ro*******@yahoo.com wrote:
This statement gives core dump if( pError->pFileName[0] != '\0' ) can someone suggest why ?


pError->pFileName is probably not useful (anymore?)... It could be a
NULL pointer for instance.

pError itself seems to be valid, since you can dereference it.

Zlo
Nov 14 '05 #7
<11**********************@g14g2000cwa.googlegroups .com>
ro*******@yahoo.com 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".

--
Christopher Benson-Manica
ataru(at)cyberspace.org
Nov 14 '05 #8
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.

Christopher Benson-Manica wrote:
<11**********************@g14g2000cwa.googlegroups .com>
ro*******@yahoo.com 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".

--
Christopher Benson-Manica
ataru(at)cyberspace.org


Nov 14 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ahmed Ossman | last post by:
hi, I want to save the return value from the signal() function, what is the type of the variable. i.e. I want to do the following: <variable type?> ret_sig = signal(......); I need it soo...
1
by: Nish | last post by:
I have the coredump of my process that crashed. Is there any unix utility/program or option in gdb that can be used just to find out as to the process core-dumped because of which signal? I do...
3
by: Martin McCormick | last post by:
A C program contains several signal statements to remove a lock file if the program gets killed: /*Set up interrupt handler to catch ctrl-C so that lock file can be removed.*/...
11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
18
by: Sven | last post by:
Hi, I found a strange behaviour when using the time() function from time.h. Sometimes when it is called, it does not show the correct time in seconds, but an initial value. This time seem to be...
10
by: subramanian | last post by:
Consider the following code: segment violation is deliberately generated to catch the SIGSEGV signal. The handler for this signal, namely SIGSEGV_handler, is called. However after the handler is...
2
by: Achint Mehta | last post by:
Hi, I am running purify on my program (on linux with gcc ver. 3.4.6) I have installed a signal handler (for timer) using sigaction. I am passing a pointer (data) into the sival_ptr which I...
2
by: wnbill | last post by:
hie I am running a batch developed in C on unix and its core-dumping. Upon opening the core with gdb its giving me Program terminated with signal 10, Bus Error. ...
29
by: Leet Jon | last post by:
Hi what's the reason for having the default disposition for SIGSEGV, SIGFPE, SIGBUS etc to be terminating the program, when these signals can just be ignored by the program? Many programs crash...
3
by: Toby Webb | last post by:
Hi, can anyone help please? I am trying to get infromation from my wireless card, such as signal strength and a list of SSIDs that it can see. I have been able to get the signal strength (see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.