buglibffcall - foreign function call libraries - Bugs: bug #32466, segfault


bug #32466: segfault

Submitted by:  Andrey Kutejko <andy128k>
Submitted on:  Sun Feb 13 23:06:05 2011  
Category: NoneSeverity: 4 - Important
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Bruno Haible <haible>
Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Sat Feb 11 15:07:22 2017, comment #6:

I've reverted the fix and installed a simpler one instead:


Bruno Haible <haible>
Project AdministratorIn charge of this item.
Mon Jan 2 22:52:45 2017, comment #5:

Re Sam:

> packaging libffcall as a shared library is a mistake.

I disagree. There is a move to position-independent code in the industry (think of ASLR). And when security bugs need to be fixed, you don't want to recompile all packages that use the library. So, compiling libffcall as a shared library should be made possible.

Re Andrey:

> Some code from ld.so corrupts r10 register which is used to pass callback data.

Yup. It's the routine, in ld.so, which resolves the address of function.

I found your patch (0001-fix-callback-on-x86_64.patch) very inspiring. Sure, it is wrong because it does not respect the required alignment of %rsp. But what I like about it is the ability to insert arbitrary instructions at the beginning of the function __vacall_r.

Now fixed for x86_64 and other CPU types through http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=cb99e282fc978c77c4fb44d7965b331b89dd55ac

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Mon Feb 14 03:56:39 2011, comment #4:

packaging libffcall as a shared library is a mistake.
see libffcall/README
I will leave it to Bruno to decide whether to accept the patch.

Sam Steingold <sds>
Project Administrator
Mon Feb 14 00:16:49 2011, comment #3:

I use CVS snaphot 1.10+cvs20100619 (Debian Unstable).

There is no segfault when libcallback is linked as static library. But program crashes when libcallback is linked as shared library.

Some code from ld.so corrupts r10 register which is used to pass callback data.

Andrey Kutejko <andy128k>
Sun Feb 13 23:59:43 2011, comment #2:

wfm on Linux sysu76 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 23:42:43 UTC 2011 x86_64 GNU/Linux
and cvs head of ffcall:
$ gcc -I ~/src/top/include/ test_callback.c ~/src/top/lib/libvacall.a ~/src/top/lib/libtrampoline.a ~/src/top/lib/libcallback.a -o test_callback.exe
$ ./test_callback.exe
data = 0xbebebe: 2 + 3 = 5

are you reporting a bug in the released version or in cvs head?

Sam Steingold <sds>
Project Administrator
Sun Feb 13 23:12:00 2011, comment #1:

libcallback.so crashes on amd64.

I attach simple program which reproduces an error and a patch.

(file #22679, file #22680)

Andrey Kutejko <andy128k>
Sun Feb 13 23:06:05 2011, original submission:
Andrey Kutejko <andy128k>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #22679:  test_callback.c added by andy128k (457B - text/x-csrc)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by haible (Posted a comment)
  • -unavailable- added by sds (Posted a comment)
  • -unavailable- added by andy128k (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Jan 2 22:52:45 2017haibleSeverity3 - Normal=>4 - Important
    Sun Feb 13 23:59:43 2011sdsAssigned toNone=>haible
    Sun Feb 13 23:12:00 2011andy128kAttached File-=>Added test_callback.c, #22679
      Attached File-=>Added 0001-fix-callback-on-x86_64.patch, #22680

    Back to the top

    Powered by Savane 3.1-cleanup1