Re: snprintf causes regression tests to fail

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.general
Message-ID <[email protected]>
I have some new information.  If I add the attached patch to snprintf.c,
I should see see snprintf() being called printing "0", vsnprintf()
printing "1" and dopr(), "2".  However, I only see "0" printing in the
server logs.

I think this means it is finding our /port/snprintf(), but when it calls
vsnprintf, it must be using some other version, probably the operating
system version that doesn't support %lld.

I am also attaching the 'nm' output from libpgport_srv.a which does show
vsnprintf as being defined.

Win32 doesn't like multiply defined symbols so we use
-Wl,--allow-multiple-definition to allow multiple symbols.

I bet if I define LONG_LONG_INT_FORMAT as '%I64d' it would pass the
regression tests.  (I will test now.)  Our config/c-library.m4 file
confirms that format for MinGW:

	# MinGW uses '%I64d', though gcc throws an warning with -Wall,

The big question is why our own vsnprintf() is not being called from
snprintf() in our port file.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [email protected]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [email protected]
/bjm/diff (text/plain, 642 B)
*** snprintf.c	Tue Mar  1 19:02:13 2005
--- /laptop/tmp/snprintf.c	Tue Mar  1 20:27:21 2005
***************
*** 96,101 ****
--- 96,102 ----
  	int			len;
  	va_list		args;
  
+ puts("0");
  	va_start(args, fmt);
  	len = vsnprintf(str, count, fmt, args);
  	va_end(args);
***************
*** 109,114 ****
--- 110,116 ----
  	char *end;
  	str[0] = '\0';
  	end = str + count - 1;
+ puts("1");
  	dopr(str, fmt, args, end);
  	if (count > 0)
  		end[0] = '\0';
***************
*** 178,183 ****
--- 180,186 ----
  		int	realpos;
  	} fmtpar[NL_ARGMAX+1], *fmtparptr[NL_ARGMAX+1];
  
+ puts("2");
  
  	format_save = format;
  	output = buffer;
/laptop/tmp/nm.out (text/plain, 8 KB)
crypt.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000060 b _a64toi
00002ce0 b _CF6464
000003c0 t _CIFP
000034e0 b _constdatablock
00000441 T _crypt
000034f0 b _cryptresult
00000760 t _des_cipher
00000000 d _des_ready
000006c2 t _des_setkey
000000c0 t _ExpandTr
000018e0 b _IE3264
00000a84 t _init_des
00000f0f t _init_perm
00000080 t _IP
00000400 t _itoa64
00003510 b _KS
000003a0 t _P32Tr
00000100 t _PC1
000000e0 b _PC1ROT
00000160 t _PC2
000008e0 b _PC2ROT
00000000 b _perm.0
00000000 t _permute
00000138 t _Rotates
000001a0 t _S
00001ce0 b _SPE
00000040 b _tmp32.1

fseeko.o:
00000000 b .bss
00000000 d .data
00000000 t .text

getrusage.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U ___udivdi3
         U ___umoddi3
         U __dosmaperr
         U __errno
         U _GetCurrentProcess@0
         U _GetLastError@0
         U _GetProcessTimes@20
00000000 T _getrusage

inet_aton.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __imp____mb_cur_max
         U __imp___pctype
         U __isctype
         U _htonl@4
00000000 T _inet_aton

random.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _lrand48
00000000 T _random

srandom.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _srand48
00000000 T _srandom

unsetenv.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _getenv
         U _malloc
         U _putenv
         U _sprintf
00000004 T _unsetenv

getaddrinfo_srv.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _atoi
         U _free
         U _gethostbyname@4
         U _htonl@4
         U _htons@4
         U _inet_aton
         U _inet_ntoa@4
         U _malloc
         U _memcpy
         U _ntohs@4
0000025a T _pg_freeaddrinfo
000002ca T _pg_gai_strerror
00000000 T _pg_getaddrinfo
000002f6 T _pg_getnameinfo
         U _snprintf
         U _WSAGetLastError@0

copydir.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t ___func__.0
         U _AllocateDir
000000a5 T _copydir
         U _CopyFileA@12
         U _errcode_for_file_access
         U _errfinish
         U _errmsg
         U _errstart
         U _FreeDir
         U _mkdir
         U _readdir
         U _snprintf

gettimeofday.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U ___udivdi3
00000000 t _epoch
         U _GetSystemTime@4
00000008 T _gettimeofday
         U _SystemTimeToFileTime@8

kill.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __errno
         U _CallNamedPipeA@28
         U _GetLastError@0
00000015 T _pgkill
         U _wsprintfA

open.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __assert
         U __errno
         U __open_osfhandle
         U __setmode
         U _CloseHandle@4
         U _CreateFileA@28
         U _GetLastError@0
00000000 t _openFlagsToCreateFileFlags
00000160 T _win32_open

rand.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t __dorand48
0000000c D __rand48_add
00000006 D __rand48_mult
00000000 D __rand48_seed
000000bd T _lrand48
000000ed T _srand48

snprintf.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U ___udivdi3
         U ___umoddi3
         U __alloca
         U __vsnprintf
