Hello,
I'm trying to make libdbi-drivers for sqlite3 von Windows Vista Ultimate
64Bit using Mingw64 build environment. If I run the included test case
(make check) I will receive a segmentation fault in function
dbi_geterror defined in source file dbd_sqlite3.c. I suppose that the
problem is caused by the fact that dbi_geterror is defined using a
formal parameter named *errno
int dbd_geterror(dbi_conn_t *conn, int *errno, char **errstr);
and the fact that errno is also defined as a macro in stdlib.h used by
dbd_sqlite3.c:
#define errno (*_errno())
errno_t __cdecl _set_errno(int _Value);
errno_t __cdecl _get_errno(int *_Value);
#endif
The problem can be reduced to and reproduced with the following tiny
program:
#include <stdio.h>
#include <stdlib.h>
void geterror(int *errno) {
*errno = 4711;
}
int main() {
int no;
geterror(&no);
printf("Error = %i",no);
return 0;
}
This compiles to the following assembler code:
geterror:
.LFB12:
.loc 1 20 0
.LVL0:
subq $40, %rsp
.LCFI0:
.loc 1 21 0
call *%rcx
.LVL1:
movq (%rax), %rax
movl $4711, (%rax)
.loc 1 22 0
addq $40, %rsp
ret
If I undefine the macro like
#include <stdio.h>
#include <stdlib.h>
#undef errno
void geterror(int *errno) {
*errno = 4711;
}
int main() {
int no;
geterror(&no);
printf("Error = %i",no);
return 0;
}
or rename the formal parameter error to ierror the problem will
disappear. The same applies to function _dbd_internal_error_handler in
file dbd_helper.c of the libdbi package.
Have I done something wrong in the configuration or is this a bug?
Regards,
Peter
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Libdbi-drivers-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel