Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does NV_FUNCT differ from NV_FUNCTION? #1046

Open
krader1961 opened this issue Dec 4, 2018 · 1 comment
Open

How does NV_FUNCT differ from NV_FUNCTION? #1046

krader1961 opened this issue Dec 4, 2018 · 1 comment
Labels

Comments

@krader1961
Copy link
Contributor

Please explain to me the difference between NV_FUNCT in src/cmd/ksh93/include/nval.h and NV_FUNCTION in src/cmd/ksh93/include/name.h. It seems to me that everyplace that uses NV_FUNCT should be using NV_FUNCTION. Other than the definition of NV_FUNCTION which should be using NV_MISC (formerly NV_IDENT). This is another instance where symbols like NV_FUNCTION should be a distinct bit rather than a composite bit field. And the NV_ symbols in name.h should be in nval.h. See issue #1038.

I continue to be amazed that this code works as well as it does given such ambiguities that have already been shown to be the source of bugs.

@krader1961 krader1961 self-assigned this Dec 4, 2018
@krader1961
Copy link
Contributor Author

Please notice that expressions like this from src/cmd/ksh93/sh/name.c are fundamentally broken:

nv_isattr(np, NV_ARRAY | NV_INTEGER | NV_FUNCT | NV_REF)

That's because they can result in false positives if any of those symbols are defined in terms or more than a single bit. Which isn't true of that specific expression. However, note that NV_FUNCT, and some of the other symbols, are used in a multi-bit definition of a different symbol. And thus might be set as a side-effect of setting one of those other symbols. Furthermore, some of those symbols, such as NV_FUNCT, are defined defined in terms of a different namval attr bit. In this case NV_FUNCT is an alias for NV_IDENT which is now defined as an alias for NV_MISC. The latter being used for many other purposes.

This is related to #855. And this also probably accounts for some of the use-after-free and similar failures that are found when running the code under a debug malloc, ASAN, or valgrind.

@krader1961 krader1961 removed their assignment Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant