[sr-dev] [kamailio/kamailio] shm_malloc to align on __alignof__(_max_align_t) like malloc = 16 bytes (Issue #3157)

space88man notifications at github.com
Mon Jun 20 13:16:00 CEST 2022



### Description
I am creating a module that uses a 3rd party library(wolfSSL), that depending on build flags,
requires alignment of memory blocks to be the same as `malloc`, i.e., 16 bytes on gcc/AMD64.

It seems that `shm_malloc` returns memory aligned to 8 bytes.

Since system malloc always returns 16-byte aligned memory, it might be good to match that
behaviour in `shm_malloc` in case future kamailio modules use libraries that expect this.

### Expected behavior

`shm_malloc` returns memory aligned on `__alignof__(_max_align_t) == 16`

#### Actual observed behavior

`shm_malloc` returns blocks aligned on 8-bytes

#### Debugging Data
When allocating `*SSL_CTX` and `*SSL ` structs by tls module they occassionally will
have 8 byte (and not necessarily 16-byte) alignments. OpenSSL does not require 16-byte alignments
but wolfSSL requires 16-byte alignments.


### Possible Solutions

* The custom memory allocators in  WIP `tls_wolfssl/` could try to wrap around `shm_malloc`.
* have a static build of wolfSSL that does not require 16-byte alignment

### Additional Information

The default `./configure` build of wolfSSL has structs that require 16-byte alignment.
wolfSSL library has a configure flag `--enable-aligndata=no` that relaxes this requirement.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3157
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/3157 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20220620/15200e20/attachment.htm>


More information about the sr-dev mailing list