1 |
Hi, |
2 |
|
3 |
I was trying to run clang (built specifically for musl) on a chroot |
4 |
musl system, and met some strange issue. After some investigation, it |
5 |
turns out the function realpath() is giving me wrong results. |
6 |
|
7 |
I can reproduce the error with the following code snippet: |
8 |
|
9 |
#include <stdio.h> |
10 |
#include <stdlib.h> |
11 |
#include <limits.h> |
12 |
|
13 |
int main(int argc, char** argv) { |
14 |
const char* path = "/usr/bin/clang"; // suppose this is a valid path |
15 |
char resolved[PATH_MAX]; |
16 |
char* ret = realpath(path, resolved); |
17 |
|
18 |
if (ret) |
19 |
printf("%s\n", ret); |
20 |
} |
21 |
|
22 |
If I build it against musl, it gives correct result on my host, but |
23 |
wrong result on chroot; If I build it against glibc (statically, since |
24 |
there's no glibc on chroot), it gives correct results on both |
25 |
environments. So it looks like musl is to blame on the chroot |
26 |
environment. I haven't yet confirmed if it's a bug. |
27 |
|
28 |
Any thoughts? |
29 |
|
30 |
BTW, I built my musl system with the GRS tool, using the |
31 |
desktop-amd64-musl-hardened profile. |
32 |
|
33 |
|
34 |
Regards, |
35 |
Lei |