Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HXCPP_GC_MOVING in combination with HXCPP_ALIGN_ALLOC #1167

Open
sannyun opened this issue Dec 18, 2024 · 0 comments
Open

HXCPP_GC_MOVING in combination with HXCPP_ALIGN_ALLOC #1167

sannyun opened this issue Dec 18, 2024 · 0 comments

Comments

@sannyun
Copy link

sannyun commented Dec 18, 2024

When I run the following program built with HXCPP_GC_MOVING and HXCPP_ALIGN_ALLOC flags enabled, I get a segmentation fault. Commenting out one of them fixes the problem. Moreover , removing these lines solves the problem, too.

System info

  • haxe 4.3.6
  • hxcpp 4.3.68
  • clang 19.1.4
  • macOS Sequoia 15.1.1

Main.hx

class Point {
	public function new(x: Int, y: Int) {
		this.x = x;
		this.y = y;
	}
	
	public var x: Int;
	public var y: Int;
}

final ITERATIONS = 10000000;

class Main {
	private static final array: Array<Point> = [];
	
	public static function addPoint(): Void {
		array.push(new Point(array.length, array.length));
	}
	
	public static function main(): Void {
		for (i in 0...ITERATIONS) {
			addPoint();
		}

		final halfSize = Std.int(array.length / 2);
		
		array.resize(halfSize);
		for (i in 0...halfSize) {
			addPoint();
		}

		var idx = Std.int(Math.random() * array.length);
		trace('$idx == ${array[idx].x}');
	}
}

build.hxml

-D HXCPP_GC_MOVING
-D HXCPP_ALIGN_ALLOC
-D HXCPP_API_LEVEL=430

-main Main
--cpp build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant