You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring models for the ORM, if the parent and child both reference each other it results in a memory error during compilation.
Reproduction Steps
module main
import db.sqlite
@[table: 'parents']
struct Parent {
id int @[primary; sql: serial]
// removing the following line or the one noted below
// results in successful compilation
children []Child @[fkey: 'parent_id']
}
@[table: 'children']
struct Child {
id int @[primary; sql: serial]
parent_id int
// removing the following line or the one noted above
// results in successful compilation
parent Parent
}
fn main() {
mut db := sqlite.connect('demo.sql') or {
panic(err)
}
defer {
db.close() or { panic(err) }
}
_ := sql db {
select from Parent
} or {
panic(err)
}
}
Expected Behavior
The compiler should provide an error message to the user instead of crashing.
Current Behavior
> v .
fish: Job 1, 'v .' terminated by signal SIGSEGV (Address boundary error)
Possible Solution
The call stack seems to get stuck infinitely calling Checker_sql_expr.
frame #631: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fddc720) at v2.15290716692373272098.tmp.c:75429
frame #632: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fddfa30) at v2.15290716692373272098.tmp.c:75429
frame #633: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fde2d40) at v2.15290716692373272098.tmp.c:75429
frame #634: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fde6050) at v2.15290716692373272098.tmp.c:75429
frame #635: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fde9360) at v2.15290716692373272098.tmp.c:75429
frame #636: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fdec670) at v2.15290716692373272098.tmp.c:75429
frame #637: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x000000016fdef980) at v2.15290716692373272098.tmp.c:75429
frame #638: 0x000000010025ffa0 v`v__checker__Checker_sql_expr(c=0x000000013480b200, node=0x00000001147fc6d0) at v2.15290716692373272098.tmp.c:75429
frame #639: 0x00000001001cc24c v`v__checker__Checker_expr(c=0x000000013480b200, node=0x000000016fdf5080) at v2.15290716692373272098.tmp.c:63446
frame #640: 0x000000010018c3ac v`v__checker__Checker_assign_stmt(c=0x000000013480b200, node=0x00006000004dcd80) at v2.15290716692373272098.tmp.c:58241
frame #641: 0x00000001001c0aec v`v__checker__Checker_stmt(c=0x000000013480b200, node=0x00000001147f9c90) at v2.15290716692373272098.tmp.c:62132
frame #642: 0x00000001001c8124 v`v__checker__Checker_stmts_ending_with_expression(c=0x000000013480b200, stmts=0x00000001147fcaf0) at v2.15290716692373272098.tmp.c:62700
frame #643: 0x00000001001c7e24 v`v__checker__Checker_stmts(c=0x000000013480b200, stmts=0x00000001147fcaf0) at v2.15290716692373272098.tmp.c:62676
frame #644: 0x000000010020e300 v`v__checker__Checker_fn_decl(c=0x000000013480b200, node=0x00000001147fc850) at v2.15290716692373272098.tmp.c:69497
frame #645: 0x00000001001c15a8 v`v__checker__Checker_stmt(c=0x000000013480b200, node=0x00006000004dcea0) at v2.15290716692373272098.tmp.c:62212
frame #646: 0x00000001001a73f4 v`v__checker__Checker_check(c=0x000000013480b200, ast_file=0x00000001147fcc20) at v2.15290716692373272098.tmp.c:60284
frame #647: 0x00000001001a7bdc v`v__checker__Checker_check_files(c=0x000000013480b200) at v2.15290716692373272098.tmp.c:60351
frame #648: 0x00000001004992cc v`v__builder__Builder_middle_stages(b=0x000000016fdfdfe8) at v2.15290716692373272098.tmp.c:114499
frame #649: 0x000000010049978c v`v__builder__Builder_front_and_middle_stages(b=0x000000016fdfdfe8) at v2.15290716692373272098.tmp.c:114533
frame #650: 0x00000001004b9c5c v`v__builder__cbuilder__gen_c(b=0x000000016fdfdfe8) at v2.15290716692373272098.tmp.c:116989
frame #651: 0x00000001004b9abc v`v__builder__cbuilder__build_c(b=0x000000016fdfdfe8, out_file=(str = "/tmp/v_501/ormerr.15090000011550855866.tmp.c", len = 44, is_lit = 0)) at v2.15290716692373272098.tmp.c:116972
frame #652: 0x00000001004b9910 v`v__builder__cbuilder__compile_c(b=0x000000016fdfdfe8) at v2.15290716692373272098.tmp.c:116962
frame #653: 0x00000001004b7e68 v`v__builder__Builder_rebuild(b=0x000000016fdfdfe8, backend_cb=(v`v__builder__cbuilder__compile_c at v2.15290716692373272098.tmp.c:116947)) at v2.15290716692373272098.tmp.c:116868
frame #654: 0x00000001004ae554 v`v__builder__compile(command=(str = "build", len = 5, is_lit = 1), pref_=0x000000013500b600, backend_cb=(v`v__builder__cbuilder__compile_c at v2.15290716692373272098.tmp.c:116947)) at v2.15290716692373272098.tmp.c:115973
frame #655: 0x00000001004be294 v`main__rebuild(prefs=0x000000013500b600) at v2.15290716692373272098.tmp.c:117303
frame #656: 0x00000001004bd570 v`main__main at v2.15290716692373272098.tmp.c:117251
frame #657: 0x00000001004d0f78 v`main(___argc=2, ___argv=0x000000016fdff600) at v2.15290716692373272098.tmp.c:117970
Additional Information/Context
No response
V version
V 0.4.3 b944927
Environment details (OS name and version, etc.)
V full version: V 0.4.3 eaacf83.b944927
OS: macos, macOS, 14.2.1, 23C71
Processor: 11 cpus, 64bit, little endian, Apple M3 Pro
Describe the bug
When declaring models for the ORM, if the parent and child both reference each other it results in a memory error during compilation.
Reproduction Steps
Expected Behavior
The compiler should provide an error message to the user instead of crashing.
Current Behavior
Possible Solution
The call stack seems to get stuck infinitely calling Checker_sql_expr.
Additional Information/Context
No response
V version
V 0.4.3 b944927
Environment details (OS name and version, etc.)
V full version: V 0.4.3 eaacf83.b944927
OS: macos, macOS, 14.2.1, 23C71
Processor: 11 cpus, 64bit, little endian, Apple M3 Pro
getwd:
vexe:
vexe mtime:
vroot: OK, value:
VMODULES: OK, value:
VTMP: OK, value:
Git version: git version 2.39.3 (Apple Git-145)
Git vroot status: weekly.2023.50-100-gb944927f
.git/config present: true
CC version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: