Skip to content

Commit ad1b43e

Browse files
authored
Merge pull request #2708 from kif/2631_segfault_pixelsplitting
2631 segfault pixelsplitting
2 parents c02c052 + b72e22e commit ad1b43e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/pyFAI/ext/regrid_common.pxi

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Some are defined in the associated header file .pxd
3232

3333
__author__ = "Jérôme Kieffer"
3434
__contact__ = "Jerome.kieffer@esrf.fr"
35-
__date__ = "18/11/2025"
35+
__date__ = "27/11/2025"
3636
__status__ = "stable"
3737
__license__ = "MIT"
3838

@@ -512,6 +512,7 @@ def _sp_integrate1d(buffer_t[::1] buffer,
512512
floating stop0, floating stop1):
513513
_integrate1d(buffer, start0, start1, stop0, stop1)
514514

515+
515516
cdef inline void _integrate2d(buffer_t[:, ::1] box,
516517
floating start0, floating start1,
517518
floating stop0, floating stop1) noexcept nogil:
@@ -545,7 +546,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
545546
abs_area = fabs(segment_area)
546547
dA = (stop0 - start0) # always positive
547548
h = 0
548-
while abs_area > 0:
549+
while abs_area > 0 and h<box.shape[1]:
549550
if dA > abs_area:
550551
dA = abs_area
551552
abs_area = -1
@@ -559,7 +560,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
559560
abs_area = fabs(segment_area)
560561
h = 0
561562
dA = dP
562-
while abs_area > 0:
563+
while abs_area > 0 and h<box.shape[1]:
563564
if dA > abs_area:
564565
dA = abs_area
565566
abs_area = -1
@@ -573,7 +574,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
573574
abs_area = fabs(segment_area)
574575
h = 0
575576
dA = 1.0
576-
while abs_area > 0:
577+
while abs_area > 0 and h<box.shape[1]:
577578
if dA > abs_area:
578579
dA = abs_area
579580
abs_area = -1
@@ -589,7 +590,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
589590
abs_area = fabs(segment_area)
590591
h = 0
591592
dA = fabs(dP)
592-
while abs_area > 0:
593+
while abs_area > 0 and h<box.shape[1]:
593594
if dA > abs_area:
594595
dA = abs_area
595596
abs_area = -1
@@ -605,7 +606,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
605606
# sign = segment_area / abs_area
606607
dA = (start0 - stop0) # always positive
607608
h = 0
608-
while abs_area > 0:
609+
while abs_area > 0 and h<box.shape[1]:
609610
if dA > abs_area:
610611
dA = abs_area
611612
abs_area = -1
@@ -620,7 +621,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
620621
abs_area = fabs(segment_area)
621622
h = 0
622623
dA = fabs(dP)
623-
while abs_area > 0:
624+
while abs_area > 0 and h<box.shape[1]:
624625
if dA > abs_area:
625626
dA = abs_area
626627
abs_area = -1
@@ -634,7 +635,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
634635
abs_area = fabs(segment_area)
635636
h = 0
636637
dA = 1
637-
while abs_area > 0:
638+
while abs_area > 0 and h<box.shape[1]:
638639
if dA > abs_area:
639640
dA = abs_area
640641
abs_area = -1
@@ -650,7 +651,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
650651
abs_area = fabs(segment_area)
651652
h = 0
652653
dA = fabs(dP)
653-
while abs_area > 0:
654+
while abs_area > 0 and h<box.shape[1]:
654655
if dA > abs_area:
655656
dA = abs_area
656657
abs_area = -1

src/pyFAI/test/test_azimuthal_integrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
__contact__ = "Jerome.Kieffer@ESRF.eu"
3434
__license__ = "MIT"
3535
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
36-
__date__ = "21/11/2025"
36+
__date__ = "27/11/2025"
3737

3838
import unittest
3939
import os
@@ -806,7 +806,7 @@ def tearDownClass(cls) -> None:
806806

807807
def test_flexible(self):
808808
for m in IntegrationMethod.select_method(dim=2, impl="cython"):
809-
res = self.ai.integrate2d(self.img, 50, 50, method=m, unit=("qx_nm^-1", "qy_nm^-1"))
809+
res = self.ai.integrate2d(self.img, 50, 50, method=m, unit=("qxgi_nm^-1", "qygi_nm^-1"))
810810
img, rad, azim = res
811811
self.assertTrue(numpy.nanmax(img) > 0, f"image is non empty for {m}")
812812
radmax = rad.max()

0 commit comments

Comments
 (0)