MrcSnm/HipremeEngine

start_here: crashes out of the box for me

0xEAB opened this issue · 7 comments

0xEAB commented
$ lldb bin/desktop/hipreme_engine ./projects/start_here
(lldb) target create "bin/desktop/hipreme_engine"
Current executable set to '/_FOO_BAR/HipremeEngine/bin/desktop/hipreme_engine' (x86_64).
(lldb) settings set -- target.run-args  "./projects/start_here"
(lldb) run
Process 6917 launched: '/_FOO_BAR/HipremeEngine/bin/desktop/hipreme_engine' (x86_64)
INFO: Console installed for Platforms.DEFAULT
		source/app.d:145 at void app.initEngine
INFO: HipFS installed at path ./projects/start_here/assets
		source/app.d:147 at void app.initEngine
INFO: Starting HipRenderer with configuration: 
MultisamplingLevel: 0
BufferingCount: 2
Fullscreen: true
Vsync: activated
		modules/renderer/source/hip/hiprenderer/config.d:27 at void hip.hiprenderer.config.HipRendererConfig.logConfiguration
GL Renderer: Mesa Intel(R) Iris(R) Graphics 6100 (BDW GT3)
GL Version: 4.6 (Core Profile) Mesa 20.3.5
GLSL Version: 4.60
ERROR: Fullscreen is not implemented for this platform
		modules/renderer/source/hip/hiprenderer/renderer.d:316 at bool hip.hiprenderer.renderer.HipRenderer.initialize
Changing window size to [800, 600]
		modules/renderer/source/hip/hiprenderer/renderer.d:325 at void hip.hiprenderer.renderer.HipRenderer.setWindowSize
HIP: Loading default assets
HIP: Loaded default image
HIP: Loaded default font
HIP: 2D Renderer: Initializing viewport
HIP: 2D Renderer: Initializing camera 1
HIP: 2D Renderer: Initializing camera 2
HIP: 2D Renderer: Initializing camera 3 
HIP: 2D Renderer: Initializing camera 4
HIP: 2D Renderer: Initializing spritebatch
HIP: 2D Renderer: Initializing geometrybatch
HIP: 2D Renderer: Initializing text renderer
INFO: Loading dll ./projects/start_here/libstart_here.so
		source/hip/systems/hotload.d:55 at bool hip.systems.hotload.HotloadableDLL.load
