Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering #2

Merged
merged 14 commits into from
Apr 25, 2012
Merged

Filtering #2

merged 14 commits into from
Apr 25, 2012

Conversation

edgomez
Copy link
Member

@edgomez edgomez commented Apr 23, 2012

Better pixel interpolation for more accurate lens filtering and arbitrary angle rotations:

  • generic framework for pixel interpolation
  • bilinear interpolation support
  • bicubic interpolation support
  • lanczos2 interpolation support
  • lanczos3 interpolation support
  • in sync with master (as of this pull request date)

this header contains all the necessary functions to compute
a lanczos filter for interpolation, and apply it

Signed-off-by: Edouard Gomez <[email protected]>
- turn the filter size into a module static const
- fixed roi for lens module
- add a framework for more interpolators
- funcs now start with _ for private functions
- funcs now start with dt_interpolation_ for public functions
- add bilinear interpolation function + interpolator entry
- add a lanczos2 interpolator entry
- add a lanczos3 interpolator entry
- add preference entry to schema
- add function helper to retrieve interolator type
- use it for lens and clipping
@jcsogo jcsogo merged commit 38e4950 into darktable-org:filtering Apr 25, 2012
hanatos added a commit that referenced this pull request May 19, 2013
hanatos added a commit that referenced this pull request May 22, 2013
(cherry picked from commit e03d69d)
houz pushed a commit that referenced this pull request Apr 22, 2014
LebedevRI added a commit that referenced this pull request Nov 21, 2014
This was probably missed (or it was not noticed) in 78fc8af

Fixes:
=================================================================
==19419==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f31036b66e0 at pc 0x7f31cd73ce7a bp 0x7f3145815a80 sp 0x7f3145815a78
READ of size 4 at 0x7f31036b66e0 thread T57
    #0 0x7f31cd73ce79 in _blend_normal_unbounded /home/lebedevri/darktable/src/develop/blend.c:486
    #1 0x7f31cd744916 in dt_develop_blend_process._omp_fn.6 /home/lebedevri/darktable/src/develop/blend.c:2194
    #2 0x7f31c6ba5715 (/usr/lib/x86_64-linux-gnu/libgomp.so.1+0xd715)
    #3 0x7f31c9db80a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x80a3)
    #4 0x7f31c68cdccc in clone (/lib/x86_64-linux-gnu/libc.so.6+0xe5ccc)

0x7f31036b66e0 is located 0 bytes to the right of 89644768-byte region [0x7f30fe138800,0x7f31036b66e0)
allocated by thread T10 here:
    #0 0x7f31cdbd4c9b in __interceptor_posix_memalign (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54c9b)
    #1 0x7f31cd65c18d in dt_alloc_align /home/lebedevri/darktable/src/common/darktable.c:997
    #2 0x7f31cd731cd8 in dt_dev_pixelpipe_cache_get_weighted /home/lebedevri/darktable/src/develop/pixelpipe_cache.c:163
    #3 0x7f31cd7369dd in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:827
    #4 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #5 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #6 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #7 0x7f31cd732c54 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:814
    #8 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #9 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #10 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #11 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #12 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #13 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #14 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #15 0x7f31cd732c54 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:814
    #16 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #17 0x7f31cd732c54 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:814
    #18 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #19 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #20 0x7f31cd732c54 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:814
    #21 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #22 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #23 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #24 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #25 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #26 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #27 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #28 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689
    #29 0x7f31cd732452 in dt_dev_pixelpipe_process_rec /home/lebedevri/darktable/src/develop/pixelpipe_hb.c:689

Thread T57 created by T10 here:
    #0 0x7f31cdba3bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
    #1 0x7f31c6ba5c56 (/usr/lib/x86_64-linux-gnu/libgomp.so.1+0xdc56)
    #2 0x7f31c6ba17d9 in GOMP_parallel (/usr/lib/x86_64-linux-gnu/libgomp.so.1+0x97d9)
    #3 0x3ed921823dcccccc

