Project

General

Profile

Actions

Bug #1711

closed

memmem() in string.h should be more or less VISIBLE on x86_64?

Added by davshao over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The memmem() function has a prototype given in /usr/include/string.h, (and
/usr/src/lib/libc/string/memmem.c exists) only it is required that __BSD_VISIBLE
be defined. Unfortunately a check of gcc 4.1.2

gcc -E -dM - < /dev/null | sort

shows no sign of any *VISIBLE.

Suppose on x86_64 some package, say scmgit-base, detects the existence of
memmem() yet because it too does not define any *VISIBLE uses an implicit
definition of memmem(), as is indicated in the build messages:

checking for memmem... yes
checking for library containing memmem... none required
and
diff.c:369: warning: implicit declaration of function 'memmem'

From scmgit-base's configure it is just a simple test for memmem(), essentially just

char memmem ();
int
main () {
return memmem ();
;
return 0;
}

Then the return value of the actual memmem() that should be (void *) I believe
suddenly becomes an int, so that what used to be a valid pointer after the
return is now possibly not a valid pointer on x86_64 if it is truncated and then
sign extended to a negative 64-bit number. For example, using

git diff HEAD^ HEAD

produces segmentation fault errors.

So far setting
NO_MEMMEM = YesPlease
in git's entry for DragonFly in its Makefile does not appear to have solved the
problem.

Actions #1

Updated by swildner over 14 years ago

Am 31.03.2010 21:55, schrieb David Shao (via DragonFly issue tracker):

New submission from David Shao<>:

The memmem() function has a prototype given in /usr/include/string.h, (and
/usr/src/lib/libc/string/memmem.c exists) only it is required that __BSD_VISIBLE
be defined. Unfortunately a check of gcc 4.1.2

gcc -E -dM -< /dev/null | sort

shows no sign of any *VISIBLE.

__BSD_VISIBLE is not a builtin. It's defined in <sys/cdefs.h> and is 1
for our default compilation environment (unless any _POSIX_C_SOURCE or
similar macros are set).

Sascha

Actions #2

Updated by qhwt+dfly over 14 years ago

:

Then the return value of the actual memmem() that should be (void *) I believe
suddenly becomes an int, so that what used to be a valid pointer after the
return is now possibly not a valid pointer on x86_64 if it is truncated and then
sign extended to a negative 64-bit number. For example, using

git diff HEAD^ HEAD

produces segmentation fault errors.

This particular issue in git should have been solved in pkgsrc-HEAD,
can you try updating the devel/scmgit-base directory and re-install it?

Cheers.

Actions #3

Updated by swildner almost 13 years ago

  • Status changed from New to Closed
  • Assignee deleted (0)

All issues fixed, closing.

Actions

Also available in: Atom PDF