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

Nondeterminism in nesc output #36

Open
mstewartgallus opened this issue Dec 22, 2015 · 7 comments
Open

Nondeterminism in nesc output #36

mstewartgallus opened this issue Dec 22, 2015 · 7 comments

Comments

@mstewartgallus
Copy link

There are two cases.

When function declarations do not have argument names then nondeterministic names will be generated for them like typedef int (*__compar_fn_t)(const void *arg_0x2aeff645d6e0, const void *arg_0x2aeff645d9b8);.

When templated instances are used then instance parameters for functions can also have nondeterministic names.

This is bad for reproducible builds although I think as of now it can only really effect debug information.

@cire831
Copy link
Member

cire831 commented Dec 22, 2015

can you please be more specific?

what exactly is non-deterministic?

@mstewartgallus
Copy link
Author

The function declaration arguments seem to have names generated from program pointers to memory. Such pointers are usually nondeterministic because of things like ASLR.

But anyway, the simplest way to reproduce the problem is to run the command nescc -conly -S -fnesc-cfile=old.c Source.nc && nescc -conly -S -fnesc-cfile=new.c Source.nc for some source Source.nc and then compare the output files with diff or a similar utility.

@cire831
Copy link
Member

cire831 commented Dec 23, 2015

what is ASLR?

On Tue, Dec 22, 2015 at 1:29 PM, Steven Stewart-Gallus <
notifications@github.com> wrote:

The function declaration arguments seem to have names generated from
program pointers to memory. Such pointers are usually nondeterministic
because of things like ASLR.

But anyway, the simplest way to reproduce the problem is to run the
command nescc -conly -S -fnesc-cfile=old.c Source.nc && nescc -conly -S
-fnesc-cfile=new.c Source.nc and then compare the output files with diff
or a similar utility.


Reply to this email directly or view it on GitHub
#36 (comment).

Eric B. Decker
Senior (over 50 :-) Researcher

@mstewartgallus
Copy link
Author

ASLR is short for Address Space Layout Randomization and is a security feature in modern operating systems.

When the library code for malloc or similar allocates memory it ultimately needs to defer to the OS and use a system call such as sbrk or mmap to map memory into the process. With ASLR the OS can return a random memory block for certain mmap requests instead of a deterministic one. As well, carefully written program loaders let mmap and ASLR map libraries and position independent executables into random locations so pointers to data in library and executable code may not be deterministic.

@cire831
Copy link
Member

cire831 commented Dec 23, 2015

okay. thanks for the def

so why does any of this matter?

On Tue, Dec 22, 2015 at 8:19 PM, Steven Stewart-Gallus <
notifications@github.com> wrote:

ASLR is short for Address Space Layout Randomization

When the library code for malloc or similar allocates memory it
ultimately needs to defer to the OS and use a system call such as sbrk or
mmap to map memory into the process. With ASLR the OS can return a random
memory block for certain mmap requests instead of a deterministic one. As
well, carefully written program loaders libraries let mmap and ASLR map
libraries and position independent executables into random locations, so
pointers to data in library and executable code may not be deterministic.


Reply to this email directly or view it on GitHub
#36 (comment).

Eric B. Decker
Senior (over 50 :-) Researcher

@mstewartgallus
Copy link
Author

Reproducible builds have a number of uses: see https://reproducible-builds.org/

I personally would like reproducible builds so that if I decide to distribute partially compiled code (nesc code translated to C code but the C code not compiled to object code) that someone else could independently compile and create the C code to be sure I wasn't pulling any funny business.

@phil-levis
Copy link

Steven,

I'd suggest contacting David Gay (dgay42), since he wrote 99% of the nesC compiler. He can at the very least point you at the bit of code that generates those argument names so you can suggest something more deterministic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants