[action] [PR:22073] Fix the nnpy installation failure for test_copp#22160
Merged
vmittal-msft merged 1 commit intosonic-net:202511from Jan 30, 2026
Merged
[action] [PR:22073] Fix the nnpy installation failure for test_copp#22160vmittal-msft merged 1 commit intosonic-net:202511from
vmittal-msft merged 1 commit intosonic-net:202511from
Conversation
What is the motivation for this PR? To fix the failure of nnpy package installation, the root cause is This error—failed to map segment from shared object—is almost always caused by the /tmp partition being mounted with the noexec flag. In many security-hardened Linux environments (like those used for SONiC), the system prevents files in /tmp from being executed. Since pip creates a temporary build environment in /tmp to compile nnpy and cffi, the installation crashes when it tries to load the newly built library. The Fix: Change the Temporary Directory You can tell pip to use a different directory for building that has execution permissions (like your home directory or /var/tmp). Why nnpy specifically is failing? Unlike many other packages, nnpy is a "thick" wrapper around the C-library nanomsg. It uses a tool called CFFI (C Foreign Function Interface). pip downloads the nnpy source. It creates a "virtual" build environment in /tmp. It compiles a C-extension (_cffi_backend.so). It tries to "import" that C-extension to finish the metadata generation. The Linux kernel sees the file is in a noexec zone and kills the process, resulting in the error you saw. How did you do it? change to use /var/tmp-build as TMPDIR for cffi and nnpy installation. Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
12 tasks
Collaborator
Author
|
Original PR: #22073 |
Collaborator
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
YatishSVC
approved these changes
Jan 30, 2026
vmittal-msft
approved these changes
Jan 30, 2026
lakshmi-nexthop
pushed a commit
to lakshmi-nexthop/sonic-mgmt
that referenced
this pull request
Feb 11, 2026
…nic-net#22160) What is the motivation for this PR? To fix the failure of nnpy package installation, the root cause is This error—failed to map segment from shared object—is almost always caused by the /tmp partition being mounted with the noexec flag. In many security-hardened Linux environments (like those used for SONiC), the system prevents files in /tmp from being executed. Since pip creates a temporary build environment in /tmp to compile nnpy and cffi, the installation crashes when it tries to load the newly built library. The Fix: Change the Temporary Directory You can tell pip to use a different directory for building that has execution permissions (like your home directory or /var/tmp). Why nnpy specifically is failing? Unlike many other packages, nnpy is a "thick" wrapper around the C-library nanomsg. It uses a tool called CFFI (C Foreign Function Interface). pip downloads the nnpy source. It creates a "virtual" build environment in /tmp. It compiles a C-extension (_cffi_backend.so). It tries to "import" that C-extension to finish the metadata generation. The Linux kernel sees the file is in a noexec zone and kills the process, resulting in the error you saw. How did you do it? change to use /var/tmp-build as TMPDIR for cffi and nnpy installation. Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com> Co-authored-by: Zhaohui Sun <94606222+ZhaohuiS@users.noreply.github.com> Signed-off-by: Lakshmi Yarramaneni <lakshmi@nexthop.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes # (issue)
nnpy package installation failed in test_copp on master image.
Type of change
Back port request
Approach
What is the motivation for this PR?
To fix the failure of nnpy package installation, the root cause is
This error—failed to map segment from shared object—is almost always caused by the /tmp partition being mounted with the noexec flag.
In many security-hardened Linux environments (like those used for SONiC), the system prevents files in /tmp from being executed. Since pip creates a temporary build environment in /tmp to compile nnpy and cffi, the installation crashes when it tries to load the newly built library.
The Fix: Change the Temporary Directory
You can tell pip to use a different directory for building that has execution permissions (like your home directory or /var/tmp).
Why nnpy specifically is failing?
The Linux kernel sees the file is in a noexec zone and kills the process, resulting in the error you saw.
How did you do it?
change to use
/var/tmp-buildasTMPDIRforcffiandnnpyinstallation.How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation