Page MenuHomeFreeBSD

depend-cleanup.sh: Move pwd to a safer place
Needs ReviewPublic

Authored by aokblast on Sat, Jan 17, 1:26 PM.
Tags
None
Referenced Files
F142548218: D54757.diff
Tue, Jan 20, 9:04 PM
Unknown Object (File)
Sun, Jan 18, 7:45 PM
Unknown Object (File)
Sun, Jan 18, 6:44 PM
Unknown Object (File)
Sun, Jan 18, 2:15 PM
Unknown Object (File)
Sun, Jan 18, 11:47 AM
Unknown Object (File)
Sat, Jan 17, 11:36 PM
Unknown Object (File)
Sat, Jan 17, 6:03 PM
Unknown Object (File)
Sat, Jan 17, 6:01 PM
Subscribers

Details

Reviewers
markj
jrtc27
imp
Summary

When using bear -- make buildworld, the bear failed on getcwd in this function.
This is because the interceptor want to use getcwd on a deleted
directory. We move the pwd out from the $OBJTOP.

Notice that any operation on $OBJTOP should be invalid after calling rm.
As a result, it is safe to move to any place.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 69961
Build 66844: arc lint + arc unit

Event Timeline

aokblast added a reviewer: markj.
aokblast added reviewers: jrtc27, imp.
aokblast edited the summary of this revision. (Show Details)

I don’t understand, other than it sounding like bear is broken

I don’t understand, other than it sounding like bear is broken

Sorry, the commit message is not clear. I try to explain with more detail. Please tell me if you need anymore information.

When

pwd == $OBJTOP

, and after

run rm -rf "$OBJTOP"

getcwd(3) will return with error since the directory is deleted.

Under this condition:

When shell is executing:

mkdir -p "$OBJTOP"

bear intercepts the libc exec(3) function call and call getcwd in here. As a result, it causes an error.

I don’t understand, other than it sounding like bear is broken

Sorry, the commit message is not clear. I try to explain with more detail. Please tell me if you need anymore information.

When

pwd == $OBJTOP

, and after

run rm -rf "$OBJTOP"

getcwd(3) will return with error since the directory is deleted.

Under this condition:

When shell is executing:

mkdir -p "$OBJTOP"

bear intercepts the libc exec(3) function call and call getcwd in here. As a result, it causes an error.

So... bear makes assumptions that are false and breaks perfectly fine build system code

tools/build/depend-cleanup.sh
250

Having said that, would changing this line to:

rm -rf "$OBJTOP"/* "$OBJTOP"/.[!.] "$OBJTOP"/.??*

also address the issue? That would avoid the need for the mkdir -p "$OBJTOP" on line 264 and be generally more friendly.

I don’t understand, other than it sounding like bear is broken

Sorry, the commit message is not clear. I try to explain with more detail. Please tell me if you need anymore information.

When

pwd == $OBJTOP

, and after

run rm -rf "$OBJTOP"

getcwd(3) will return with error since the directory is deleted.

Under this condition:

When shell is executing:

mkdir -p "$OBJTOP"

bear intercepts the libc exec(3) function call and call getcwd in here. As a result, it causes an error.

So... bear makes assumptions that are false and breaks perfectly fine build system code

Yes, you are right. In Bear, getcwd is used to format absolute path names. When a path is already absolute, the working-directory parameter can be optional. However, changing this behavior in Bear would require refactoring many files due to the deep call chain. I will give it a try when I have time.

tools/build/depend-cleanup.sh
250

Thanks! I am trying to run make buildworld. I will update the patch if it runs sucessfully.

Delete content instead of removing the whole directory