Skip to content

Commit

Permalink
Fix crash with null array in constant record aggregate
Browse files Browse the repository at this point in the history
Fixes xxx
  • Loading branch information
nickg committed Jan 18, 2025
1 parent 231ae7a commit 1fa5a79
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Unreleased changes
- Fixed a crash when a subprogram is called with too many named arguments
(from @NikLeberg) (#1091).
- Fixed a crash when a constant record aggregate has a null array
element (#1137).

## Version 1.15.0 - 2025-01-11
- `--load` is now a global option and should be placed before the `-r`
Expand Down
1 change: 1 addition & 0 deletions src/jit/jit-interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static inline int64_t interp_get_int(jit_interp_t *state, jit_value_t value)
return state->regs[value.reg].integer;
case JIT_VALUE_INT64:
case JIT_VALUE_DOUBLE:
case JIT_ADDR_ABS:
return value.int64;
default:
CANNOT_HANDLE(value);
Expand Down
7 changes: 6 additions & 1 deletion src/jit/jit-irgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static inline jit_value_t jit_value_from_loc(const loc_t *loc)

static inline jit_value_t jit_null_ptr(void)
{
jit_value_t value = { .kind = JIT_VALUE_INT64, .int64 = 0 };
jit_value_t value = { .kind = JIT_ADDR_ABS, .int64 = 0 };
return value;
}

Expand Down Expand Up @@ -1068,6 +1068,11 @@ static void irgen_copy_const(jit_irgen_t *g, unsigned char *p,
memcpy(p, g->func->cpool + value.int64, bytes);
break;

case JIT_ADDR_ABS:
assert(value.int64 == 0);
assert(bytes == 0);
break;

default:
fatal_trace("cannot handle value kind %d", value.kind);
}
Expand Down
32 changes: 32 additions & 0 deletions test/regress/issue1137.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
entity issue1137 is
end entity;

architecture test of issue1137 is
type t_rec is record
x : integer;
y : bit_vector(1 to 0); -- Null
z : integer;
end record;

signal s : t_rec := (42, "", 55);
begin

process is
variable v : t_rec := (666, "", 12);
begin
assert s.x = 42;
assert s.y = "";
assert s.z = 55;
v.y := "";
s.y <= "";
wait for 1 ns;
assert s.x = 42;
assert s.y = v.y;
assert s.z = 55;
assert v.x = 666;
assert v.y = "";
assert v.z = 12;
wait;
end process;

end architecture;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1092,3 +1092,4 @@ ename17 fail,gold,2008
cmdline13 shell
issue1117 normal,psl,2008
issue1125 normal,2008
issue1137 normal

0 comments on commit 1fa5a79

Please sign in to comment.