mesonbuild / mesonbuild/meson

Sandbox Violation Error Due to Subproject Folder Name Clashing with Subdirectory Name

Open
#13,005 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

**Describe the bug**
I've encountered an issue where Meson reports a "Sandbox violation" error during the build process of a subproject when the subproject folder name specified in the root meson.build file is the same as the name of a subdirectory within the subproject. This naming clash seems to confuse Meson, leading to erroneous sandbox violation errors, even though the file structure and references are correctly set up. Renaming the subproject folder to a different name resolves the issue, suggesting that Meson might be mistakenly conflating the two due to the name similarity.

The following error is reported by Meson:
`code/proj1/code/meson.build:8:0: ERROR: Sandbox violation: Tried to grab file main.c from a nested subproject.`

**To Reproduce**
1. Define a project in the root meson.build file, using a directory name that is also used by a subdirectory within one of the subprojects.
2. Attempt to build the project.

**Expected behavior**
Meson should differentiate between the subproject directory specified in the root meson.build and subdirectories within subprojects, even when they share the same name. The current behavior suggests a namespace collision that could lead to confusion and errors in projects with nested structures.

**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)? -> Plain
* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) -> Ubuntu 22.04
* what Python version are you using e.g. 3.8.0 -> 3.11
* what `meson --version` -> 1.2.1
* what `ninja --version` if it's a Ninja build -> 1.11.1

Here's an overview of the project structure that led to the issue (simplified for clarity):
```
.
├── code # Name used for the subproject directory in root meson.build
│ ├── proj1
│ │ ├── code # Subdirectory within proj1 that also uses the name 'code'
│ │ │ ├── include
│ │ │ │ └── [headers...]
│ │ │ ├── src
│ │ │ │ └── main.c
│ │ │ └── meson.build # This build file attempts to include 'src/main.c'
│ │ └── meson.build # Subproject definition, includes subdir('code')
│ ├── proj2-lib
│ └── proj3-lib
└── meson.build # Root build file, where 'code' is specified as the subproject_dir
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the plain native build using the root meson.build, code/proj1/meson.build, and code/proj1/code/meson.build structure, including src/main.c. Start by tracing how subproject_dir and subdir('code') are resolved, then confirm the build no longer reports a sandbox violation when the names collide. Use the reported Meson 1.2.1 and Ninja 1.11.1 versions as a baseline.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.