diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
index bd013da9b03f8644576ab7cafa762a6982e2ad4c..cde93889848527dd99f8e46056decd1568e1dd9b 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
@@ -375,3 +375,11 @@ repair table t1 extended;
 Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
 drop table t1;
+create table t1 ( id int primary key,
+hexid  varchar(10) generated always as (hex(id)) stored,
+key (hexid)) engine=myisam;
+insert into t1 (id) select 100;
+select * from t1;
+id	hexid
+100	64
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
index 337d14c3074e2977feb775324dfe81dbb6a260a4..3269979fc9e4148304e587beaf396a614bd6321e 100644
--- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
@@ -262,3 +262,13 @@ create table t1 (
 insert into t1 values (null, 0);
 repair table t1 extended;
 drop table t1;
+
+#
+# MDEV-18486 Database crash on a table with indexed virtual column
+#
+create table t1 ( id int primary key,
+        hexid  varchar(10) generated always as (hex(id)) stored,
+        key (hexid)) engine=myisam;
+insert into t1 (id) select 100;
+select * from t1;
+drop table t1;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index dedf232523b78b01531a1d234ff583678e419ba4..80bfdda18ded6e58d36c26c04242df671765428b 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -934,14 +934,18 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param)
     ulong new_vreclength= file->s->vreclength;
     for (Field **vf= table->vfield; *vf; vf++)
     {
-      uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
-      set_if_bigger(new_vreclength, vf_end);
-      indexed_vcols|= (*vf)->flags & PART_KEY_FLAG;
+      if (!(*vf)->stored_in_db())
+      {
+        uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
+        set_if_bigger(new_vreclength, vf_end);
+        indexed_vcols|= (*vf)->flags & PART_KEY_FLAG;
+      }
     }
     if (!indexed_vcols)
       return;
     file->s->vreclength= new_vreclength;
   }
+  DBUG_ASSERT(file->s->base.reclength < file->s->vreclength);
   param->fix_record= compute_vcols;
   table->use_all_columns();
   table->vcol_set= &table->s->all_set;