@@ -53,6 +53,11 @@ bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) {
53
53
54
54
#define K_ATOS_ENV_VAR " __check_mach_ports_lookup"
55
55
56
+ // This cannot live in `AtosSymbolizerProcess` because instances of that object
57
+ // are allocated by the internal allocator which under ASan is poisoned with
58
+ // kAsanInternalHeapMagic.
59
+ static char kAtosMachPortEnvEntry [] = K_ATOS_ENV_VAR " =000000000000000" ;
60
+
56
61
class AtosSymbolizerProcess : public SymbolizerProcess {
57
62
public:
58
63
explicit AtosSymbolizerProcess (const char *path)
@@ -69,7 +74,7 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
69
74
// We use `putenv()` rather than `setenv()` so that we can later directly
70
75
// write into the storage without LibC getting involved to change what the
71
76
// variable is set to
72
- int result = putenv (mach_port_env_var_entry_ );
77
+ int result = putenv (kAtosMachPortEnvEntry );
73
78
CHECK_EQ (result, 0 );
74
79
}
75
80
}
@@ -95,12 +100,13 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
95
100
// for our task port. We can't call `setenv()` here because it might call
96
101
// malloc/realloc. To avoid that we instead update the
97
102
// `mach_port_env_var_entry_` variable with our current PID.
98
- uptr count = internal_snprintf (mach_port_env_var_entry_ ,
99
- sizeof (mach_port_env_var_entry_ ),
103
+ uptr count = internal_snprintf (kAtosMachPortEnvEntry ,
104
+ sizeof (kAtosMachPortEnvEntry ),
100
105
K_ATOS_ENV_VAR " =%s" , pid_str_);
101
106
CHECK_GE (count, sizeof (K_ATOS_ENV_VAR) + internal_strlen (pid_str_));
102
107
// Document our assumption but without calling `getenv()` in normal
103
108
// builds.
109
+ DCHECK (getenv (K_ATOS_ENV_VAR));
104
110
DCHECK_EQ (internal_strcmp (getenv (K_ATOS_ENV_VAR), pid_str_), 0 );
105
111
}
106
112
@@ -127,9 +133,10 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
127
133
}
128
134
129
135
char pid_str_[16 ];
130
- // Space for `\0` in `kAtosEnvVar_` is reused for `=`.
131
- char mach_port_env_var_entry_[sizeof (K_ATOS_ENV_VAR) + sizeof (pid_str_)] =
132
- K_ATOS_ENV_VAR " =0" ;
136
+ // Space for `\0` in `K_ATOS_ENV_VAR` is reused for `=`.
137
+ static_assert (sizeof (kAtosMachPortEnvEntry ) ==
138
+ (sizeof (K_ATOS_ENV_VAR) + sizeof (pid_str_)),
139
+ " sizes should match" );
133
140
};
134
141
135
142
#undef K_ATOS_ENV_VAR
0 commit comments