Thread T10 created by T0 here:
    #0 0x7f31cdba3bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
    #1 0x7f31cd6fc149 in dt_control_jobs_init /home/lebedevri/darktable/src/control/jobs.c:512
    #2 0x7f31cd6f1945 in dt_control_init /home/lebedevri/darktable/src/control/control.c:317
    #3 0x7f31cd65fe3c in dt_init /home/lebedevri/darktable/src/common/darktable.c:745
    #4 0x400b7f in main /home/lebedevri/darktable/src/main.c:24
    #5 0x7f31c6809b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/lebedevri/darktable/src/develop/blend.c:486 _blend_normal_unbounded
Shadow bytes around the buggy address:
  0x0fe6a06cec80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe6a06cec90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe6a06ceca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe6a06cecb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe6a06cecc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0fe6a06cecd0: 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa
  0x0fe6a06cece0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe6a06cecf0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe6a06ced00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe6a06ced10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe6a06ced20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Contiguous container OOB:fc
  ASan internal:           fe
==19419==ABORTING
pedrocr added a commit that referenced this pull request Jan 1, 2015
Cleanup of several broken bits of the exiv2 thumbnail code
LebedevRI added a commit that referenced this pull request Feb 26, 2015
…s longer than 19 symbols

We use  char op[20];  to store iop names, and if somehow we end up with iop
with long-enough name, we end up overflowing stack:

==23602==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff00816974 at pc 0x7fdcbfbce3f2 bp 0x7fff00816810 sp 0x7fff00816808
WRITE of size 1 at 0x7fff00816974 thread T0
    #0 0x7fdcbfbce3f1 in dt_iop_load_modules_so /home/lebedevri/darktable/src/develop/imageop.c:1214
    #1 0x7fdcbfb00229 in dt_init /home/lebedevri/darktable/src/common/darktable.c:873
    #2 0x400b9f in main /home/lebedevri/darktable/src/main.c:24
    #3 0x7fdcb80b1b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
    #4 0x400c22 (/usr/local/bin/darktable+0x400c22)

Address 0x7fff00816974 is located in stack of thread T0 at offset 180 in frame
    #0 0x7fdcbfbcc92f in dt_iop_load_modules_so /home/lebedevri/darktable/src/develop/imageop.c:1196

  This frame has 5 object(s):
    [32, 40) 'stmt'
    [96, 104) 'stmt'
    [160, 180) 'op' <== Memory access at offset 180 overflows this variable
    [224, 1248) 'path'
    [1280, 5376) 'plugindir'

SUMMARY: AddressSanitizer: stack-buffer-overflow /home/lebedevri/darktable/src/develop/imageop.c:1214 dt_iop_load_modules_so
...
==23602==ABORTING

Now, if we encounter such an iop (e.g. libexposure123456789012.so), we will simply fail to load it:
[iop_load_module] failed to open operation `exposure12345678901': /usr/local/lib/darktable/plugins/libexposure12345678901.so: cannot open shared object file: No such file or directory

While there, also add check to the CMake add_iop() macro to prevent adding such iops.
LebedevRI added a commit that referenced this pull request Feb 26, 2015
…s longer than 19 symbols

We use  char op[20];  to store iop names, and if somehow we end up with iop
with long-enough name, we end up overflowing stack:

==23602==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff00816974 at pc 0x7fdcbfbce3f2 bp 0x7fff00816810 sp 0x7fff00816808
WRITE of size 1 at 0x7fff00816974 thread T0
    #0 0x7fdcbfbce3f1 in dt_iop_load_modules_so /home/lebedevri/darktable/src/develop/imageop.c:1214
    #1 0x7fdcbfb00229 in dt_init /home/lebedevri/darktable/src/common/darktable.c:873
    #2 0x400b9f in main /home/lebedevri/darktable/src/main.c:24
    #3 0x7fdcb80b1b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
    #4 0x400c22 (/usr/local/bin/darktable+0x400c22)

Address 0x7fff00816974 is located in stack of thread T0 at offset 180 in frame
    #0 0x7fdcbfbcc92f in dt_iop_load_modules_so /home/lebedevri/darktable/src/develop/imageop.c:1196

  This frame has 5 object(s):
    [32, 40) 'stmt'
    [96, 104) 'stmt'
    [160, 180) 'op' <== Memory access at offset 180 overflows this variable
    [224, 1248) 'path'
    [1280, 5376) 'plugindir'

SUMMARY: AddressSanitizer: stack-buffer-overflow /home/lebedevri/darktable/src/develop/imageop.c:1214 dt_iop_load_modules_so
...
==23602==ABORTING

Now, if we encounter such an iop (e.g. libexposure123456789012.so), we will simply fail to load it:
[iop_load_module] failed to open operation `exposure12345678901': /usr/local/lib/darktable/plugins/libexposure12345678901.so: cannot open shared object file: No such file or directory

