public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol
@ 2003-07-04 11:38 richard at brainstorm dot co dot uk
  2003-07-04 17:15 ` [Bug libobjc/11433] " pinskia at physics dot uc dot edu
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: richard at brainstorm dot co dot uk @ 2003-07-04 11:38 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433

           Summary: Crash due to dereferencing null pointer when querying
                    protocol
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libobjc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: richard at brainstorm dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org

Consider the following trivial test program (test.m)-

#include        <objc/objc.h>
#include        <objc/Object.h>
#include        <objc/Protocol.h>

@protocol TestProtocol
+ testMethod;
@end

int
main()
{
  [@protocol(TestProtocol) descriptionForInstanceMethod: @selector(name)];
  return 0;
}


If you compile it using the command 'gcc test.m -lobjc'
Then run a.out, and you will get a segmentation violation.

This is because TestProtocol contains only a class method, but we tried to look
up an instance method ... the lookup should have returned a null pointer rather
than crashing.

There is a simple fix to the file Protocol.m in the objc runtume ...

diff Protocol.m Protocol.m.old
83c83
<   if (instance_methods != 0)
---
>   for (i = 0; i < instance_methods->count; i++)
85,89c85,86
<       for (i = 0; i < instance_methods->count; i++)
<       {
<         if (!strcmp ((char*)instance_methods->list[i].name, name))
<           return &(instance_methods->list[i]);
<       }
---
>       if (!strcmp ((char*)instance_methods->list[i].name, name))
>       return &(instance_methods->list[i]);
113c110
<   if (class_methods != 0)
---
>   for (i = 0; i < class_methods->count; i++)
115,119c112,113
<       for (i = 0; i < class_methods->count; i++)
<       {
<         if (!strcmp ((char*)class_methods->list[i].name, name))
<           return &(class_methods->list[i]);
<       }
---
>       if (!strcmp ((char*)class_methods->list[i].name, name))
>       return &(class_methods->list[i]);


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
@ 2003-07-04 17:15 ` pinskia at physics dot uc dot edu
  2003-07-04 20:01 ` richard at brainstorm dot co dot uk
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-04 17:15 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-07-04 17:15:30
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-04 17:15 -------
I can confirm this on 2.95.3 and on the mainline (20030704).
Would you mind reading <http://gcc.gnu.org/contribute.html> and sending your patch to 
gcc-patches@gcc.gnu.org?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
  2003-07-04 17:15 ` [Bug libobjc/11433] " pinskia at physics dot uc dot edu
@ 2003-07-04 20:01 ` richard at brainstorm dot co dot uk
  2003-08-23  0:43 ` dhazeghi at yahoo dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: richard at brainstorm dot co dot uk @ 2003-07-04 20:01 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433



------- Additional Comments From richard at brainstorm dot co dot uk  2003-07-04 20:01 -------
Subject: Re:  Crash due to dereferencing null pointer when querying protocol


On Friday, July 4, 2003, at 06:15 PM, pinskia at physics dot uc dot edu 
wrote:

> ------- Additional Comments From pinskia at physics dot uc dot edu  
> 2003-07-04 17:15 -------
> I can confirm this on 2.95.3 and on the mainline (20030704).
> Would you mind reading <http://gcc.gnu.org/contribute.html> and 
> sending your patch to
> gcc-patches@gcc.gnu.org?
>

OK.  I sent it in.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
  2003-07-04 17:15 ` [Bug libobjc/11433] " pinskia at physics dot uc dot edu
  2003-07-04 20:01 ` richard at brainstorm dot co dot uk
@ 2003-08-23  0:43 ` dhazeghi at yahoo dot com
  2003-10-30  7:08 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  0:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (2 preceding siblings ...)
  2003-08-23  0:43 ` dhazeghi at yahoo dot com
@ 2003-10-30  7:08 ` pinskia at gcc dot gnu dot org
  2003-12-01 23:06 ` zack at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-30  7:08 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
   Target Milestone|---                         |3.4


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-30 07:07 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-07/msg00447.html>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (3 preceding siblings ...)
  2003-10-30  7:08 ` pinskia at gcc dot gnu dot org
@ 2003-12-01 23:06 ` zack at gcc dot gnu dot org
  2003-12-01 23:30 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zack at gcc dot gnu dot org @ 2003-12-01 23:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zack at gcc dot gnu dot org  2003-12-01 23:06 -------
