Opened 18 years ago
Closed 18 years ago
#1153 closed enhancement (fixed)
ppStack dies in a Bus Error: pmReadoutWriteSubtractionKernels
| Reported by: | Michael Wood-Vasey | Owned by: | Paul Price |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | ppStack | Version: | 2.6 |
| Severity: | minor | Keywords: | |
| Cc: |
Description
ppStack compiled from CVS HEAD (2008/11/07, 19:00 EST) gives a Bus Error. I obtained the same Bus Error last week, but at least the new version in CVS HEAD gets there much faster now. I figured I was doing something wrong before, but I finally decided that maybe there was a bug.
(gdb) run test3.mdc test3
Starting program: /Users/mwv/local/PS1/code/ipp/default.darwin_x86/bin/ppStack test3.mdc test3
Reading symbols for shared libraries +++++++++++++++++++++..... done
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |4|psModules.config
merged camera recipes with system recipes
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |W|ppStackCamera (ppStackCamera.c:211)
SOURCES provided without PSF --- ignoring.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |W|ppStackCamera (ppStackCamera.c:211)
SOURCES provided without PSF --- ignoring.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |I|psModules.config.format
Camera _MEGACAM-SKYCELL, format SKYCELL matches header.
2008-11-08 00:34:25Z|Peace.local |W|ppStackCamera (ppStackCamera.c:211)
SOURCES provided without PSF --- ignoring.
Done parsing arguments
Determining target PSF....
Temporary files: /tmp/test3.0.conv.im.fits /tmp/test3.0.conv.mk.fits /tmp/test3.0.conv.wt.fits
Temporary files: /tmp/test3.1.conv.im.fits /tmp/test3.1.conv.mk.fits /tmp/test3.1.conv.wt.fits
Temporary files: /tmp/test3.2.conv.im.fits /tmp/test3.2.conv.mk.fits /tmp/test3.2.conv.wt.fits
Convolving inputs to target PSF....
2008-11-08 00:34:25Z|Peace.local |I|p_psRandomGetSystemSeed
System random seed value used = 49da9346cdd66fab
Convolving input 0 of 3 to target PSF....
2008-11-08 00:34:28Z|Peace.local |I|psModules.imcombine
POIS kernel: 1,0 --> 8 elements
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000008
0x0021c4df in pmReadoutWriteSubtractionKernels ()
(gdb) bt
#0 0x0021c4df in pmReadoutWriteSubtractionKernels ()
#1 0x000100c0 in ppStackMatch (readout=0x2741194, regions=0xbfffe7d4, kernels=0xbfffe7d0, chi2=0x2740da4, sources=0x0, psf=0x0, rng=0x2740334, config=0xe06b14) at ppStackMatch.c:297
#2 0x00008a2f in ppStackLoop (config=0xe06b14) at ppStackLoop.c:484
#3 0x000027e0 in main (argc=3, argv=0xbfffea7c) at ppStack.c:59
Here's the test3.mdc file
[mwv@peace skycell.0198755.new] cat test3.mdc
INPUT0 METADATA
IMAGE STR 905092.fits
MASK STR 905092.mk.fits
WEIGHT STR 905092.wt.fits
# PSF STR 905092.psf
SOURCES STR 905092.cmf
WEIGHTING F32 1.0
SCALE F32 1.0
END
INPUT1 METADATA
IMAGE STR 906046.fits
MASK STR 906046.mk.fits
WEIGHT STR 906046.wt.fits
# PSF STR 906046.psf
SOURCES STR 906046.cmf
WEIGHTING F32 1.0
SCALE F32 1.0
END
INPUT2 METADATA
# 906046.fits 906287.fits 906450.fits 906747.fits
IMAGE STR 906287.fits
MASK STR 906287.mk.fits
WEIGHT STR 906287.wt.fits
# PSF STR 906287.psf
SOURCES STR 906287.cmf
WEIGHTING F32 1.0
SCALE F32 1.0
END
Change History (4)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000008
0x0000a10e in ppStackLoop (config=0xe06b14) at ppStackLoop.c:704
704 inspect->data[i] = psArrayAdd(inspect->data[i], 1, results->data[i]);
(gdb) bt
#0 0x0000a10e in ppStackLoop (config=0xe06b14) at ppStackLoop.c:704
#1 0x000027e0 in main (argc=3, argv=0xbfffea7c) at ppStack.c:59
(gdb) p i
$1 = 0
(gdb) p num
$2 = 2
(gdb) p inspect
$3 = (psArray *) 0xc4038d4
(gdb) p results
$4 = (psArray *) 0x0
Here's the context in ppStackLoop.c. The inspect->data[i]= line is line 704. 'results' points to 0x0 so results->data gives a Bus error.
while ((job = psThreadJobGetDone())) {
psArray *results = job->results; Results of job
for (int i = 0; i < num; i++) {
if (inputMask->data.U8[i]) {
continue;
}
inspect->data[i] = psArrayAdd(inspect->data[i], 1, results->data[i]);
}
psFree(job);
}
Ah, it's the threading. Or more specifically not explicitly threading. I just reran with '-threads 2' and it worked and finished.
Reading data for chunk 47 into group 2....
Reading data for chunk 48 into group 1....
Reading data for chunk 49 into group 0....
Reading data for chunk 50 into group 1....
2008-11-08 02:46:43Z|serenity.phyast.pitt.edu|I|ppStack
Time to make final stack: 2.512016 sec
Cleaning up after combination....
2008-11-08 02:46:44Z|serenity.phyast.pitt.edu|I|p_psRandomGetSystemSeed
System random seed value used = 42fb6ad6c027c036
2008-11-08 02:46:44Z|serenity.phyast.pitt.edu|I|psModules.camera
Renormalising weight map by 35.694057
2008-11-08 02:46:48Z|serenity.phyast.pitt.edu|I|p_psRandomGetSystemSeed
System random seed value used = 5ce928a5e851d2e4
2008-11-08 02:46:48Z|serenity.phyast.pitt.edu|I|p_psRandomGetSystemSeed
System random seed value used = b733ed3da77ff11b
Finished at 497.942166 sec
So I suggest there's something slightly off in the threading vs. non-threading logic that means that not using the '-threads' option leads to this null dereference.
comment:3 by , 18 years ago
| Status: | new → assigned |
|---|
This is a bug I discovered the other day and haven't had a chance to fix yet. The workaround is to run with threads, even just one ("-threads 1").
comment:4 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
I believe the 'result' array was NULL because there were jobs left on the 'done' queue (in psThread.c) by a different process (PSLIB_IMAGE_CONVOLVE_MASK), and these jobs have no result array. Ensuring psThreadPoolWait harvests the jobs when requested appears to fix the problem.
Fixed in CVS head.

Ah, I see. That error I just reported occurs when I don't specify any PSF in the .mdc file (which I had tried to see if it would just skip doing the convolution). If I include the PSF file then it makes it much futher:
2008-11-08 02:14:25Z|serenity.phyast.pitt.edu|I|psModules.imcombine
2008-11-08 02:14:26Z|serenity.phyast.pitt.edu|I|psModules.camera
2008-11-08 02:14:26Z|serenity.phyast.pitt.edu|I|ppStack
2008-11-08 02:14:26Z|serenity.phyast.pitt.edu|I|ppStack
[...]
Bus error
I'll run it within gdb next to figure out why this bus error happens.