While there, also add check to the CMake add_iop() macro to prevent adding such iops.

(cherry picked from commit 8bfcc8c)
LebedevRI added a commit that referenced this pull request May 17, 2015
…o module

Fixes following issue: (refs #10455, comment 3)
1. (empty history stack) change exposure
2. add new exposure iop instance
3. change exposure in second instance
4. delete that new instance
5. change exposure in original instance

=================================================================
31502ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6190023d489c at pc 0x7f073823a423 bp 0x7ffd3f9349d0 sp 0x7ffd3f9349c8
READ of size 4 at 0x6190023d489c thread T0
#0 0x7f073823a422 in dt_dev_add_history_item /home/lebedevri/darktable/src/develop/develop.c:557
#1 0x7f0711886433 in exposure_set_white /home/lebedevri/darktable/src/iop/exposure.c:661
#2 0x7f0711886882 in dt_iop_exposure_set_white /home/lebedevri/darktable/src/iop/exposure.c:682
#3 0x7f07118869e2 in exposure_callback /home/lebedevri/darktable/src/iop/exposure.c:827
#4 0x7f0735ee0503 (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x10503)
#5 0x7f0735ef9fa6 in g_signal_emit_valist (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x29fa6)
#6 0x7f0735efae49 in g_signal_emit_by_name (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x2ae49)
#7 0x7f073814fe94 in dt_bauhaus_slider_set_normalized /home/lebedevri/darktable/src/bauhaus/bauhaus.c:1937
#8 0x7f07381535c6 in dt_bauhaus_slider_scroll /home/lebedevri/darktable/src/bauhaus/bauhaus.c:1781
#9 0x7f07379ad41d (/usr/lib/x86_64-linux-gnu/libgtk-3.so.0+0x1ed41d)
#10 0x7f0735ee0503 (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x10503)
#11 0x7f0735ef9a4f in g_signal_emit_valist (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x29a4f)
#12 0x7f0735efa8fe in g_signal_emit (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x2a8fe)
#13 0x7f0737addde3 (/usr/lib/x86_64-linux-gnu/libgtk-3.so.0+0x31dde3)
#14 0x7f07379aad2d (/usr/lib/x86_64-linux-gnu/libgtk-3.so.0+0x1ead2d)
#15 0x7f07379ac93d in gtk_main_do_event (/usr/lib/x86_64-linux-gnu/libgtk-3.so.0+0x1ec93d)
#16 0x7f073754fb11 (/usr/lib/x86_64-linux-gnu/libgdk-3.so.0+0x4fb11)
#17 0x7f0735c09c3c in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x49c3c)
#18 0x7f0735c09f1f (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x49f1f)
#19 0x7f0735c0a241 in g_main_loop_run (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4a241)
#20 0x7f07379abbf4 in gtk_main (/usr/lib/x86_64-linux-gnu/libgtk-3.so.0+0x1ebbf4)
#21 0x7f073833ec96 in dt_gui_gtk_run /home/lebedevri/darktable/src/gui/gtk.c:964
#22 0x400cf3 in main /home/lebedevri/darktable/src/main.c:25
#23 0x7f07309e9b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
#24 0x400bd8 (/usr/local/bin/darktable+0x400bd8)

AddressSanitizer can not describe address in more detail (wild memory access suspected).
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/lebedevri/darktable/src/develop/develop.c:557 dt_dev_add_history_item
...
31502ABORTING
LebedevRI added a commit that referenced this pull request May 23, 2015
Fixes following LeakSanitizer-detected leaks:

Direct leak of 432 byte(s) in 1 object(s) allocated from:
    #0 0x7ff04e12c74f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7ff04df002dd in dt_get_printer_info /home/lebedevri/darktable/src/common/cups_print.c:51
    #2 0x7ff02b25d4ca
    #3 0x7ff02b261c9a
    #4 0x7ff04de9ac43 in dt_lib_load_modules /home/lebedevri/darktable/src/libs/lib.c:718
    #5 0x7ff04de9d512 in dt_lib_init /home/lebedevri/darktable/src/libs/lib.c:1008
    #6 0x7ff04dc968c7 in dt_init /home/lebedevri/darktable/src/common/darktable.c:889
    #7 0x400cb8 in main /home/lebedevri/darktable/src/main.c:24
    #8 0x7ff046501b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

Direct leak of 432 byte(s) in 1 object(s) allocated from:
    #0 0x7ff04e12c74f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7ff04df002dd in dt_get_printer_info /home/lebedevri/darktable/src/common/cups_print.c:51
    #2 0x7ff02b25d4ca
    #3 0x7ff02b25e3b2
    #4 0x7ff04b9f0503 (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x10503)
LebedevRI added a commit that referenced this pull request May 23, 2015
That was allocated in dt_accel_connect_preset_lib()

Fixes following LeakSanitizer-detected leak:
Direct leak of 112 byte(s) in 7 object(s) allocated from:
    #0 0x7f6bd60fc74f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7f6bd36ef799 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f799)
    #2 0x7f6bd5e6ff8a in dt_lib_connect_common_accels /home/lebedevri/darktable/src/libs/lib.c:1103
    #3 0x7f6bd5e731db in dt_view_manager_switch /home/lebedevri/darktable/src/views/view.c:353
    #4 0x7f6bd5cf8572 in _dt_ctl_switch_mode_to /home/lebedevri/darktable/src/control/control.c:630
    #5 0x7f6bd36eac84 in g_main_context_invoke_full (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4ac84)
LebedevRI added a commit that referenced this pull request May 23, 2015
That was allocated in dt_accel_connect_preset_iop()

Fixes following LeakSanitizer-detected leak:
Direct leak of 1616 byte(s) in 101 object(s) allocated from:
    #0 0x7fe9ab77474f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7fe9a8d67799 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f799)
    #2 0x7fe9ab3afe5d in dt_iop_connect_common_accels /home/lebedevri/darktable/src/develop/imageop.c:2784
    #3 0x7fe9874ec398
    #4 0x7fe9ab4ebf54 in dt_view_manager_switch /home/lebedevri/darktable/src/views/view.c:401
    #5 0x7fe9ab370506 in _dt_ctl_switch_mode_to /home/lebedevri/darktable/src/control/control.c:630
    #6 0x7fe9a8d62be4 in g_main_context_invoke_full (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4abe4)
codingdave added a commit to codingdave/darktable that referenced this pull request Oct 12, 2020
dtorop added a commit to dtorop/darktable that referenced this pull request Feb 5, 2021
From @parafin: "functions shouldn’t be defined in headers like this,
they must be static to avoid symbol collision. And usually they are
also marked as inline. Point being that correct fix is to add inline
keyword, not remove static. Or move definition to .c file."
@davidvj davidvj mentioned this pull request Feb 18, 2024
Jiyone pushed a commit to Jiyone/darktable that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants