drmortalwombat / oscar64

Optimizing Small memory C Compiler Assembler and Runtime for C64
GNU General Public License v3.0
261 stars 21 forks source link

Array.h fails #77

Closed polluks closed 1 month ago

polluks commented 1 month ago

This is reproducible


/Users/sah/g/oscar64/bin/oscar64 -e -O3 -bc opp_streamtest.cpp
Assertion failed: (n >= 0), function operator[], file Array.h, line 244.
make[1]: *** [opp_streamtest] Abort trap: 6
drmortalwombat commented 1 month ago

Can't reproduce

polluks commented 1 month ago

(lldb) r -e -O3 -bc opp_streamtest.cpp
Process 22649 launched: '/Users/sah/g/oscar64/bin/oscar64' (arm64)
Assertion failed: (n >= 0), function operator[], file Array.h, line 244.
Process 22649 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #4: 0x00000001001ef308 oscar64`ByteCodeInstruction::Assemble(ByteCodeGenerator*, ByteCodeBasicBlock*) (.cold.2) [inlined] GrowingArray<LinkerReference>::operator[](this=<unavailable>, n=<unavailable>) at Array.h:244:3 [opt]
   241  
   242      __forceinline T& operator[](int n)
   243      {
-> 244          assert(n >= 0);
   245          if (n >= size) Grow(n + 1, false);
   246          return array[n];
   247      }
Target 0: (oscar64) stopped.
warning: oscar64 was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x00000001963215e0 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000196359f70 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x0000000196266908 libsystem_c.dylib`abort + 128
    frame #3: 0x0000000196265c1c libsystem_c.dylib`__assert_rtn + 284
  * frame #4: 0x00000001001ef308 oscar64`ByteCodeInstruction::Assemble(ByteCodeGenerator*, ByteCodeBasicBlock*) (.cold.2) [inlined] GrowingArray<LinkerReference>::operator[](this=<unavailable>, n=<unavailable>) at Array.h:244:3 [opt]
    frame #5: 0x00000001001ef2ec oscar64`ByteCodeInstruction::Assemble(ByteCodeGenerator*, ByteCodeBasicBlock*) (.cold.2) [inlined] GrowingArray<LinkerReference>::Push(this=<unavailable>, t=<unavailable>) at Array.h:270:3 [opt]
    frame #6: 0x00000001001ef2ec oscar64`ByteCodeInstruction::Assemble(ByteCodeGenerator*, ByteCodeBasicBlock*) (.cold.2) at ByteCodeGenerator.cpp:973:24 [opt]
    frame #7: 0x000000010005a930 oscar64`InterCodeBasicBlock::UpdateLocalIntegerRangeSetsForward(GrowingArray<InterVariable*> const&, GrowingArray<InterVariable*> const&) [inlined] GrowingArray<IntegerValueRange>::operator[](this=<unavailable>, n=<unavailable>) at Array.h:244:3 [opt]
    frame #8: 0x000000010005a92c oscar64`InterCodeBasicBlock::UpdateLocalIntegerRangeSetsForward(this=0x000000012c07e200, localVars=<unavailable>, paramVars=<unavailable>) at InterCode.cpp:8327:11 [opt]
    frame #9: 0x0000000100056314 oscar64`InterCodeBasicBlock::UpdateLocalIntegerRangeSets(this=0x000000012c07e200, localVars=<unavailable>, paramVars=<unavailable>) at InterCode.cpp:8666:2 [opt]
    frame #10: 0x0000000100055ce0 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c07e200, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7543:4 [opt]
    frame #11: 0x0000000100055cf8 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c075e00, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7547:31 [opt]
    frame #12: 0x0000000100055cf8 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c067a00, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7547:31 [opt]
    frame #13: 0x0000000100055d14 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c067400, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7549:33 [opt]
    frame #14: 0x0000000100055d14 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c05c600, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7549:33 [opt]
    frame #15: 0x0000000100055cf8 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c054800, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7547:31 [opt]
    frame #16: 0x0000000100055cf8 oscar64`InterCodeBasicBlock::BuildGlobalIntegerRangeSets(this=0x000000012c02cc00, initial=<unavailable>, localVars=0x000000012bfcdd40, paramVars=<unavailable>) at InterCode.cpp:7547:31 [opt]
    frame #17: 0x00000001000a3c34 oscar64`InterCodeProcedure::Close(this=0x000000012bfcdba0) at InterCode.cpp:22089:24 [opt]
    frame #18: 0x00000001000b9e3c oscar64`InterCodeGenerator::TranslateProcedure(this=0x00006000010dc0c0, mod=0x0000600003adc0c0, exp=0x00006000035d5ce0, dec=0x000000012aee2500) at InterCodeGenerator.cpp:5746:9 [opt]
    frame #19: 0x00000001000b97dc oscar64`InterCodeGenerator::TranslateAssembler(this=0x00006000010dc0c0, mod=0x0000600003adc0c0, exp=<unavailable>, refvars=0x0000000000000000) at InterCodeGenerator.cpp:862:40 [opt]
    frame #20: 0x000000010001f18c oscar64`Compiler::GenerateCode(this=0x00006000025dc000) at Compiler.cpp:911:23 [opt]
    frame #21: 0x00000001001eed2c oscar64`main2(argc=<unavailable>, argv=0x000000016fdff488) at oscar64.cpp:530:50 [opt]
    frame #22: 0x0000000195fd7274 dyld`start + 2840
drmortalwombat commented 1 month ago

This one was fixed with e4e997fef22097d585e74e1b85fec91ac49900c9 please check that you are building the correct version.

polluks commented 1 month ago

Thanks! How about moving the makefile to the main directory? Just to save the f option.