<html>
<head>
  
</head>
<body text="#000000" bgcolor="#ffffff">
Aram and all,<br>
<br>
Thank you for your report of this error.  Thanks for documenting the
error and making the corrupted hddm file available to me, otherwise it
would have been difficult to reproduce.  This error does not have to do
with particularly busy events, as Dave suggested.  The hddm file is
corrupted near the end in a very peculiar way that took me quite a bit
of experimenting to reproduce.  The simplest way to reproduce what you
saw is to run a hdgeant simulation with a large output file and run out
of disk space or quota on the disk where the hddm output file is being
written.  This condition was not being reported properly to HDGeant, so
the event writer was failing silently, and allowing the simulation to
continue.  The result was that after 474310 good events in the output
file you saved on the work disk, event 474311 and following are
corrupted and will produce unpredictable results whenever they are read.<br>
<br>
I have produced a fix for this problem and commited it to svn.  To test
the fix, I set up a small disk partition and reproduced the error you
reported in the hddm file after only 47 output events.   I then applied
the changes below and ran the test again.  It reported a fatal error
and aborted the simulation at event 47 as desired, with events 1-46
still intact and readable in the output hddm file.  Here are the
changes.<br>
<ol>
  <li>modified hddm-c so that [after it is used to regenerate hddm_s.c
and hddm_s.h in the HDDM directory] flush_s_HDDM() returns -1 if it
encounters endoffile or i/o errors.  To apply this fix, you must:</li>
  <ul>
    <li>go to the hddm directory under programs/Utilities and do "svn
update; make install".</li>
    <li>go to the HDDM directory under libraries and do "hddm-c
event.xml".<br>
    </li>
  </ul>
  <li>modified HDGeant function flushOutput() in hddmOutput.c to write
a fatal error message to stderr, and quit with error code 7 if
flush_s_HDDM() returns an error.  To apply this fix, you must:</li>
  <ul>
    <li>go to the HDGeant directory under programs/Simulation and do
"svn update; make hdgeant"</li>
    <li>run a new simulation<br>
    </li>
  </ul>
</ol>
It would be great if someone would add this check on the return value
from flush_s_HDDM() to other programs that write hddm files, eg. Monte
Carlo event generators (bggen?) and mcsmear, to prevent this gotcha
from hitting anyone else in the future.<br>
<br>
Your existing 14.x GB file bggen_xxxxxxx.hddm file that produced the
error can still be used for your studies provided that you do not read
past event 474310.<br>
<br>
-Richard Jones<br>
<br>
<br>
<br>
<br>
David Lawrence wrote:
<blockquote type="cite" cite="mid:4AF07314.7000207@jlab.org">
  <pre wrap="">Hi Aram,

    OK, I do recall actually seeing this behavior before. It happens 
when there is a particularly busy event. When I tried running through 
your events with hd_root (no processing, just reading) I got a seg. 
fault as well. The stack trace reported that the sighandler() was called 
from  make_s_FdcCathodeHits(), a routine that's part of the HDDM 
library. I believe the problem is that the call to malloc() within this 
routine is failing for these really busy events due to the block size 
being simply too big. There does not appear to be a check on the malloc 
call succeeding at the moment. I'm CC-ing Richard Jones on this since he 
is the father of HDDM so maybe a fix can be implemented in the next 
version. In the meantime, I think the only solution is to avoid these 
really busy events by either reducing the background, or only analyzing 
the first 474263 events in your file ;).

Regards,
-David


Aram Teymurazyan wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi David,

I have a file posted at:

/work/halld/home/teymuraz/bggen_hdgeant_no_pileup.55.hddm (sorry for 
the large file).

mcsmear and hddm_cull_events both fail when working with this file.
If you have time to figure out what went wrong I would highly 
appreciate it.

Thanks,
Aram


ifarml5> mcsmear -n bggen_hdgeant_no_pileup.55.hddm
 input file: bggen_hdgeant_no_pileup.55.hddm
 output file: bggen_hdgeant_no_pileup.55_smeared.hddm
FCAL Geometry initialized with 2800 active blocks.
  474264 events processed
 *** Break *** segmentation violation


//-----------------


ifarml5> hddm_cull_events -s474164 -k500 bggen_hdgeant_no_pileup.55.hddm
Skipping 474164
Keeping  500
 output file: culled.hddm
 input file: bggen_hdgeant_no_pileup.55.hddm
Segmentation faultad     (97 event written)
    </pre>
  </blockquote>
  <pre wrap="">
  </pre>
</blockquote>
<br>
</body>
</html>