@bldrs-ai/conway 1.497.1417 → 1.498.1418

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ var import_node_process = require("node:process");
30
30
  var readline = __toESM(require("node:readline"), 1);
31
31
 
32
32
  // compiled/src/version/version.js
33
- var versionString = "Conway v1.497.1417";
33
+ var versionString = "Conway v1.498.1418";
34
34
 
35
35
  // compiled/dependencies/conway-geom/interface/conway_geometry.js
36
36
  var wasmType = "";
@@ -14965,7 +14965,7 @@ ${t5.join("\n")}` : "";
14965
14965
  var import_process = require("process");
14966
14966
 
14967
14967
  // compiled/src/version/version.js
14968
- var versionString = "Conway v1.497.1417";
14968
+ var versionString = "Conway v1.498.1418";
14969
14969
 
14970
14970
  // compiled/dependencies/conway-geom/interface/conway_geometry.js
14971
14971
  function pThreadsAllowed() {
@@ -87845,6 +87845,77 @@ var IfcSceneBuilder = class {
87845
87845
  }
87846
87846
  };
87847
87847
 
87848
+ // compiled/src/core/wasm_heap.js
87849
+ function describeHeap(wasmModule, arrayPtr, numBytes) {
87850
+ const heap = wasmModule.HEAPU8;
87851
+ const buffer = heap?.buffer;
87852
+ const shared = typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
87853
+ const kind = buffer === void 0 ? "none" : shared ? "SharedArrayBuffer" : "ArrayBuffer";
87854
+ const extensible = shared ? buffer?.growable : buffer?.resizable;
87855
+ return `ptr ${arrayPtr} + ${numBytes} bytes, heap view length ${heap?.length}, buffer ${kind} byteLength ${buffer?.byteLength}, extensible ${extensible}`;
87856
+ }
87857
+ function arrayToWasmHeap(wasmModule, array) {
87858
+ const numBytes = array.length * array.BYTES_PER_ELEMENT;
87859
+ const arrayPtr = wasmModule._malloc(numBytes) >>> 0;
87860
+ if (arrayPtr === 0 && numBytes > 0) {
87861
+ throw new Error(`wasm _malloc returned an unusable address for ${numBytes} bytes - ` + describeHeap(wasmModule, arrayPtr, numBytes));
87862
+ }
87863
+ const heapBuffer = wasmModule.HEAPU8.buffer;
87864
+ if (arrayPtr + numBytes > heapBuffer.byteLength) {
87865
+ const description = describeHeap(wasmModule, arrayPtr, numBytes);
87866
+ releaseQuietly(() => wasmModule._free(arrayPtr));
87867
+ throw new Error(`wasm heap allocation lies outside the heap view - the view is stale or the heap grew without it. ${description}`);
87868
+ }
87869
+ const destination = new Uint8Array(heapBuffer, arrayPtr, numBytes);
87870
+ destination.set(new Uint8Array(array.buffer, array.byteOffset, numBytes));
87871
+ return arrayPtr;
87872
+ }
87873
+ function arraysToWasmHeap(wasmModule, arrays) {
87874
+ const pointers = [];
87875
+ try {
87876
+ for (const array of arrays) {
87877
+ pointers.push(arrayToWasmHeap(wasmModule, array));
87878
+ }
87879
+ } catch (error) {
87880
+ for (const pointer of pointers) {
87881
+ releaseQuietly(() => wasmModule._free(pointer));
87882
+ }
87883
+ throw error;
87884
+ }
87885
+ return pointers;
87886
+ }
87887
+ function releaseQuietly(release) {
87888
+ try {
87889
+ release();
87890
+ } catch (error) {
87891
+ logger_default.debug(`wasm resource release failed during teardown: ${error instanceof Error ? error.message : error}`);
87892
+ }
87893
+ }
87894
+ function withRelease(body, release) {
87895
+ let result;
87896
+ try {
87897
+ result = body();
87898
+ } catch (error) {
87899
+ releaseQuietly(release);
87900
+ throw error;
87901
+ }
87902
+ release();
87903
+ return result;
87904
+ }
87905
+ function freeAll(wasmModule, pointers) {
87906
+ let firstFailure;
87907
+ for (const pointer of pointers) {
87908
+ try {
87909
+ wasmModule._free(pointer);
87910
+ } catch (error) {
87911
+ firstFailure ??= error;
87912
+ }
87913
+ }
87914
+ if (firstFailure !== void 0) {
87915
+ throw firstFailure;
87916
+ }
87917
+ }
87918
+
87848
87919
  // compiled/src/ifc/ifc_parser_quirks.js
87849
87920
  var MATERIAL_RELATED_OBJECTS_PERMISSIVE = true;
87850
87921
  var REFLECTANCE_METHOD_PERMISSIVE = true;
@@ -88294,32 +88365,42 @@ var IfcGeometryExtraction = class _IfcGeometryExtraction {
88294
88365
  polygonalFaceBufferOffsets.push(allIndices.length);
88295
88366
  startIndicesBufferOffsets.push(allStartIndices.length);
88296
88367
  const indicesArray = allIndices.view;
88297
- const indicesArrayPtr = this.arrayToWasmHeap(indicesArray);
88298
88368
  const startIndicesArray = allStartIndices.view;
88299
- const startIndicesArrayPtr = this.arrayToWasmHeap(startIndicesArray);
88300
88369
  const polygonalFaceBufferOffsetsArray = polygonalFaceBufferOffsets.view;
88301
- const polygonalFaceBufferOffsetsArrayPtr = this.arrayToWasmHeap(polygonalFaceBufferOffsetsArray);
88302
88370
  const startIndicesBufferOffsetsArray = startIndicesBufferOffsets.view;
88303
- const startIndicesBufferOffsetsArrayPtr = this.arrayToWasmHeap(startIndicesBufferOffsetsArray);
88304
- const polygonalFaceVector = this.wasmModule.buildIndexedPolygonalFaceVector(indicesArrayPtr, indicesArray.length, startIndicesArrayPtr, polygonalFaceBufferOffsetsArrayPtr, polygonalFaceBufferOffsetsArray.length, startIndicesBufferOffsetsArrayPtr, startIndicesBufferOffsetsArray.length);
88305
- const pointsParseBuffer = this.conwayModel.nativeParseBuffer();
88306
- if (!entity.Coordinates.extractParseBuffer(0, 0, 0, pointsParseBuffer, this.wasmModule, true)) {
88307
- pointsParseBuffer.resize(0);
88308
- }
88309
- const pointsArrayNative = this.wasmModule.parseVertexVector(pointsParseBuffer);
88310
- this.conwayModel.freeParseBuffer(pointsParseBuffer);
88311
- const parameters = {
88312
- indicesPerFace,
88313
- points: pointsArrayNative,
88314
- faces: polygonalFaceVector
88315
- };
88316
- const geometry = this.conwayModel.getPolygonalFaceSetGeometry(parameters);
88317
- pointsArrayNative.delete();
88318
- this.wasmModule._free(indicesArrayPtr);
88319
- this.wasmModule._free(startIndicesArrayPtr);
88320
- this.wasmModule._free(polygonalFaceBufferOffsetsArrayPtr);
88321
- this.wasmModule._free(startIndicesBufferOffsetsArrayPtr);
88322
- polygonalFaceVector.delete();
88371
+ const [indicesArrayPtr, startIndicesArrayPtr, polygonalFaceBufferOffsetsArrayPtr, startIndicesBufferOffsetsArrayPtr] = arraysToWasmHeap(this.wasmModule, [
88372
+ indicesArray,
88373
+ startIndicesArray,
88374
+ polygonalFaceBufferOffsetsArray,
88375
+ startIndicesBufferOffsetsArray
88376
+ ]);
88377
+ const geometry = withRelease(
88378
+ () => {
88379
+ const polygonalFaceVector = this.wasmModule.buildIndexedPolygonalFaceVector(indicesArrayPtr, indicesArray.length, startIndicesArrayPtr, polygonalFaceBufferOffsetsArrayPtr, polygonalFaceBufferOffsetsArray.length, startIndicesBufferOffsetsArrayPtr, startIndicesBufferOffsetsArray.length);
88380
+ return withRelease(() => {
88381
+ const pointsParseBuffer = this.conwayModel.nativeParseBuffer();
88382
+ const pointsArrayNative = withRelease(() => {
88383
+ if (!entity.Coordinates.extractParseBuffer(0, 0, 0, pointsParseBuffer, this.wasmModule, true)) {
88384
+ pointsParseBuffer.resize(0);
88385
+ }
88386
+ return this.wasmModule.parseVertexVector(pointsParseBuffer);
88387
+ }, () => this.conwayModel.freeParseBuffer(pointsParseBuffer));
88388
+ return withRelease(() => this.conwayModel.getPolygonalFaceSetGeometry({
88389
+ indicesPerFace,
88390
+ points: pointsArrayNative,
88391
+ faces: polygonalFaceVector
88392
+ }), () => pointsArrayNative.delete());
88393
+ }, () => polygonalFaceVector.delete());
88394
+ },
88395
+ // freeAll, not four statements in one closure: there the first failure
88396
+ // would abandon the other three.
88397
+ () => freeAll(this.wasmModule, [
88398
+ indicesArrayPtr,
88399
+ startIndicesArrayPtr,
88400
+ polygonalFaceBufferOffsetsArrayPtr,
88401
+ startIndicesBufferOffsetsArrayPtr
88402
+ ])
88403
+ );
88323
88404
  const canonicalMesh = {
88324
88405
  type: CanonicalMeshType.BUFFER_GEOMETRY,
88325
88406
  geometry,
@@ -88435,12 +88516,7 @@ var IfcGeometryExtraction = class _IfcGeometryExtraction {
88435
88516
  * @return {number} Pointer/memory address
88436
88517
  */
88437
88518
  arrayToWasmHeap(array) {
88438
- const bytesPerElement = array.BYTES_PER_ELEMENT;
88439
- const numBytes = array.length * bytesPerElement;
88440
- const arrayPtr = this.wasmModule._malloc(numBytes);
88441
- const arrayWasm = new Uint8Array(this.wasmModule.HEAPU8.buffer, arrayPtr, numBytes);
88442
- arrayWasm.set(new Uint8Array(array.buffer, array.byteOffset, numBytes));
88443
- return arrayPtr;
88519
+ return arrayToWasmHeap(this.wasmModule, array);
88444
88520
  }
88445
88521
  /**
88446
88522
  * @param array
@@ -15943,7 +15943,7 @@ var ParsingBuffer = class {
15943
15943
  };
15944
15944
 
15945
15945
  // compiled/src/version/version.js
15946
- var versionString = "Conway v1.497.1417";
15946
+ var versionString = "Conway v1.498.1418";
15947
15947
 
15948
15948
  // compiled/dependencies/conway-geom/interface/conway_geometry.js
15949
15949
  function pThreadsAllowed() {
@@ -80882,6 +80882,39 @@ var ExtractResult;
80882
80882
  ExtractResult2[ExtractResult2["INVALID_STEP"] = 4] = "INVALID_STEP";
80883
80883
  })(ExtractResult || (ExtractResult = {}));
80884
80884
 
80885
+ // compiled/src/core/wasm_heap.js
80886
+ function describeHeap(wasmModule, arrayPtr, numBytes) {
80887
+ const heap = wasmModule.HEAPU8;
80888
+ const buffer = heap?.buffer;
80889
+ const shared = typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
80890
+ const kind = buffer === void 0 ? "none" : shared ? "SharedArrayBuffer" : "ArrayBuffer";
80891
+ const extensible = shared ? buffer?.growable : buffer?.resizable;
80892
+ return `ptr ${arrayPtr} + ${numBytes} bytes, heap view length ${heap?.length}, buffer ${kind} byteLength ${buffer?.byteLength}, extensible ${extensible}`;
80893
+ }
80894
+ function arrayToWasmHeap(wasmModule, array) {
80895
+ const numBytes = array.length * array.BYTES_PER_ELEMENT;
80896
+ const arrayPtr = wasmModule._malloc(numBytes) >>> 0;
80897
+ if (arrayPtr === 0 && numBytes > 0) {
80898
+ throw new Error(`wasm _malloc returned an unusable address for ${numBytes} bytes - ` + describeHeap(wasmModule, arrayPtr, numBytes));
80899
+ }
80900
+ const heapBuffer = wasmModule.HEAPU8.buffer;
80901
+ if (arrayPtr + numBytes > heapBuffer.byteLength) {
80902
+ const description = describeHeap(wasmModule, arrayPtr, numBytes);
80903
+ releaseQuietly(() => wasmModule._free(arrayPtr));
80904
+ throw new Error(`wasm heap allocation lies outside the heap view - the view is stale or the heap grew without it. ${description}`);
80905
+ }
80906
+ const destination = new Uint8Array(heapBuffer, arrayPtr, numBytes);
80907
+ destination.set(new Uint8Array(array.buffer, array.byteOffset, numBytes));
80908
+ return arrayPtr;
80909
+ }
80910
+ function releaseQuietly(release) {
80911
+ try {
80912
+ release();
80913
+ } catch (error) {
80914
+ logger_default.debug(`wasm resource release failed during teardown: ${error instanceof Error ? error.message : error}`);
80915
+ }
80916
+ }
80917
+
80885
80918
  // compiled/src/AP214E3_2010/ap214_product_shape_map.js
80886
80919
  var AP214ProductShapeMap = class {
80887
80920
  constructor() {
@@ -82021,12 +82054,7 @@ var AP214GeometryExtraction = class _AP214GeometryExtraction {
82021
82054
  * @return {number} Pointer/memory address
82022
82055
  */
82023
82056
  arrayToWasmHeap(array) {
82024
- const bytesPerElement = array.BYTES_PER_ELEMENT;
82025
- const numBytes = array.length * bytesPerElement;
82026
- const arrayPtr = this.wasmModule._malloc(numBytes);
82027
- const arrayWasm = new Uint8Array(this.wasmModule.HEAPU8.buffer, arrayPtr, numBytes);
82028
- arrayWasm.set(new Uint8Array(array.buffer));
82029
- return arrayPtr;
82057
+ return arrayToWasmHeap(this.wasmModule, array);
82030
82058
  }
82031
82059
  /**
82032
82060
  * @param array
@@ -944,7 +944,7 @@ var EntityTypesIfcCount = 909;
944
944
  var entity_types_ifc_gen_default = EntityTypesIfc;
945
945
 
946
946
  // compiled/src/version/version.js
947
- var versionString = "Conway v1.497.1417";
947
+ var versionString = "Conway v1.498.1418";
948
948
 
949
949
  // compiled/dependencies/conway-geom/interface/conway_geometry.js
950
950
  var wasmType = "";
@@ -1 +1 @@
1
- {"version":3,"file":"ap214_geometry_extraction.d.ts","sourceRoot":"","sources":["../../../src/AP214E3_2010/ap214_geometry_extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EAEtB,OAAO,EACP,WAAW,EAOX,wBAAwB,EAMxB,aAAa,EACb,SAAS,EACT,sBAAsB,EAEtB,cAAc,EACd,iBAAiB,EAOjB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EAItB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAqB,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EAEnB,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAEL,aAAa,EAEb,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,gBAAgB,EAEhB,cAAc,EACd,eAAe,EACf,oCAAoC,EACpC,oCAAoC,EACpC,MAAM,EAEN,UAAU,EACV,eAAe,EAEf,eAAe,EACf,kBAAkB,EAGlB,KAAK,EACL,mBAAmB,EACnB,SAAS,EAIT,OAAO,EACP,mBAAmB,EACnB,IAAI,EACJ,wBAAwB,EACxB,YAAY,EAMZ,gBAAgB,EAGhB,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,WAAW,EAMX,MAAM,EACN,SAAS,EAAE,KAAK,EAEhB,QAAQ,EAOR,aAAa,EACb,uBAAuB,EAEvB,mBAAmB,EAInB,oBAAoB,EACpB,iCAAiC,EACjC,yBAAyB,EACz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
1
+ {"version":3,"file":"ap214_geometry_extraction.d.ts","sourceRoot":"","sources":["../../../src/AP214E3_2010/ap214_geometry_extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EAEtB,OAAO,EACP,WAAW,EAOX,wBAAwB,EAMxB,aAAa,EACb,SAAS,EACT,sBAAsB,EAEtB,cAAc,EACd,iBAAiB,EAOjB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EAItB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAqB,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EAEnB,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAGxD,OAAO,EAEL,aAAa,EAEb,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,gBAAgB,EAEhB,cAAc,EACd,eAAe,EACf,oCAAoC,EACpC,oCAAoC,EACpC,MAAM,EAEN,UAAU,EACV,eAAe,EAEf,eAAe,EACf,kBAAkB,EAGlB,KAAK,EACL,mBAAmB,EACnB,SAAS,EAIT,OAAO,EACP,mBAAmB,EACnB,IAAI,EACJ,wBAAwB,EACxB,YAAY,EAMZ,gBAAgB,EAGhB,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,WAAW,EAMX,MAAM,EACN,SAAS,EAAE,KAAK,EAEhB,QAAQ,EAOR,aAAa,EACb,uBAAuB,EAEvB,mBAAmB,EAInB,oBAAoB,EACpB,iCAAiC,EACjC,yBAAyB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hP"}
@@ -4,6 +4,7 @@ import { ObjectPool } from "../core/native_pool.js";
4
4
  import { MemoizationCapture, RegressionCaptureState } from "../core/regression_capture_state.js";
5
5
  import { ExtractResult } from "../core/shared_constants.js";
6
6
  import Logger from "../logging/logger.js";
7
+ import { arrayToWasmHeap } from "../core/wasm_heap.js";
7
8
  import { advanced_brep_shape_representation, advanced_face, annotation_occurrence, axis2_placement_2d, axis2_placement_3d, b_spline_curve, b_spline_curve_with_knots, b_spline_surface, b_spline_surface_with_knots, boolean_result, cartesian_point, cartesian_transformation_operator_3d, circle, colour_rgb, composite_curve, composite_curve_segment, conical_surface, context_dependent_shape_representation, conversion_based_unit, cylindrical_surface, draughting_model, edge_curve, edge_loop, ellipse, extruded_area_solid, face, face_based_surface_model, faceted_brep, fill_area_style_colour, geometric_curve_set, geometrically_bounded_2d_wireframe_representation, geometrically_bounded_wireframe_shape_representation, global_unit_assigned_context, half_space_solid, item_defined_transformation, length_unit, line, manifold_solid_brep, mapped_item, next_assembly_usage_occurrence, over_riding_styled_item, parameter_value, pcurve, placement, plane, poly_loop, polyline, pre_defined_colour, presentation_layer_assignment, product, product_definition, product_definition_shape, property_definition, rational_b_spline_curve, rational_b_spline_surface, representation_item, representation_relationship_with_transformation, seam_curve, shape_definition_representation, shape_representation, shape_representation_relationship, shell_based_surface_model, si_prefix, si_unit, spherical_surface, styled_item, surface_curve, surface_of_linear_extrusion, surface_of_revolution, surface_side, surface_style_fill_area, surface_style_rendering, surface_style_usage, toroidal_surface, trimmed_curve, trimming_preference, vertex_loop, vertex_point, view_volume, } from "./AP214E3_2010_gen/index.js";
8
9
  import EntityTypesAP214 from "./AP214E3_2010_gen/entity_types_ap214.gen.js";
9
10
  import { AP214ProductShapeMap } from "./ap214_product_shape_map.js";
@@ -589,14 +590,7 @@ export class AP214GeometryExtraction {
589
590
  * @return {number} Pointer/memory address
590
591
  */
591
592
  arrayToWasmHeap(array) {
592
- // Allocate memory for the array within the Wasm module
593
- const bytesPerElement = array.BYTES_PER_ELEMENT;
594
- const numBytes = array.length * bytesPerElement;
595
- const arrayPtr = this.wasmModule._malloc(numBytes);
596
- // Create a new Uint8Array view on the Wasm memory buffer, then set the array to it
597
- const arrayWasm = new Uint8Array(this.wasmModule.HEAPU8.buffer, arrayPtr, numBytes);
598
- arrayWasm.set(new Uint8Array(array.buffer));
599
- return arrayPtr;
593
+ return arrayToWasmHeap(this.wasmModule, array);
600
594
  }
601
595
  /**
602
596
  * @param array
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Copying JS-side arrays into the wasm heap.
3
+ *
4
+ * This lives in one place because the two geometry extractors had a copy each,
5
+ * and the copies had drifted: one honoured the source view's window and the
6
+ * other did not, and neither checked what _malloc returned. The failure modes
7
+ * are quiet enough to be worth naming here.
8
+ *
9
+ * See bldrs-ai/conway#485 for what an uninstrumented failure on this path
10
+ * costs: `Invalid typed array length: 80`, no context, and two sightings
11
+ * across two models before it could even be located.
12
+ */
13
+ /** What the wasm module exposes that this needs. Deliberately narrow. */
14
+ export interface WasmHeapModule {
15
+ _malloc(bytes: number): number;
16
+ _free(pointer: number): void;
17
+ HEAPU8: Uint8Array;
18
+ }
19
+ export type CopyableArray = Float32Array | Float64Array | Uint32Array;
20
+ /**
21
+ * Copy an array into a fresh wasm heap allocation.
22
+ *
23
+ * @param wasmModule The module to allocate in.
24
+ * @param array The data to copy. May be a view into a larger buffer.
25
+ * @return {number} Pointer to the copy, owned by the caller.
26
+ */
27
+ export declare function arrayToWasmHeap(wasmModule: WasmHeapModule, array: CopyableArray): number;
28
+ /**
29
+ * Copy several arrays into the wasm heap, all or nothing.
30
+ *
31
+ * arrayToWasmHeap throws on a failed allocation, which is the right thing on
32
+ * its own but turns a caller that allocates N buffers before freeing any into
33
+ * a leak: the throw on buffer 2 strands buffer 1, the per-record catch
34
+ * upstream moves to the next record, and the leak repeats - accelerating the
35
+ * exhaustion being reported. Callers that hold several at once use this
36
+ * instead, which frees what it took before letting the error out.
37
+ *
38
+ * @param wasmModule The module to allocate in.
39
+ * @param arrays The data to copy, in order.
40
+ * @return {number[]} Pointers in the same order, owned by the caller.
41
+ */
42
+ export declare function arraysToWasmHeap(wasmModule: WasmHeapModule, arrays: readonly CopyableArray[]): number[];
43
+ /**
44
+ * Run a resource release so it cannot replace an exception already in flight.
45
+ *
46
+ * Releases here re-enter the wasm runtime - _free, embind delete(), returning
47
+ * a pooled buffer - and they run from finally blocks that may be unwinding
48
+ * because that runtime just failed. A throw from one of them would REPLACE the
49
+ * original error, so the caller upstream would see a generic teardown failure
50
+ * instead of the diagnostic that says what actually went wrong. Losing the
51
+ * cause is strictly worse than failing to reclaim memory on a path where the
52
+ * heap is already lost.
53
+ *
54
+ * Reported at debug rather than swallowed outright, so it is still findable
55
+ * with -vv, and NOT at warning/error: this runs during teardown of an already
56
+ * failing record, where a second message would be noise on top of the one that
57
+ * matters.
58
+ *
59
+ * @param release The release step to run.
60
+ */
61
+ export declare function releaseQuietly(release: () => void): void;
62
+ /**
63
+ * Run `body`, then release - propagating a release failure on success, and
64
+ * suppressing it only when something is already being unwound.
65
+ *
66
+ * That asymmetry is the point. releaseQuietly on its own is right during
67
+ * unwinding and wrong otherwise: on the success path a teardown failure is a
68
+ * real fault with nothing competing to report it, and swallowing it would let
69
+ * a record be reported COMPLETE while its resources were never reclaimed. So
70
+ * the quiet treatment applies to exactly the case it was argued for.
71
+ *
72
+ * @param body The work that needs the resource.
73
+ * @param release How to give the resource back.
74
+ * @return {T} Whatever body returned.
75
+ */
76
+ export declare function withRelease<T>(body: () => T, release: () => void): T;
77
+ /**
78
+ * Free several pointers, independently.
79
+ *
80
+ * One failing free must not abandon the rest - batching them into a single
81
+ * statement means the first failure strands every pointer after it - and it
82
+ * must not be lost either, so the first error is re-thrown once they have all
83
+ * been attempted. Combined with withRelease that gives the wanted behaviour on
84
+ * both paths: everything is freed either way, and the failure surfaces on the
85
+ * success path while staying quiet during unwinding.
86
+ *
87
+ * @param wasmModule The module the pointers belong to.
88
+ * @param pointers The allocations to release.
89
+ */
90
+ export declare function freeAll(wasmModule: WasmHeapModule, pointers: readonly number[]): void;
91
+ //# sourceMappingURL=wasm_heap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm_heap.d.ts","sourceRoot":"","sources":["../../../src/core/wasm_heap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM,CAAA;IAChC,KAAK,CAAE,OAAO,EAAE,MAAM,GAAI,IAAI,CAAA;IAC9B,MAAM,EAAE,UAAU,CAAA;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,CAAA;AAiDrE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC3B,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,GAAI,MAAM,CAuD7D;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,SAAS,aAAa,EAAE,GAAI,MAAM,EAAE,CAqB/C;AAGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAE,OAAO,EAAE,MAAM,IAAI,GAAI,IAAI,CAW1D;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAG,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,IAAI,GAAI,CAAC,CAiBtE;AAGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACnB,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAI,IAAI,CAkBlE"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Copying JS-side arrays into the wasm heap.
3
+ *
4
+ * This lives in one place because the two geometry extractors had a copy each,
5
+ * and the copies had drifted: one honoured the source view's window and the
6
+ * other did not, and neither checked what _malloc returned. The failure modes
7
+ * are quiet enough to be worth naming here.
8
+ *
9
+ * See bldrs-ai/conway#485 for what an uninstrumented failure on this path
10
+ * costs: `Invalid typed array length: 80`, no context, and two sightings
11
+ * across two models before it could even be located.
12
+ */
13
+ import Logger from "../logging/logger.js";
14
+ /**
15
+ * Describe the heap and the request, for an error message that is actually
16
+ * actionable.
17
+ *
18
+ * The buffer's kind matters, and there are two kinds to tell apart, not one.
19
+ * conway's MT build creates its memory with `shared: true`, so its heap is a
20
+ * growable SharedArrayBuffer; single-threaded builds on emscripten 6 get a
21
+ * resizable ArrayBuffer (see decode_utf8.ts). Both cases have length-tracking
22
+ * views that extend by themselves, which is why emscripten's
23
+ * updateMemoryViews() early-returns on growth rather than rebuilding them.
24
+ *
25
+ * So both flags are reported. They have different names on the two buffer
26
+ * types, and printing only one makes every single-threaded failure look like
27
+ * the assumption has broken when it has not - which would be a false alarm
28
+ * pointing away from whatever the real cause was.
29
+ *
30
+ * @param wasmModule The module whose heap is being written to.
31
+ * @param arrayPtr The pointer _malloc returned.
32
+ * @param numBytes The size of the intended copy.
33
+ * @return {string} A description of the heap state.
34
+ */
35
+ function describeHeap(wasmModule, arrayPtr, numBytes) {
36
+ const heap = wasmModule.HEAPU8;
37
+ const buffer = heap?.buffer;
38
+ const shared = typeof SharedArrayBuffer !== "undefined" &&
39
+ buffer instanceof SharedArrayBuffer;
40
+ const kind = buffer === void 0 ? "none" :
41
+ (shared ? "SharedArrayBuffer" : "ArrayBuffer");
42
+ // Whichever flag this buffer type actually carries. Reported as one field so
43
+ // a reader does not have to know which name goes with which kind.
44
+ const extensible = shared ? buffer?.growable : buffer?.resizable;
45
+ return `ptr ${arrayPtr} + ${numBytes} bytes, ` +
46
+ `heap view length ${heap?.length}, ` +
47
+ `buffer ${kind} byteLength ${buffer?.byteLength}, ` +
48
+ `extensible ${extensible}`;
49
+ }
50
+ /**
51
+ * Copy an array into a fresh wasm heap allocation.
52
+ *
53
+ * @param wasmModule The module to allocate in.
54
+ * @param array The data to copy. May be a view into a larger buffer.
55
+ * @return {number} Pointer to the copy, owned by the caller.
56
+ */
57
+ export function arrayToWasmHeap(wasmModule, array) {
58
+ const numBytes = array.length * array.BYTES_PER_ELEMENT;
59
+ // Normalised, not rejected. _malloc is bound raw from wasmExports and
60
+ // returns i32, and every target builds with MAXIMUM_MEMORY=4GB, so a
61
+ // perfectly good address at or above 2^31 arrives here NEGATIVE. Treating
62
+ // that as a failure would hard-fail every copy once the heap passes 2GB -
63
+ // which is the memory-pressure scenario #485 is about - so it is converted
64
+ // the way emscripten's own glue does (`HEAPU32[ptr >>> 2 >>> 0]`) and used
65
+ // in that form for the bounds test, the view, the free and the message.
66
+ // Left signed it would also pass the bounds test below, since a negative
67
+ // plus numBytes is not greater than byteLength.
68
+ const arrayPtr = wasmModule._malloc(numBytes) >>> 0;
69
+ // 0 is _malloc's failure return and also a valid byteOffset, so the view
70
+ // below would be constructed happily and this would go on to write over
71
+ // whatever lives at address 0 - corrupting the heap instead of reporting
72
+ // that it is exhausted.
73
+ if (arrayPtr === 0 && numBytes > 0) {
74
+ throw new Error(`wasm _malloc returned an unusable address for ${numBytes} bytes - ` +
75
+ describeHeap(wasmModule, arrayPtr, numBytes));
76
+ }
77
+ const heapBuffer = wasmModule.HEAPU8.buffer;
78
+ // Checked rather than left to the TypedArray constructor, whose RangeError
79
+ // is just "Invalid typed array length: N" - true, unactionable, and
80
+ // indistinguishable from a dozen other causes.
81
+ if (arrayPtr + numBytes > heapBuffer.byteLength) {
82
+ const description = describeHeap(wasmModule, arrayPtr, numBytes);
83
+ // The allocation SUCCEEDED and only the view is refused, so this owns a
84
+ // pointer nobody else can reach - arraysToWasmHeap's cleanup cannot see it
85
+ // because it was never returned. Leaking here would mean leaking once per
86
+ // record, under a per-record catch, while reporting that the heap is in
87
+ // trouble.
88
+ releaseQuietly(() => wasmModule._free(arrayPtr));
89
+ throw new Error("wasm heap allocation lies outside the heap view - " +
90
+ `the view is stale or the heap grew without it. ${description}`);
91
+ }
92
+ const destination = new Uint8Array(heapBuffer, arrayPtr, numBytes);
93
+ // Honour the source view's own window: subarray() results share their
94
+ // parent's backing buffer, so copying `array.buffer` wholesale reads the
95
+ // wrong bytes, and the wrong number of them, for anything that is a view.
96
+ destination.set(new Uint8Array(array.buffer, array.byteOffset, numBytes));
97
+ return arrayPtr;
98
+ }
99
+ /**
100
+ * Copy several arrays into the wasm heap, all or nothing.
101
+ *
102
+ * arrayToWasmHeap throws on a failed allocation, which is the right thing on
103
+ * its own but turns a caller that allocates N buffers before freeing any into
104
+ * a leak: the throw on buffer 2 strands buffer 1, the per-record catch
105
+ * upstream moves to the next record, and the leak repeats - accelerating the
106
+ * exhaustion being reported. Callers that hold several at once use this
107
+ * instead, which frees what it took before letting the error out.
108
+ *
109
+ * @param wasmModule The module to allocate in.
110
+ * @param arrays The data to copy, in order.
111
+ * @return {number[]} Pointers in the same order, owned by the caller.
112
+ */
113
+ export function arraysToWasmHeap(wasmModule, arrays) {
114
+ const pointers = [];
115
+ try {
116
+ for (const array of arrays) {
117
+ pointers.push(arrayToWasmHeap(wasmModule, array));
118
+ }
119
+ }
120
+ catch (error) {
121
+ // Individually, and quietly. One free throwing must not strand the rest,
122
+ // and must not replace the allocation error being propagated.
123
+ for (const pointer of pointers) {
124
+ releaseQuietly(() => wasmModule._free(pointer));
125
+ }
126
+ throw error;
127
+ }
128
+ return pointers;
129
+ }
130
+ /**
131
+ * Run a resource release so it cannot replace an exception already in flight.
132
+ *
133
+ * Releases here re-enter the wasm runtime - _free, embind delete(), returning
134
+ * a pooled buffer - and they run from finally blocks that may be unwinding
135
+ * because that runtime just failed. A throw from one of them would REPLACE the
136
+ * original error, so the caller upstream would see a generic teardown failure
137
+ * instead of the diagnostic that says what actually went wrong. Losing the
138
+ * cause is strictly worse than failing to reclaim memory on a path where the
139
+ * heap is already lost.
140
+ *
141
+ * Reported at debug rather than swallowed outright, so it is still findable
142
+ * with -vv, and NOT at warning/error: this runs during teardown of an already
143
+ * failing record, where a second message would be noise on top of the one that
144
+ * matters.
145
+ *
146
+ * @param release The release step to run.
147
+ */
148
+ export function releaseQuietly(release) {
149
+ try {
150
+ release();
151
+ }
152
+ catch (error) {
153
+ Logger.debug(`wasm resource release failed during teardown: ${error instanceof Error ? error.message : error}`);
154
+ }
155
+ }
156
+ /**
157
+ * Run `body`, then release - propagating a release failure on success, and
158
+ * suppressing it only when something is already being unwound.
159
+ *
160
+ * That asymmetry is the point. releaseQuietly on its own is right during
161
+ * unwinding and wrong otherwise: on the success path a teardown failure is a
162
+ * real fault with nothing competing to report it, and swallowing it would let
163
+ * a record be reported COMPLETE while its resources were never reclaimed. So
164
+ * the quiet treatment applies to exactly the case it was argued for.
165
+ *
166
+ * @param body The work that needs the resource.
167
+ * @param release How to give the resource back.
168
+ * @return {T} Whatever body returned.
169
+ */
170
+ export function withRelease(body, release) {
171
+ let result;
172
+ try {
173
+ result = body();
174
+ }
175
+ catch (error) {
176
+ releaseQuietly(release);
177
+ throw error;
178
+ }
179
+ release();
180
+ return result;
181
+ }
182
+ /**
183
+ * Free several pointers, independently.
184
+ *
185
+ * One failing free must not abandon the rest - batching them into a single
186
+ * statement means the first failure strands every pointer after it - and it
187
+ * must not be lost either, so the first error is re-thrown once they have all
188
+ * been attempted. Combined with withRelease that gives the wanted behaviour on
189
+ * both paths: everything is freed either way, and the failure surfaces on the
190
+ * success path while staying quiet during unwinding.
191
+ *
192
+ * @param wasmModule The module the pointers belong to.
193
+ * @param pointers The allocations to release.
194
+ */
195
+ export function freeAll(wasmModule, pointers) {
196
+ let firstFailure;
197
+ for (const pointer of pointers) {
198
+ try {
199
+ wasmModule._free(pointer);
200
+ }
201
+ catch (error) {
202
+ firstFailure ??= error;
203
+ }
204
+ }
205
+ if (firstFailure !== void 0) {
206
+ throw firstFailure;
207
+ }
208
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wasm_heap.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm_heap.test.d.ts","sourceRoot":"","sources":["../../../src/core/wasm_heap.test.ts"],"names":[],"mappings":""}