On Thursday, May 14, 2015 02:01:26 PM Isaiah Norton wrote:
> As far as I can tell, we don't store this information [1] -- mmap_array
> simply calls pointer_to_array [2] on the address returned by mmap, and at
> that point the array is just like any other created from a pointer.
>
> Your idea to to try writing to the array may actually be the least
> heavy-handed possibility I can think of! But for the sake of
> ...completeness... here are a few other ideas:
>
> - mmap_array attaches a finalizer to the object. I don't think we have an
> API to look at finalizers right now, but we could potentially add a few
> lines of C code in gc.c to introspect whether a finalizer is attached to an
> object, then see whether that finalizer is calling Libdl.munmap.
>
> - find an API that allows to check whether a pointer is mmap'd
> (unfortunately I didn't see an obvious candidate in a quick scan of the
> POSIX shm docs)
>
> - relatedly: on Linux, you could look at /proc/PID/maps and see if the
> pointer comes from one of those regions (see e.g. [4])
>
> [1]
https://github.com/JuliaLang/julia/blob/master/src/julia.h#L151-L162
> [2]
>
https://github.com/JuliaLang/julia/blob/861f02712eb4b41c08fed3f21c5a4206b8d6
> 69bc/base/mmap.jl#L78 [3]
>
https://github.com/JuliaLang/julia/blob/861f02712eb4b41c08fed3f21c5a4206b8d6