Alignment used by dlmalloc is not correct (AFAICT)

オープン
#249 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
c, wasm

調査の方向性

まず、引用されている MALLOC_ALIGNMENT と 8-byte の調整行がある dlmalloc/src/malloc.c を読んでください。リンクされている Emscripten issue と LLVM review を確認し、提案されている3つの選択肢と、それらが標準に及ぼす影響を理解してください。1つのアプローチが選択され、malloc のアライメント動作が標準に準拠した時点で作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

Today dlmalloc has hardcoded MALLOC_ALIGNMENT of 2*pointer size:
https://github.com/WebAssembly/wasi-libc/blob/3c4a3f94d1ce685a672ec9a642f1ae42dae16eb1/dlmalloc/src/malloc.c#L628

Emscripten has had the same issue basically forever, but its not standards compliant and is causing issues for some codebases that assume malloc returns things that are aligned to alignof(max_align_t). See https://github.com/emscripten-core/emscripten/issues/10072.

We've discussed several ways to address this, the most obvious being to increase the alignment used by dlmalloc to 16 bytes. However, we are also looking and reducing the alignment of max_align_t instead: https://reviews.llvm.org/D104808
The rational being that increasing malloc alignment does have some size and performance costs associated with it. Also, dlmalloc seems to be tuned for 8 bytes allignment:

https://github.com/WebAssembly/wasi-libc/blob/3c4a3f94d1ce685a672ec9a642f1ae42dae16eb1/dlmalloc/src/malloc.c#L252-L253

So, the choices seem like:

  1. Leave everything as is and accept non-conforming malloc.
  2. Increase alignment used by dlmalloc.
  3. Decrease the alignment of long double.
主要言語
C
スター
1k
フォーク
268
平均マージ
1日 3時間
マージ済み PR(30日)
20

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WebAssembly/wasi-libc のほかの issue

WebAssembly/wasi-libc の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。