From e603d30426da92456bd8e3c0ef4090a6cdc26bc3 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sat, 4 May 2013 21:09:18 +0200 Subject: [PATCH] Fix floating point exception. dev->max_file_size = 2 * num_recs * dev->max_block_size; max_block_size can be 0 which gives a max_file_size which is 0 when you then calculate write_eof = dev->max_file_size / REC_SIZE; /*compute when we add EOF*/ then write_eof = 0 and when you then do if ((block->BlockNumber % write_eof) == 0) { You get a nice Floating Point Execption. We now set max_file_size to something more appropriate and assert on write_eof being bigger then 0 so we never do a divide by zero again. Fixes #96: btape crashes using multiple tape test when tape was written by a fill test before. --- src/stored/btape.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stored/btape.c b/src/stored/btape.c index f761f37b0c5..ee6393f33fa 100644 --- a/src/stored/btape.c +++ b/src/stored/btape.c @@ -1143,7 +1143,11 @@ static bool write_two_files() * Set big max_file_size so that write_record_to_block * doesn't insert any additional EOF marks */ - dev->max_file_size = 2 * num_recs * dev->max_block_size; + if (dev->max_block_size) { + dev->max_file_size = 2 * num_recs * dev->max_block_size; + } else { + dev->max_file_size = 2 * num_recs * DEFAULT_BLOCK_SIZE; + } Pmsg2(-1, _("\n=== Write, rewind, and re-read test ===\n\n" "I'm going to write %d records and an EOF\n" "then write %d records and an EOF, then rewind,\n" @@ -2231,6 +2235,8 @@ static void fillcmd() min_block_size = dev->min_block_size; dev->min_block_size = dev->max_block_size; write_eof = dev->max_file_size / REC_SIZE; /*compute when we add EOF*/ + ASSERT(write_eof > 0); + set_volume_name("TestVolume1", 1); dir_ask_sysop_to_create_appendable_volume(dcr); dev->set_append(); /* force volume to be relabeled */