public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32166] New: Condition check for const char string fails
@ 2007-05-31 15:51 kmanjunat at gmail dot com
2007-05-31 16:35 ` [Bug c/32166] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: kmanjunat at gmail dot com @ 2007-05-31 15:51 UTC (permalink / raw)
To: gcc-bugs
Ive been working on a c program that does the error
condition check in the beginning as follows,
char *fun(str)
const char *str;
{
if (str == NULL) <-- Error check, taking the const char variable directly.
printf("Null string \n");
..............
}
But the code fails to perform the error checking
when a NULL string is passed and gives a segmentation
fault.
Did anyone face a similar problem. Please provide me some
information regarding this problem.
--
Summary: Condition check for const char string fails
Product: gcc
Version: 3.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kmanjunat at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
@ 2007-05-31 16:35 ` pinskia at gcc dot gnu dot org
2007-06-01 7:52 ` kmanjunat at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-31 16:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-05-31 16:35 -------
without a testcase it is hard to help you.
The char pointer might just point to some random memory which you might get a
crash.
Either hand us a testcase or use a debuger to debug your code more.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
2007-05-31 16:35 ` [Bug c/32166] " pinskia at gcc dot gnu dot org
@ 2007-06-01 7:52 ` kmanjunat at gmail dot com
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kmanjunat at gmail dot com @ 2007-06-01 7:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from kmanjunat at gmail dot com 2007-06-01 07:52 -------
The test case is being called from a shared library with the
eabi support using dlopen.
The following is the test case
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main()
{
char *a=NULL;
char *b="abcd";
char *ret=NULL;
ret=fun(a);
printf("%s \n", ret);
ret=fun(b);
printf("%s \n", ret);
return 0;
}
Definition of fun() is in the shared library
as follows :
char *fun(str)
const char *str;
{
int len;
char *copy;
if (str == NULL)
{
printf("Error, Null string passed \n");
return(NULL);
}
len = strlen(str) + 1;
if(!(copy = malloc(len)))
return(NULL);
memcpy(copy, str, len);
return(copy);
}
The control is not getting into the condition check
"if(str == NULL)". Ive verified this with the objdump of the
testcase, which does not show the "cmp instruction"
for the if (str == NULL) condition checking.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
2007-05-31 16:35 ` [Bug c/32166] " pinskia at gcc dot gnu dot org
2007-06-01 7:52 ` kmanjunat at gmail dot com
@ 2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-01 11:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2007-06-01 11:19 -------
*** Bug 32174 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
` (2 preceding siblings ...)
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
@ 2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
2007-06-10 2:10 ` pinskia at gcc dot gnu dot org
2007-12-02 21:32 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-01 11:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2007-06-01 11:19 -------
*** Bug 32175 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
` (3 preceding siblings ...)
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
@ 2007-06-10 2:10 ` pinskia at gcc dot gnu dot org
2007-12-02 21:32 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-10 2:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2007-06-10 02:10 -------
What target are you targetting?
Also I can't reproduce this on the trunk.
Can you provide the output of "gcc -v" ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/32166] Condition check for const char string fails
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
` (4 preceding siblings ...)
2007-06-10 2:10 ` pinskia at gcc dot gnu dot org
@ 2007-12-02 21:32 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-02 21:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2007-12-02 21:32 -------
No feedback in over 3 months so closing as worksforme.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |WORKSFORME
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-12-02 21:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-31 15:51 [Bug c/32166] New: Condition check for const char string fails kmanjunat at gmail dot com
2007-05-31 16:35 ` [Bug c/32166] " pinskia at gcc dot gnu dot org
2007-06-01 7:52 ` kmanjunat at gmail dot com
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
2007-06-01 11:19 ` rguenth at gcc dot gnu dot org
2007-06-10 2:10 ` pinskia at gcc dot gnu dot org
2007-12-02 21:32 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).