000000dd t _dopr
00000c73 t _dopr_outch
00000c09 t _dostr
00000b29 t _fmtfloat
00000986 t _fmtnum
00000000 b _fmtpar.0
00050050 b _fmtparptr.1
000008cc t _fmtstr
00000000 T _printf
         U _putchar
         U _puts
00000055 T _snprintf
         U _sprintf
00000083 T _vsnprintf

dirmod_srv.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t ___func__.0
00000137 t ___func__.1
00000230 t ___func__.2
000005ec t ___func__.3
         U __errno
         U _closedir
         U _CloseHandle@4
         U _CreateDirectoryA@8
         U _CreateFileA@28
         U _DeviceIoControl@32
         U _elog_finish
         U _elog_start
         U _errcode_for_file_access
         U _errfinish
         U _errmsg
         U _errstart
000004c2 t _fnames
000005b8 t _fnames_cleanup
         U _FormatMessageA@28
         U _GetLastError@0
         U _LocalFree@4
         U _MoveFileExA@12
         U _MultiByteToWideChar@24
         U _opendir
         U _pfree
         U _pgport_palloc
         U _pgport_pstrdup
00000081 T _pgrename
00000282 T _pgsymlink
00000182 T _pgunlink
         U _pgwin32_backend_usleep
         U _readdir
         U _RemoveDirectoryA@4
         U _repalloc
         U _rmdir
0000062c T _rmtree
         U _snprintf
         U _sprintf
         U _stat
         U _strchr
         U _strcpy
         U _unlink

exec_srv.o:
00000000 b .bss
00000000 d .data
00000000 t .text
000000d2 t ___func__.0
000008a5 t ___func__.1
         U __errno
         U __imp____mb_cur_max
         U __imp___pctype
         U __isctype
         U __pclose
         U _canonicalize_path
         U _CloseHandle@4
         U _CreatePipe@16
         U _CreateProcessA@40
         U _DuplicateHandle@28
         U _elog_finish
         U _elog_start
00000181 T _find_my_exec
00000514 T _find_other_exec
         U _first_dir_separator
         U _first_path_separator
         U _GetCurrentProcess@0
         U _getcwd
         U _getenv
         U _join_path_components
         U _last_dir_separator
         U _memset
00000971 T _pclose_check
         U _perror
         U _pg_strcasecmp
00000610 t _pipe_read_line
         U _ReadFile@20
000004f3 t _resolve_symlinks
         U _snprintf
         U _stat
         U _strcat
         U _strchr
         U _strcmp
         U _strcpy
         U _strerror
         U _strncpy
00000005 t _validate_exec
         U _WaitForSingleObject@8

noblock.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _ioctlsocket@12
00000000 T _set_noblock

path.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __imp____mb_cur_max
         U __imp___iob
         U __imp___pctype
         U __isctype
00000210 T _canonicalize_path
         U _exit
         U _find_my_exec
0000008f T _first_dir_separator
000000bc T _first_path_separator
         U _fprintf
000004d3 T _get_etc_path
00000620 T _get_home_path
0000050b T _get_include_path
00000580 T _get_includeserver_path
000005b4 T _get_lib_path
000005f3 T _get_locale_path
00000684 T _get_parent_directory
0000052a T _get_pkginclude_path
000005d3 T _get_pkglib_path
00000323 T _get_progname
0000049f T _get_share_path
         U _getenv
0000012d T _join_path_components
000000d9 T _last_dir_separator
0000010e T _make_native_path
000003d8 t _make_relative_path
         U _pg_strcasecmp
         U _putenv
000006bc T _set_pglocale_pgservice
         U _setlocale
         U _SHGetFolderPathA@20
00000000 t _skip_drive
         U _snprintf
         U _strdup
         U _strncmp
         U _strncpy
00000772 t _trim_directory
00000805 t _trim_trailing_separator

pipe.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t ___func__.0
         U _accept@12
         U _bind@12
         U _closesocket@4
         U _connect@12
         U _errfinish
         U _errmsg_internal
         U _errstart
         U _getsockname@12
         U _htonl@4
         U _htons@4
         U _listen@8
00000164 T _pgpipe
0000042e T _piperead
         U _recv@16
         U _socket@12
         U _WSAGetLastError@0

pgsleep.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 T _pg_usleep
         U _SleepEx@8

pgstrcasecmp.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __imp____mb_cur_max
         U __imp___pctype
         U __isctype
00000000 T _pg_strcasecmp
0000010e T _pg_strncasecmp
000002aa T _pg_tolower
00000234 T _pg_toupper
         U _tolower
         U _toupper

sprompt.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U __imp___iob
         U _fclose
         U _fflush
         U _fgets
         U _fopen
         U _fputc
         U _fputs
         U _free
         U _GetConsoleMode@8
         U _GetStdHandle@4
         U _malloc
00000000 D _prompt_state
         U _SetConsoleMode@8
0000000d T _simple_prompt

thread_srv.o:
00000000 b .bss
00000000 d .data
00000000 t .text
         U _gethostbyname@4
00000039 T _pqGethostbyname
00000000 T _pqStrerror
         U _strerror
         U _strncpy
         U _WSAGetLastError@0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.