Commit 13d775f
committed
Make ReadOnlyError on PROT_NONE consistent
This replaces #36625. Essentially the question is what should
reading from PROT_NONE memory do. At the moment we throw
ReadOnlyMemoryError on Linux and pass through the segfault on
Windows/Mac. It's not super clear what the right answer is,
though it would be nice to be consistent. After some discussion,
it seemed that not throwing ReadOnlyMemoryError on Linux was probably
the better consistency direction for two reasons:
1. Getting a ReadOnlyMemoryError is confusing if the failing operation
is a read. We could of course rename the error, but that would be
a bigger breaking change.
2. The purpose of this exception is to protect people who accidentally
try to write to mmap'ed memory that they don't have write permissions
to. It was never intended to become a general memory access error
exception, so it seems prudent to restrict it as much as possible.
To make this happen, there is some platform specific code here to
read the memory error register out of the signal context.
Decoding this register is shared code between the operating systems,
but the register itself is in an OS-specifc location in the signal
frame. I have implemented the retrieval code for all our CI'ed
platforms. Other users will get an appropriate `#warning` (similar
to other code in this file) and can fill in the necessary code
at their leisure. A new test in test/misc.jl will indicate whether
or not the check is correct.1 parent 8e949d6 commit 13d775f
3 files changed
+91
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 149 | | |
156 | 150 | | |
157 | 151 | | |
| |||
167 | 161 | | |
168 | 162 | | |
169 | 163 | | |
| 164 | + | |
170 | 165 | | |
171 | 166 | | |
172 | 167 | | |
173 | 168 | | |
174 | | - | |
175 | 169 | | |
176 | 170 | | |
177 | 171 | | |
| |||
180 | 174 | | |
181 | 175 | | |
182 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
| |||
279 | 288 | | |
280 | 289 | | |
281 | 290 | | |
282 | | - | |
283 | | - | |
| 291 | + | |
| 292 | + | |
284 | 293 | | |
285 | 294 | | |
286 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
228 | 250 | | |
229 | 251 | | |
230 | 252 | | |
231 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
232 | 292 | | |
233 | 293 | | |
234 | 294 | | |
| |||
273 | 333 | | |
274 | 334 | | |
275 | 335 | | |
276 | | - | |
| 336 | + | |
277 | 337 | | |
278 | 338 | | |
279 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
952 | 952 | | |
953 | 953 | | |
954 | 954 | | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
0 commit comments