The problem with the free function when using cmos via scons compilation

4.4

guys, I have a problem, when I compiled my build for the web via scons, I got this error New Game Project.js:7 Uncaught RuntimeError: Aborted(free() called but not included in the build - add _free to EXPORTED_FUNCTIONS)
at abort (New Game Project.js:7:8720)
at _free (New Game Project.js:7:2698)
at Object.free (New Game Project.js:7:135576)
at AudioBufferSourceNode._onended (New Game Project.js:7:149883) please help me if necessary, here is my compilation code “C:\emsdk\python\3.9.2-nuget_64bit\Scripts\scons.exe” platform=web debug_symbols=no target=template_release lto=full optimize=size module_text_server_adv_enabled=no module_text_server_fb_enabled=yes disable_3d=yes module_basis_universal_enabled=no module_bmp_enabled=no module_camera_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_jsonrpc_enabled=no module_ktx_enabled=no module_meshoptimizer_enabled=no module_mobile_vr_enabled=no module_msdfgen_enabled=no module_multiplayer_enabled=no module_noise_enabled=no module_navigation_enabled=no module_openxr_enabled=no module_raycast_enabled=no module_regex_enabled=no module_squish_enabled=no module_svg_enabled=no module_tga_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_webrtc_enabled=no module_webxr_enabled=no threads=no

1 Like

same spend the whole compiling
it crashes with the same error
my custom.py:
target=“template_release”
threads=“no”
optimize=“size”
lto=“full”

1 Like

I have the same issue.

What I did:

git clone https://github.com/godotengine/godot.git -b 4.4.1-stable

cd godot
scons target=template_release threads=no platform=web

Then copy godot.web.template_release.wasm32.nothreads.zip to my Godot project, and set it as custom_template/release for the web export.

After exporting and running the Node.js server, I got the following error in the Firefox console:

Uncaught RuntimeError: Aborted(free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS)
    abort index.js:formatted:375
    _free index.js:formatted:102
    free index.js:formatted:6413
    _onended index.js:formatted:7054
    _addEndedListener index.js:formatted:7065
    SampleNode index.js:formatted:6865
    create index.js:formatted:6838
    start_sample index.js:formatted:7368
    _godot_audio_sample_start index.js:formatted:7588
    button_cb index.js:formatted:9268
    add index.js:formatted:7939
    _godot_js_input_mouse_button_cb index.js:formatted:9273
    Godot index.js:formatted:395
    callMain index.js:formatted:12625
    Engine index.js:formatted:13540
    Engine index.js:formatted:13534
    promise callback*start index.js:formatted:13506
    Engine index.js:formatted:13578
    promise callback*startGame index.js:formatted:13577
    <anonymous> index.html:203
    <anonymous> index.html:217
1 Like

The exception is raised by the line GodotRuntime.free(idCharPtr) from the following code block:

switch (self.getSample().loopMode) {
      case 'disabled':
      {
          const id = this.id;
          self.stop();
          if (GodotAudio.sampleFinishedCallback != null) {
            const idCharPtr = GodotRuntime.allocString(id);
            GodotAudio.sampleFinishedCallback(idCharPtr);
            GodotRuntime.free(idCharPtr)
          }
      }
      break;
      case 'forward':
      case 'backward':
        self.restart();
        break;
      default:
}
1 Like

This is also happening to me, but only if I compile on a Github Actions workflow running on Ubuntu 24.04. If I compile a build on my local Windows 11 machine (using the same versions of python, emscripten and scons) this error does not happen. I made sure not to remove Audio stuff from the custom build profile file. I even tried just removing 3D features, navigation, and vulkan and the same crash happened. My custom build profile looks like this:

{
	"disabled_build_options": {
		"disable_3d": true,
		"disable_3d_physics": true,
		"disable_navigation": true,
		"openxr": false,
		"vulkan": false
	},
	"disabled_classes": [],
	"type": "build_profile"
}

And I execute SCons like this:

 scons platform=web target=template_release optimize=size use_volk=no \
              tools=no deprecated=no threads=no \
              build_profile=/path/to/my/custom/build/profile.build

I also tried without deprecated=no. That didn’t solve the problem.

I noticed these warnings during compilation:

In file included from core/string/ustring.cpp:31:
core/string/ustring.h:683:22: warning: implicit conversion from 'const char16_t' to 'const char32_t' may change the meaning of the represented code unit [-Wcharacter-conversion]
  683 |                 const char32_t l = *l_ptr;
      |                                ~   ^~~~~~
core/string/ustring.cpp:100:9: note: in instantiation of function template specialization 'is_str_less<char16_t, char16_t>' requested here
  100 |         return is_str_less(get_data(), p_right.get_data());
      |                ^
In file included from core/string/ustring.cpp:31:
core/string/ustring.h:684:22: warning: implicit conversion from 'const char16_t' to 'const char32_t' may change the meaning of the represented code unit [-Wcharacter-conversion]
  684 |                 const char32_t r = *r_ptr;
      |                                ~   ^~~~~~

Not sure if they are related.

2 Likes

Took a peek to the github actions worflows of godotengine/godot. I noticed they used a different version of emscripten, so I changed the version on my github actions to match theirs (3.1.64). I was using version 4.x.x. That’s all it took to solve this problem. Now I’m able to play my web game without that pesky crash!