public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45106]  New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
@ 2010-07-28 11:47 robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:53 ` [Bug c/45106] " robert dot haschke at uni-bielefeld dot de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: robert dot haschke at uni-bielefeld dot de @ 2010-07-28 11:47 UTC (permalink / raw)
  To: gcc-bugs

Casting a variadic function pointer to normal function pointer (with adequate
number and type of arguments) causes a segfault, when the function is called.
Vice versa (casting normal function pointer to variadic function) works fine.
The problem only occurs for 64bit builds. Casting works nice in all directions
for 32bit builds.


-- 
           Summary: casting of variadic function pointers to normal function
                    pointers causes segfaults on 64bit systems
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: robert dot haschke at uni-bielefeld dot de
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:53 ` [Bug c/45106] " robert dot haschke at uni-bielefeld dot de
@ 2010-07-28 11:53 ` robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:57 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: robert dot haschke at uni-bielefeld dot de @ 2010-07-28 11:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from robert dot haschke at uni-bielefeld dot de  2010-07-28 11:52 -------
Created an attachment (id=21335)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21335&action=view)
preprocessed file


-- 


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
@ 2010-07-28 11:53 ` robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:53 ` robert dot haschke at uni-bielefeld dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: robert dot haschke at uni-bielefeld dot de @ 2010-07-28 11:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from robert dot haschke at uni-bielefeld dot de  2010-07-28 11:53 -------
Created an attachment (id=21336)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21336&action=view)
original .c file


-- 


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:53 ` [Bug c/45106] " robert dot haschke at uni-bielefeld dot de
  2010-07-28 11:53 ` robert dot haschke at uni-bielefeld dot de
@ 2010-07-28 11:57 ` jakub at gcc dot gnu dot org
  2010-07-28 12:04 ` rhaschke at techfak dot uni-bielefeld dot de
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-28 11:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2010-07-28 11:57 -------
Don't do it, it is not valid.
The x86-64 ABI requires that for varargs the %al register contains number of
SSE regs that need saving, while for non-varargs functions that register is
undefined.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
                   ` (2 preceding siblings ...)
  2010-07-28 11:57 ` jakub at gcc dot gnu dot org
@ 2010-07-28 12:04 ` rhaschke at techfak dot uni-bielefeld dot de
  2010-07-28 12:26 ` schwab at linux-m68k dot org
  2010-07-28 14:01 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rhaschke at techfak dot uni-bielefeld dot de @ 2010-07-28 12:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rhaschke at techfak dot uni-bielefeld dot de  2010-07-28 12:04 -------
Subject: Re:  casting of variadic function pointers to normal
 function pointers causes segfaults on 64bit systems

I was afraid of this answer.
However in my application, I have no clue which type of function pointer
is transferred. Thus, I should always cast to the variadic function
pointer in order to define the %al register?

Cheers, Robert


-- 


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
                   ` (3 preceding siblings ...)
  2010-07-28 12:04 ` rhaschke at techfak dot uni-bielefeld dot de
@ 2010-07-28 12:26 ` schwab at linux-m68k dot org
  2010-07-28 14:01 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at linux-m68k dot org @ 2010-07-28 12:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from schwab at linux-m68k dot org  2010-07-28 12:26 -------
Calling a function with a different signature than declared is undefined in any
case.


-- 


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


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

* [Bug c/45106] casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems
  2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
                   ` (4 preceding siblings ...)
  2010-07-28 12:26 ` schwab at linux-m68k dot org
@ 2010-07-28 14:01 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-28 14:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2010-07-28 14:01 -------
(In reply to comment #4)
> Subject: Re:  casting of variadic function pointers to normal
>  function pointers causes segfaults on 64bit systems
> 
> I was afraid of this answer.
> However in my application, I have no clue which type of function pointer
> is transferred. Thus, I should always cast to the variadic function
> pointer in order to define the %al register?
> 
> Cheers, Robert

That doesn't work either.  You have to pass around some cookie that
tells you the function prototype and cast to the appropriate one.


-- 


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


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

end of thread, other threads:[~2010-07-28 14:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-28 11:47 [Bug c/45106] New: casting of variadic function pointers to normal function pointers causes segfaults on 64bit systems robert dot haschke at uni-bielefeld dot de
2010-07-28 11:53 ` [Bug c/45106] " robert dot haschke at uni-bielefeld dot de
2010-07-28 11:53 ` robert dot haschke at uni-bielefeld dot de
2010-07-28 11:57 ` jakub at gcc dot gnu dot org
2010-07-28 12:04 ` rhaschke at techfak dot uni-bielefeld dot de
2010-07-28 12:26 ` schwab at linux-m68k dot org
2010-07-28 14:01 ` rguenth 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).