HipengineAPI: Initialized Console
HipengineAPI: Initialized FS
Random_range wasn't able to load (tried with Random_range)
Random_rangeu wasn't able to load (tried with Random_rangeu)
Random_rangeub wasn't able to load (tried with Random_rangeub)
Random_rangef wasn't able to load (tried with Random_rangef)
HipengineAPI: Initialized Math
HipengineAPI: Initialized G2D
HipengineAPI: Initialized Audio
HipengineAPI: Initialized Input
Process 6917 stopped
* thread #1, name = 'hipreme_engine', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff7363c98)
    frame #0: 0x00007fffc68a42cb libstart_here.so_hiptempso`_D3hip3api8internal__T26loadModuleFunctionPointersSQBxQBw6assets7globalsVAyaa0_ZQCgFZv at internal.d:98:4
   95  			static if(isFunctionPointer!(f))
   96  			{
   97  				importedFunctionName = prefix~member~'\0';
-> 98  				if(f is null)
   99  				{
   100 					f = cast(typeof(f))_loadSymbol(_dll, importedFunctionName.ptr);
   101 					if(f is null)
(lldb) bt
* thread #1, name = 'hipreme_engine', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff7363c98)
  * frame #0: 0x00007fffc68a42cb libstart_here.so_hiptempso`void hip.api.internal.loadModuleFunctionPointers!(hip.api.assets.globals, "").loadModuleFunctionPointers() at internal.d:98:4
    frame #1: 0x00007fffc689c279 libstart_here.so_hiptempso`void hip.api.assets.globals.initGlobalAssets() at globals.d:10:5
    frame #2: 0x00007fffc6899315 libstart_here.so_hiptempso`HipremeEngineGameInit at package.d:72:4
    frame #3: 0x0000555555754e40 hipreme_engine`void hip.systems.game.GameSystem.startGame()(this=0x00007ffff7039d80) at game.d:207:13
    frame #4: 0x00005555557923cf hipreme_engine`void app.gameInitialize() at app.d:230:2
    frame #5: 0x00005555557922b9 hipreme_engine`void app.HipremeMain(int, int).__lambda4() at app.d:207:23
    frame #6: 0x000055555578594b hipreme_engine`bool hip.global.gamedef.loadDefaultAssets(void delegate(), void delegate(immutable(char)[]))(onSuccess=void delegate() @ 0x00007ffff703b1c8, onFailure=void delegate(string cause) @ 0x00007ffff703b1b0) at gamedef.d:81:10
    frame #7: 0x000055555579229a hipreme_engine`HipremeMain(windowWidth=-1, windowHeight=-1) at app.d:207:2
    frame #8: 0x0000555555792549 hipreme_engine`_Dmain(args=slice<string> @ 0x00007fffffffdd80) at app.d:348:3
    frame #9: 0x00007ffff79028dc libdruntime-ldc-shared.so.101`void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() + 76
    frame #10: 0x00007ffff79026f6 libdruntime-ldc-shared.so.101`_d_run_main2 + 406
    frame #11: 0x00007ffff790254e libdruntime-ldc-shared.so.101`_d_run_main + 158
    frame #12: 0x0000555555792e82 hipreme_engine`main(argc=2, argv=0x00007fffffffe068) at entrypoint.d:42:17
    frame #13: 0x00007ffff74a9d0a libc.so.6`__libc_start_main + 234
    frame #14: 0x000055555574ebea hipreme_engine`_start + 42

OS: Debian 11 “Bullseye” (LMDE 5)
Arch: x86-64
Desktop: Cinnamon on X.org

Am I doing something wrong here?
Let me know if you need further information, please.

Compiler version?

0xEAB commented

LDC - the LLVM D compiler (1.31.0):
based on DMD v2.101.2 and LLVM 14.0.3

Hummm this could be it. Could you please try on a 2.099 (LDC 1.29)?

0xEAB commented

LDC - the LLVM D compiler (1.29.0):
based on DMD v2.099.1 and LLVM 13.0.1

same issue, I’m afraid

* thread #1, name = 'hipreme_engine', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff732f068)
  * frame #0: 0x00007fffbe9e7c85 libstart_here.so_hiptempso`void hip.api.internal.loadModuleFunctionPointers!(hip.api.assets.globals, "").loadModuleFunctionPointers() at internal.d:98:4
    frame #1: 0x00007fffbe9e4969 libstart_here.so_hiptempso`void hip.api.assets.globals.initGlobalAssets() at globals.d:10:5
    frame #2: 0x00007fffbe9e22f5 libstart_here.so_hiptempso`HipremeEngineGameInit at package.d:72:4
    frame #3: 0x0000555555725230 hipreme_engine`void hip.systems.game.GameSystem.startGame()(this=0x00007ffff702dd80) at game.d:207:13
    frame #4: 0x0000555555761e3f hipreme_engine`void app.gameInitialize() at app.d:230:2
    frame #5: 0x0000555555761d29 hipreme_engine`void app.HipremeMain(int, int).__lambda4() at app.d:207:23
    frame #6: 0x000055555575592b hipreme_engine`bool hip.global.gamedef.loadDefaultAssets(void delegate(), void delegate(immutable(char)[]))(onSuccess=void delegate() @ 0x00007ffff702f1c8, onFailure=void delegate(string cause) @ 0x00007ffff702f1b0) at gamedef.d:81:10
    frame #7: 0x0000555555761d0a hipreme_engine`HipremeMain(windowWidth=-1, windowHeight=-1) at app.d:207:2
    frame #8: 0x0000555555761fb9 hipreme_engine`_Dmain(args=slice<string> @ 0x00007fffffffddc0) at app.d:348:3
    frame #9: 0x00007ffff78ee84c libdruntime-ldc-shared.so.99`void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() + 76
    frame #10: 0x00007ffff78ee666 libdruntime-ldc-shared.so.99`_d_run_main2 + 406
    frame #11: 0x00007ffff78ee4be libdruntime-ldc-shared.so.99`_d_run_main + 158
    frame #12: 0x0000555555762762 hipreme_engine`main(argc=2, argv=0x00007fffffffe0a8) at entrypoint.d:42:17
    frame #13: 0x00007ffff749dd0a libc.so.6`__libc_start_main + 234
    frame #14: 0x000055555571f37a hipreme_engine`_start + 42

Okay, I'll fix that ASAP

0xEAB commented
INFO: Console installed for Platforms.DEFAULT
		source/app.d:145 at void app.initEngine
INFO: HipFS installed at path ./projects/start_here/assets
		source/app.d:147 at void app.initEngine
INFO: Starting HipRenderer with configuration: 
MultisamplingLevel: 0
BufferingCount: 2
Fullscreen: true
Vsync: activated
		modules/renderer/source/hip/hiprenderer/config.d:27 at void hip.hiprenderer.config.HipRendererConfig.logConfiguration
GL Renderer: Mesa Intel(R) Iris(R) Graphics 6100 (BDW GT3)
GL Version: 4.6 (Core Profile) Mesa 20.3.5
GLSL Version: 4.60
ERROR: Fullscreen is not implemented for this platform
		modules/renderer/source/hip/hiprenderer/renderer.d:316 at bool hip.hiprenderer.renderer.HipRenderer.initialize
Changing window size to [800, 600]
		modules/renderer/source/hip/hiprenderer/renderer.d:325 at void hip.hiprenderer.renderer.HipRenderer.setWindowSize
HIP: Loading default assets
HIP: Loaded default image
HIP: Loaded default font
HIP: 2D Renderer: Initializing viewport
HIP: 2D Renderer: Initializing camera 1
HIP: 2D Renderer: Initializing camera 2
HIP: 2D Renderer: Initializing camera 3 
HIP: 2D Renderer: Initializing camera 4
HIP: 2D Renderer: Initializing spritebatch
HIP: 2D Renderer: Initializing geometrybatch
HIP: 2D Renderer: Initializing text renderer
INFO: Loading dll ./projects/start_here/libstart_here.so
		source/hip/systems/hotload.d:55 at bool hip.systems.hotload.HotloadableDLL.load
HipengineAPI: Initialized Console
HipengineAPI: Initialized FS
Random_range wasn't able to load (tried with Random_range)
Random_rangeu wasn't able to load (tried with Random_rangeu)
Random_rangeub wasn't able to load (tried with Random_rangeub)
Random_rangef wasn't able to load (tried with Random_rangef)
HipengineAPI: Initialized Math
HipengineAPI: Initialized G2D
HipengineAPI: Initialized Audio
HipengineAPI: Initialized Input
HipEngineAPI: Initialized Global Assets
HipengineAPI: Initialized AssetManager
HipengineAPI: Initialized TimerManager
HipengineAPI: Initialized GameUtils
WARNING: Initializing scene gamescript.entry.MainScene
		source/hip/systems/game.d:247 at hip.systems.game.GameSystem.addScene.__lambda2
Expose event
Process 15146 stopped
* thread #1, name = 'hipreme_engine', stop reason = signal SIGSEGV: invalid address (fault address: 0xd)
    frame #0: 0x000055555570eb43 hipreme_engine`_D3hip6assets7texture16HipTextureRegion9setRegionMFffffZv(this=0x00007ffff704d2c0, u1=0, v1=0, u2=0, v2=1.33161399E-38) at texture.d:184:9
   181 	        this.v1 = v1;
   182 	        this.v2 = v2;
   183 	        //Check for round
-> 184 	        float regWidth =  (u2 - u1) * texture.getWidth;
   185 	        float regHeight = (v2 - v1) * texture.getHeight;
   186 	        regionWidth =  cast(uint)(regWidth + 0.5) > cast(uint)regWidth ? cast(uint)(regWidth+0.5) : cast(uint)regWidth;
   187 	        regionHeight = cast(uint)(regHeight + 0.5) > cast(uint)regHeight ? cast(uint)(regHeight+0.5) : cast(uint)regHeight;

as promised on Discord, demangled backtrace:

* thread #1, name = 'hipreme_engine', stop reason = signal SIGSEGV: invalid address (fault address: 0xd)
  * frame #0: 0x000055555570eb43 hipreme_engine`void hip.assets.texture.HipTextureRegion.setRegion(float, float, float, float)(this=0x00007ffff704d2c0, u1=0, v1=0, u2=0, v2=1.33161399E-38) at texture.d:184:9
    frame #1: 0x000055555570eac1 hipreme_engine`hip.assets.texture.HipTextureRegion hip.assets.texture.HipTextureRegion.__ctor(hip.api.renderer.texture.IHipTexture, float, float, float, float)(this=0x00007ffff704d2c0, texture=0x000000000000000d, u1=0, v1=0, u2=0, v2=1.33161399E-38) at texture.d:117:9
    frame #2: 0x0000555555706dff hipreme_engine`hip.api.renderer.texture.IHipTextureRegion hip.assetmanager.HipAssetManager.createTextureRegion(hip.api.renderer.texture.IHipTexture, float, float, float, float)(texture=0x000000000000000d, u1=0, v1=0, u2=0, v2=1.33161399E-38) at assetmanager.d:797:9
    frame #3: 0x00005555556dc3fd hipreme_engine`HipAssetManager_createTextureRegion(texture=0x000000000000000d, u1=0, v1=0, u2=0, v2=1.33161399E-38) at mixed.d:487:13
    frame #4: 0x00007fffc6962d0f libstart_here.so_hiptempso`void gamescript.entry.MainScene.update(float)(this=0x00007ffff7057b40, dt=0) at entry.d:29:9
    frame #5: 0x000055555569fed4 hipreme_engine`bool hip.systems.game.GameSystem.update(float)(this=0x00007ffff7039d80, deltaTime=0) at game.d:290:17
    frame #6: 0x00005555556dcf52 hipreme_engine`bool app.HipremeUpdateBase() at app.d:355:2
    frame #7: 0x00005555556dce2d hipreme_engine`void app.HipremeDesktopGameLoop() at app.d:408:3
    frame #8: 0x00005555556dcdb4 hipreme_engine`void app.gameInitialize() at app.d:231:19
    frame #9: 0x00005555556dcc99 hipreme_engine`void app.HipremeMain(int, int).__lambda4() at app.d:207:23
    frame #10: 0x00005555556d032b hipreme_engine`bool hip.global.gamedef.loadDefaultAssets(void delegate(), void delegate(immutable(char)[]))(onSuccess=void delegate() @ 0x00007ffff703b1c8, onFailure=void delegate(string cause) @ 0x00007ffff703b1b0) at gamedef.d:81:10
    frame #11: 0x00005555556dcc7a hipreme_engine`HipremeMain(windowWidth=-1, windowHeight=-1) at app.d:207:2
    frame #12: 0x00005555556dcf29 hipreme_engine`_Dmain(args=slice<string> @ 0x00007fffffffdd80) at app.d:348:3
    frame #13: 0x00007ffff79028dc libdruntime-ldc-shared.so.101`void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() + 76
    frame #14: 0x00007ffff79026f6 libdruntime-ldc-shared.so.101`_d_run_main2 + 406
    frame #15: 0x00007ffff790254e libdruntime-ldc-shared.so.101`_d_run_main + 158
    frame #16: 0x00005555556dd862 hipreme_engine`main(argc=2, argv=0x00007fffffffe068) at entrypoint.d:42:17
    frame #17: 0x00007ffff74a9d0a libc.so.6`__libc_start_main + 234
    frame #18: 0x00005555556995ca hipreme_engine`_start + 42

For documentation purposes:

This problem was occurring because some function pointers were being declared as extern(System) __gshared and some of those were loose: i.e: They wasn't static function pointers, so they didn't get mangled, and somehow, they still linked and after running, a sigsegfault occurred.
The log function was being mismatched with the core.stdc.math:log.

Creating aliases to the function pointer type and then declaring them is a fix, but this is a compiler/linker bug that should be fixed ASAP