Fully agreed, as a general rule this should always be tested first.

However, for this small test script I thought the call to contractDays(C1) is a sufficient indirect confirmation that C1 is valid. Anyway, the script is still crashing, even after changing this line to

if(C1) contractPrice(C1);

Meanwhile I also changed the asset (to something trading at this time of day):

contractUpdate("DAX-IDX-SMART-EUR",0,FUTURE);

Here is the output:

MH_Fut_Chk01
Login 0 IB..
!IB Socket connected
!Account Unnnnnnn at UTC 08-28 07:13
!Get Future Chain DAX-FUT--0----EUR
Chain of 6 DAX-IDX-SMART-EUR contracts
Loaded 6 contracts.
Error 111: Crash in function: main() at bar 0
Logout.. ok

here is the output if the contractPrice() line is commented out:

MH_Fut_Chk01
Login 0 IB..
!IB Socket connected
!Account Unnnnnnn at UTC 08-28 07:23
!Get Future Chain DAX-FUT--0----EUR
Chain of 6 DAX-IDX-SMART-EUR contracts
Loaded 6 contracts.
contractDays C1 = 43364.50
FDXM,Future,20180921,0.0000,0.0000,0.0000,0.0000,5,0
contractDays C2 = 43455.50
FDXM,Future,20181221,0.0000,0.0000,0.0000,0.0000,5,0
Logout.. ok

The script is creating the following CSV:

Class,Type,Expiry,Strike,Underlying,Ask,Bid,Multiplier,Vol
FDXM,Future,20180921,0.0000,0.0000,0.0000,0.0000,5,0
FDAX,Future,20180921,0.0000,0.0000,0.0000,0.0000,25,0
FDXM,Future,20181221,0.0000,0.0000,0.0000,0.0000,5,0
FDAX,Future,20181221,0.0000,0.0000,0.0000,0.0000,25,0
FDAX,Future,20190315,0.0000,0.0000,0.0000,0.0000,25,0
FDXM,Future,20190315,0.0000,0.0000,0.0000,0.0000,5,0

Could this be a bug related to futures chains?