[Nexus] NXdir: SEG fault
Mark Koennecke
Mark.Koennecke at psi.ch
Fri Jan 29 08:31:09 GMT 2010
Hi,
these are two separate issues.
Mark Rivers wrote:
> I have discovered a possibly related problem with stack overflow when calling Nexus API from a multi-threaded C program. I found that the function NXgetgroupinfo uses a very large amout of stack. I would get stack overflow when my thread had less than 40000 bytes of stack, it worked OK with 80000 bytes. The stack overflow only happened for me on Windows with the MS VC++ compiler, it did not happen on Linux, or Windows with the gcc compiler. But I suspect that NXgetgroupinfo is doing some recursion that can use a large amount of stack depending on the structure of the HDF file.
>
I assume this is relating to HDF-5. NXgetgroupinfo uses H5Giterate in
order to get information about the group. It may recurse; I do not
know how H5Giterate is implemented. It does not allocate particularly
large data structures either. Now H5Giterate is one the recommended
ways (by the HDF people) to search a group. And it was the only one
available when we implemented the HDF-5 part of NeXus. 80000 bytes
is 80K which does not seem to me as particularily large, given that even
a netbook has 1GB of memory these days. I am also not sure that
an alternative implementation will use less stack space. As the
implementation is working nicely on many systems and there is a workaround
I am very much tempted to write this off as a particular of that MS
compiler.
>
> Mark
>
>
> ________________________________
>
>
> Using nxdir, I get a SEGV:
>
>
>
> nxdir -t multi mcstas.h5 -p "*" --data-mode script
> *** stack smashing detected ***: nxdir terminated
> Segmentation fault
>
>
>
This is a real bug, caused by a string overrun when formatting numbers
in nxdir. I have fixed this; the
updated code is in the NeXus subversion repository.
Best Regards,
Mark Koennecke
> System is:
>
>
> NeXus 4.2.0 (from tarball)
> Linux Ubuntu 8.04 64 bits
>
>
>
> Generation of NeXus file with McStas performs OK (file attached), except for warning messages when trying to create/open already existing/opened groups/objects.
>
> The only way to seemingly test if a group exists without creating with an error message is to call NXgetgroupinfo to get the current group and make a strcmp with the requested group.
>
> There is unfortunately no such routine for data sets. We can not obtain the current Data Set name, only its dimension, rank and type with NXgetinfo.
>
> An other solution suggested by Mark K is to unactivate HDF error messages with NXMDisableErrorReporting(); and reset it with NXMEnableErrorReporting();
>
> If you think of a better way to inquire groups/data sets, and a solution for nxdir that fails showing data values/attributes, please tell me.
>
> Emmanuel.
>
>
More information about the NeXus
mailing list