Bug 26409 - Crash when using variable-size types as offset unit
Summary: Crash when using variable-size types as offset unit
Status: RESOLVED FIXED
Alias: None
Product: poke
Classification: Unclassified
Component: Compiler (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-20 00:57 UTC by Mohammad-Reza Nabipoor
Modified: 2020-11-14 18:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Backtrace (1.99 KB, text/plain)
2020-08-20 00:57 UTC, Mohammad-Reza Nabipoor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mohammad-Reza Nabipoor 2020-08-20 00:57:05 UTC
Created attachment 12783 [details]
Backtrace

Using types that have unknown size at compile-time as offset unit leads to crash:


(poke) deftype Packet = struct { uint<8>[] data; }
(poke) #Packet
lt-poke: ../../libpoke/pkl-ast.c:934: pkl_ast_sizeof_type: Assertion `PKL_AST_TYPE_COMPLETE (type) == PKL_AST_TYPE_COMPLETE_YES' failed.
Aborted (core dumped)


I think printing an error message is much more user-friendlier :)

BTW you can find the backtrace in attached file (`uknown-size-type-as-unit.bt.txt`).
Comment 1 Jose E. Marchesi 2020-08-20 08:35:25 UTC
Hi Mohammad.

This was caused by a thinko in the function that determines whether a type is complete or not.  The compiler indeed emits a proper error in these situations :)

Fixed in https://git.savannah.nongnu.org/cgit/poke.git/commit/?id=9c71d05f8c69c31f3b6a2c9966e06086e3ca1202

Thanks for reporting!
Comment 2 Mohammad-Reza Nabipoor 2020-08-20 09:18:00 UTC
Hi Jose

Thanks for the fix. Much better now!