aardappel / lobster

The Lobster Programming Language

Home Page:http://strlen.com/lobster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion failed in debug version codegen.h:173

MortimerSnerd opened this issue · comments

Latest commit, on Windows 10. It only happens for the debug version. I switched over to debug from release it to see if I would get some more logging for another problem (which was just user error). The code below triggers the assertion:

private let init_sz = 20

class Bill:
   //wld_pos  = [] :: xyz_f 
   wld_pos  = vector_reserve(typeof [xyz_f], init_sz)

let BBMGR = Bill{}

Running as is with the debug version of Lobster will get the assertion.
Commenting out line 5 and replacing it with line 4 works.

There was also a crash log. The stack part looks unhelpful, but pasting in for completeness:

===== Crash Log =====
Date: 2022-03-24, Time: 23:02:41
CMD: lobster-debug test.lobster 
ExpCode: 0x80000003, ExpFlags: 0, ExpAddress: 0xA4501CE5
SymInit: Symbol-SearchPath: '.;C:\src\wozard\src;C:\src\lobster\bin;C:\Windows;C:\Windows\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'pkelley'
OS-Version: 6.2.9200 () 0x300-0x1
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A4501CE5)
00007FF6A4501CE5 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A4501EF3)
00007FF6A4501EF3 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A44C05FD)
00007FF6A44C05FD (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A449CEAF)
00007FF6A449CEAF (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A449A718)
00007FF6A449A718 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A449DAFF)
00007FF6A449DAFF (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3C4DD94)
00007FF6A3C4DD94 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3C4D8BD)
00007FF6A3C4D8BD (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3C6CE44)
00007FF6A3C6CE44 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3C4DBA6)
00007FF6A3C4DBA6 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3C10ACC)
00007FF6A3C10ACC (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3B5C372)
00007FF6A3B5C372 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A3B2ADFF)
00007FF6A3B2ADFF (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A4552525)
00007FF6A4552525 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A45525B3)
00007FF6A45525B3 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A442DAC9)
00007FF6A442DAC9 (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A442D9AE)
00007FF6A442D9AE (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A442D86E)
00007FF6A442D86E (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF6A442DB5E)
00007FF6A442DB5E (lobster-debug): (filename not available): SDL_SetWindowGammaRamp
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFD77A77034)
00007FFD77A77034 (KERNEL32): (filename not available): BaseThreadInitThunk
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFD79982651)
00007FFD79982651 (ntdll): (filename not available): RtlUserThreadStart

Yes, vector_reserve with typeof return was the biggest hack just to get map to be efficient, but it really shouldn't be in the language..

wld_pos:[xyz_f] = vector_reserve(typeof [xyz_f], init_sz) appears to work..

Ok, use the above for now. I am not going to fix the assert, because really the solution is to find a different way to do this reserving, because there's multiple problems with it.

Ok, cleaned it up, vector_reserve and typeof return are gone, replaced by vector_capacity which has no strange edge-cases.

Now just write: wld_pos = vector_capacity([] :: xyz_f, init_sz)

It simply extends the capacity of an existing vector, rather than requiring typeof. And it is just as fast since [] doesn't allocate a buffer at all anyway.

I on purpose changed the name since it's incompatible in usage with vector_reserve so I want code using it to break.. not that I expect there will be many users of it.

e60be77