Bug confirmed 2003-12-01.  The patch looks good to me, but it isn't compliant
with the coding standards.  I will revise it.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |zack at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (4 preceding siblings ...)
  2003-12-01 23:06 ` zack at gcc dot gnu dot org
@ 2003-12-01 23:30 ` cvs-commit at gcc dot gnu dot org
  2003-12-01 23:31 ` zack at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-12-01 23:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-12-01 23:30 -------
Subject: Bug 11433

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	zack@gcc.gnu.org	2003-12-01 23:30:00

Modified files:
	gcc/testsuite  : ChangeLog 
	libobjc        : ChangeLog Protocol.m 
Added files:
	gcc/testsuite/objc.dg: proto-lossage-3.m 

Log message:
	PR 11433
	gcc/testsuite:
	* objc.dg/proto-lossage-3.m: New test.
	libobjc:
	* Protocol.m (descriptionForInstanceMethod): Don't dereference
	instance_methods if it's NULL.
	(descriptionForClassMethod): Likewise for class_methods.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3216&r2=1.3217
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/proto-lossage-3.m.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/ChangeLog.diff?cvsroot=gcc&r1=1.103&r2=1.104
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/Protocol.m.diff?cvsroot=gcc&r1=1.4&r2=1.5



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (5 preceding siblings ...)
  2003-12-01 23:30 ` cvs-commit at gcc dot gnu dot org
@ 2003-12-01 23:31 ` zack at gcc dot gnu dot org
  2003-12-02  0:45 ` gdr at integrable-solutions dot net
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zack at gcc dot gnu dot org @ 2003-12-01 23:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zack at gcc dot gnu dot org  2003-12-01 23:31 -------
Patch applied to mainline.

This is not a regression - the bug has been around since 2.95 - but the fix is
very  low risk so it might be a 3.3 candidate anyway.  But that's not my
decision.  Closing bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (6 preceding siblings ...)
  2003-12-01 23:31 ` zack at gcc dot gnu dot org
@ 2003-12-02  0:45 ` gdr at integrable-solutions dot net
  2003-12-02  1:59 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-12-02  0:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2003-12-02 00:45 -------
Subject: Re:  Crash due to dereferencing null pointer when querying protocol

"zack at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Patch applied to mainline.
| 
| This is not a regression - the bug has been around since 2.95 - but
| the fix is very  low risk so it might be a 3.3 candidate anyway.
| But that's not my decision.  Closing bug.

I'm accpeting non-regression fixes too, til December 31.
If you have any chance to apply it to 3_3-branc, that would be
appreciated.  

Thanks,

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (7 preceding siblings ...)
  2003-12-02  0:45 ` gdr at integrable-solutions dot net
@ 2003-12-02  1:59 ` cvs-commit at gcc dot gnu dot org
  2003-12-02  2:00 ` zack at gcc dot gnu dot org
  2003-12-02  2:03 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-12-02  1:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-12-02 01:59 -------
Subject: Bug 11433

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	zack@gcc.gnu.org	2003-12-02 01:59:37

Modified files:
	gcc/testsuite  : ChangeLog 
	libobjc        : ChangeLog Protocol.m 
Added files:
	gcc/testsuite/objc.dg: proto-lossage-3.m 

Log message:
	PR 11433
	gcc/testsuite:
	* objc.dg/proto-lossage-3.m: New test.
	libobjc:
	* Protocol.m (descriptionForInstanceMethod): Don't dereference
	instance_methods if it's NULL.
	(descriptionForClassMethod): Likewise for class_methods.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.319&r2=1.2261.2.320
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/proto-lossage-3.m.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.87.4.10&r2=1.87.4.11
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/Protocol.m.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3&r2=1.3.20.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (8 preceding siblings ...)
  2003-12-02  1:59 ` cvs-commit at gcc dot gnu dot org
@ 2003-12-02  2:00 ` zack at gcc dot gnu dot org
  2003-12-02  2:03 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: zack at gcc dot gnu dot org @ 2003-12-02  2:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From zack at gcc dot gnu dot org  2003-12-02 02:00 -------
Ok, applied to 3.3 branch too.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libobjc/11433] Crash due to dereferencing null pointer when querying protocol
  2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
                   ` (9 preceding siblings ...)
  2003-12-02  2:00 ` zack at gcc dot gnu dot org
@ 2003-12-02  2:03 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-02  2:03 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |3.3.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11433


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-12-02  2:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-04 11:38 [Bug libobjc/11433] New: Crash due to dereferencing null pointer when querying protocol richard at brainstorm dot co dot uk
2003-07-04 17:15 ` [Bug libobjc/11433] " pinskia at physics dot uc dot edu
2003-07-04 20:01 ` richard at brainstorm dot co dot uk
2003-08-23  0:43 ` dhazeghi at yahoo dot com
2003-10-30  7:08 ` pinskia at gcc dot gnu dot org
2003-12-01 23:06 ` zack at gcc dot gnu dot org
2003-12-01 23:30 ` cvs-commit at gcc dot gnu dot org
2003-12-01 23:31 ` zack at gcc dot gnu dot org
2003-12-02  0:45 ` gdr at integrable-solutions dot net
2003-12-02  1:59 ` cvs-commit at gcc dot gnu dot org
2003-12-02  2:00 ` zack at gcc dot gnu dot org
2003-12-02  2:03 ` 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).