Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Calling Gc.compact() in cppia collects the current CppiaClosure/ScriptCallable?

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

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

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

評価

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

調査の方向性

まず、hxcpp_set_top_of_stack() と hxRunLibrary() から Module.fromData、module.boot()、Type.createInstance、Reflect.callMethod、Gc.compact() までの報告されたシーケンスを再現します。cppia メソッドが戻った後のクラッシュを、compact() を削除した場合と比較します。closure が引き続き使用可能であること、またはサポートされる制限と必要な修正が確定すれば完了です。

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

説明

I am not even sure if the title correctly describes the issue. But it seems to be the case for what I am seeing.

Looking at the stack trace below it seems like the function variable magically becomes null, while it was still usable 2 lines above (function->runFunctionClosure(ctx);)

Image

What I notice is that there is a cpp.vm.Gc.compact() call inside the cppia function. Removing such call seems to fix the problem.

The setup is a bit complex to be isolated. So for now I am going to first describe the setup with text and see if there any insights and I hope it is some obvious gc usage issue. The following logic all happens in the same non-haxe thread:

  1. Haxe is used as a library in a c++ project and it is initialized with:
    hxcpp_set_top_of_stack();
    const char *err = hxRunLibrary();
    
  2. cppia bytecode is loaded and stored in a Haxe static variable
    module = cpp.cppia.Module.fromData(bytes);
    module.boot();
    
  3. a class defined in cppia is initialized (Type.createInstance(module.resolveClass(name))) and a instance method is invoked via Reflect.callMethod
  4. in such instance method cpp.vm.Gc.compact() is called
  5. the crash in the screenshot happens, after the cppia method returns

Info:
macos: 15 (arm64)
haxe: 4.3.6
hxcpp: git (96875093ec43e48dc2e1da95b8730e0c122ae017)

主要言語
C++
スター
329
フォーク
230
平均マージ
2日 8時間
マージ済み PR(30日)
5

環境構築

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

はじめの一歩

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

HaxeFoundation/hxcpp のほかの issue

HaxeFoundation/hxcpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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