[tor-bugs] #23882 [Core Tor/Tor]: Investigate implementing a Rust allocator wrapping tor_malloc

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Aug 10 16:04:01 UTC 2018


#23882: Investigate implementing a Rust allocator wrapping tor_malloc
-------------------------------------------------+-------------------------
 Reporter:  isis                                 |          Owner:  (none)
     Type:  enhancement                          |         Status:  new
 Priority:  High                                 |      Milestone:  Tor:
                                                 |  0.3.6.x-final
Component:  Core Tor/Tor                         |        Version:  Tor:
                                                 |  0.3.2.2-alpha
 Severity:  Normal                               |     Resolution:
 Keywords:  rust, rust-pilot,                    |  Actual Points:
  034-triage-20180328, 034-removed-20180328      |
Parent ID:                                       |         Points:  3
 Reviewer:                                       |        Sponsor:
                                                 |  Sponsor8-can
-------------------------------------------------+-------------------------

Comment (by cypherpunks3):

 Implementing `GlobalAlloc::alloc` requires respecting the alignment in the
 Layout that's passed to it, and right now there isn't an API for
 allocating aligned memory.

 So first gotta add something like `tor_aligned_alloc` that uses
 `aligned_alloc` (C11), `_aligned_malloc` (Windows), or `posix_memalign` or
 `memalign`. And you'd have to make the original `tor_malloc` forward to
 the new function, too, it can't keep calling `malloc`.

 At least it seemingly can't on Windows, because pointers returned by
 `_aligned_malloc` have to be freed with `_aligned_free`. The docs say
 [https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/aligned-
 malloc Using free is illegal.] And there'd be no way to distinguish which
 pointers were allocated by which.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23882#comment:11>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list