Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Fwd: Problem with SQLite 3.7.6



adam%NetBSD.org@localhost said:
> Can you tell me how to reproduce the problem so that we can debug it?

This looks amd64 specific, and highly dependent on compiler version
and optimization level.

Casting a function pointer from varargs-using to non-varargs-using
is generally not innocuous. The calling conventions can be different.
On i386, there is no difference afaik. On amd64, there is one:
Calls to vararg-using functions pass the number of floating-
point arguments (which are passed in FPU registers) in EAX.
In the vararg-using function, gcc generates code which saves
the floating-point arguments. This code uses a computed jump.
If there is junk in EAX, the jump goes to some random location.

So what likely happens is that the calling code (robust_open())
doesn't put a 0 into EAX because it thinks it calls a non-vararg
function. Instead, something else is there which can be the
result of a previous function call or some intermediate value.

robust_open() just calls the syscall open(). The latter is
typically implemented as assembler stub in libc, so the gcc
generated vararg handling code is not there and the semi-random
value in EAX doesn't hurt. Only if open() is implemented
by C code the problem is triggered. This happens to be the
case in NetBSD's libpthread.

best regards
Matthias



------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDirig Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

Besuchen Sie uns auf unserem neuen Webauftritt unter www.fz-juelich.de


Home | Main Index | Thread Index | Old Index