Ticket #686 (closed defect: fixed)

Opened 10 years ago

Last modified 7 years ago

Exposure constructor with BBox segfaults

Reported by: becker Owned by: becker
Priority: critical Milestone:
Component: afw Keywords:
Cc: becker, rhl Blocked By:
Blocking: Project: LSST
Version Number:
How to repeat:
import lsst.afw.image as afwImage
import lsst.afw.detection as afwDetection
mi = afwImage.MaskedImageF(10,13)
mi.getImage().set(10)
bbox     = afwImage.BBox(afwImage.PointI(0,10),
                         afwImage.PointI(9,12))
exposure    = afwImage.ExposureF(mi)
subexposure = afwImage.ExposureF(exposure, bbox)

Description (last modified by becker) (diff)

When using the new exposure constructor in the manner defined below, the process segfaults.

I presume this is because I constructed the original exposure without a Wcs; if nothing else this should throw a catchable exception and not segfault. A gdb backtrace yields the offending code :

109         _wcs->shiftReferencePixel(-bbox.getX0(), -bbox.getY0());

Change History

comment:1 Changed 10 years ago by rhl

  • Owner changed from rhl to fergal
  • Status changed from new to assigned

comment:2 Changed 10 years ago by rhl

Looks like a missing check for the existance of the WCS; Fergal?

comment:3 Changed 10 years ago by becker

  • Description modified (diff)

This also fails with an exposure with a valid Wcs.

code:

    print exposure.getWcs()
    print exposure.getMaskedImage().getDimensions()
    print trimsecBbox.getX0(), trimsecBbox.getX1(), trimsecBbox.getY0(), trimsecBbox.getY1()
    trimmedExposure = afwImage.ExposureF(exposure, trimsecBbox, False)
    print 'done'

outputs:

<lsst.afw.image.imageLib.Wcs; proxy of <Swig Object of type 'boost::shared_ptr< lsst::afw::image::Wcs > *' at 0x141cb0f0> >
(13, 10)
10 12 0 9
Segmentation fault

comment:4 Changed 10 years ago by becker

  • Cc rhl added

I do have an overall question on memory management here. If I understand correctly, this is not a deep copy (the False makes this explicit). But for the subexposure, the Wcs needs to be changed. Does this not also then change the Wcs of the original exposure?

comment:5 Changed 10 years ago by fergal

  • Status changed from assigned to inTicketWork

comment:6 Changed 10 years ago by fergal

  • Owner changed from fergal to becker
  • Status changed from inTicketWork to inStandardsReview
  • reviewstatus changed from notReady to needsReview

True enough, shiftReferencePixel() was trying to reference elements of an uninitialised wcsprm structure inside the Wcs object. I wrapped the offending calls thusly.

if(_wcsInfo != NULL) {

_wcsInfo->crpix[0] += dx; _wcsInfo->crpix[1] += dy;

}

From my understanding of what this function is supposed to do, this seemed to be the right thing to do. Reopen the ticket if it's not.

comment:7 Changed 10 years ago by becker

Could you check this in? Thanks!

comment:8 Changed 10 years ago by robyn

  • Owner changed from becker to robyn
  • Status changed from inStandardsReview to inTrunkMerge

comment:9 Changed 10 years ago by robyn

  • Status changed from inTrunkMerge to inQaReview

comment:10 Changed 10 years ago by robyn

  • Status changed from inQaReview to closed
  • Resolution set to fixed

comment:11 Changed 10 years ago by robyn

  • Owner changed from robyn to becker

comment:12 Changed 7 years ago by robyn

  • Milestone DC3a Apps Framework deleted

Milestone DC3a Apps Framework deleted

Note: See TracTickets for help on using tickets.