darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.77k stars 1.14k forks source link

DT 3.3.0+1440 : Zoomed in and Retouch crashes DT #6805

Closed chhil closed 3 years ago

chhil commented 4 years ago

Retouched imaged, zoomed in to further retouch image.

Windows. this is darktable 3.3.0+1440~g44fe67e70 reporting an exception:


Error occurred on Monday, November 9, 2020 at 12:50:47.

darktable.exe caused an Access Violation at location 000000006E941AFC in module libborders.dll Writing to location 00000000971CE000.

AddrPC           Params
000000006E941AFC 0000000007F72700 00007FF9893D2EF8 0000000000000000  libborders.dll!set_outer_border_sse._omp_fn.0  [C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0/include/xmmintrin.h @ 980]
   978: _mm_store_ps (float *__P, __m128 __A)
   979: {
>  980:   *(__m128 *)__P = __A;
   981: }
   982: 
00007FF969D8DE30 00000000561730F0 0000000000000000 0000000000000000  libgomp-1.dll!omp_in_final
00007FF9893D4F33 0000000056075460 0000000000000000 00000000561730F0  libwinpthread-1.dll!pthread_create_wrapper
00007FF9AC53B04A 00007FF9AC5906D0 00000000561730F0 0000000000000000  msvcrt.dll!_beginthreadex
00007FF9AC53B11C 0000000000000000 0000000000000000 0000000000000000  msvcrt.dll!_endthreadex
00007FF9AAC87C24 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF9ACA8CEA1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart
chhil commented 4 years ago

Got a similar stack trace on zoom to 50% and scrolling center bar to right. darktable_bt_DWIWT0.txt


AddrPC           Params
000000006E941AFC 000000006E941A30 00000000061CEDC0 05367EBA00000008  libborders.dll!set_outer_border_sse._omp_fn.0  [C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0/include/xmmintrin.h @ 980]
   978: _mm_store_ps (float *__P, __m128 __A)
   979: {
>  980:   *(__m128 *)__P = __A;
   981: }
   982: 
00007FF95E736DC9 0100010100010102 0100020102000201 000000013FFF03FE  libgomp-1.dll!GOMP_parallel
000000006E942D85 00000000061CF080 0000000000000000 0000000087230080  libborders.dll!process  [C:/msys64/home/chill/darktable/src/iop/borders.c @ 368]
   366:   const __m128 color = _mm_load_ps(col);
   367: #ifdef _OPENMP
>  368: #pragma omp parallel for default(none) \
   369:   dt_omp_firstprivate(buf, col, border_height, height, width, color)  \
   370:   schedule(static)
00000000636F2B76 00000000001285D0 B5A89EDB9F862353 00000000061CEFF8  libdarktable.dll!pixelpipe_process_on_CPU  [C:/msys64/home/chill/darktable/src/develop/pixelpipe_hb.c @ 1015]
  1013:   else
  1014:   {
> 1015:     module->process(module, piece, input, *output, roi_in, roi_out);
  1016:     *pixelpipe_flow |= (PIXELPIPE_FLOW_PROCESSED_ON_CPU);
  1017:     *pixelpipe_flow &= ~(PIXELPIPE_FLOW_PROCESSED_ON_GPU | PIXELPIPE_FLOW_PROCESSED_WITH_TILING);
00000000636F40BD 0000000004DCEE50 0000000000000000 00000000061CF758  libdarktable.dll!dt_dev_pixelpipe_process_rec  [C:/msys64/home/chill/darktable/src/develop/pixelpipe_hb.c @ 1876]
  1874:       /* opencl is not inited or not enabled or we got no resource/device -> everything runs on cpu */
  1875: 
> 1876:       if (pixelpipe_process_on_CPU(pipe, dev, input, input_format, &roi_in, output, out_format, roi_out,
  1877:                                    module, piece, &tiling, &pixelpipe_flow))
  1878:         return 1;
00000000636F466C 0000000002E71140 00000000613C7133 00000000061CF758  libdarktable.dll!dt_dev_pixelpipe_process_rec  [C:/msys64/home/chill/darktable/src/develop/pixelpipe_hb.c @ 1106]
  1104:     if(!piece->enabled
  1105:        || (dev->gui_module && dev->gui_module->operation_tags_filter() & module->operation_tags()))
> 1106:       return dt_dev_pixelpipe_process_rec(pipe, dev, output, cl_mem_output, out_format, &roi_in,
  1107:                                           g_list_previous(modules), g_list_previous(pieces), pos - 1);
  1108:   }
00000000636F3C6A 0000000000000000 0000000000000000 00000000061CFAC8  libdarktable.dll!dt_dev_pixelpipe_process_rec  [C:/msys64/home/chill/darktable/src/develop/pixelpipe_hb.c @ 1231]
  1229:     piece->processed_roi_out = *roi_out;
  1230: 
> 1231:     if(dt_dev_pixelpipe_process_rec(pipe, dev, &input, &cl_mem_input, &input_format, &roi_in,
  1232:                                     g_list_previous(modules), g_list_previous(pieces), pos - 1))
  1233:       return 1;
00000000636F7C82 0000000001680000 00007FF9ACA5B9A7 0000000001620000  libdarktable.dll!dt_dev_pixelpipe_process  [C:/msys64/home/chill/darktable/src/develop/pixelpipe_hb.c @ 2134]
  2132: {
  2133:   dt_pthread_mutex_lock(&pipe->busy_mutex);
> 2134:   int ret = dt_dev_pixelpipe_process_rec(pipe, dev, output, cl_mem_output, out_format, roi_out, modules, pieces, pos);
  2135: #ifdef HAVE_OPENCL
  2136:   // copy back final opencl buffer (if any) to CPU
00000000636A5244 0000000000000000 0000000002E7D330 0000000000000000  libdarktable.dll!dt_dev_process_image_job  [C:/msys64/home/chill/darktable/src/develop/develop.c @ 595]
   593: 
   594:   dt_get_times(&start);
>  595:   if(dt_dev_pixelpipe_process(dev->pipe, dev, x, y, wd, ht, scale))
   596:   {
   597:     // interrupted because image changed?
0000000063685BD1 00000000061CFEA8 00007FF9AC519DA0 00000000863BDD08  libdarktable.dll!dt_dev_process_image_job_run  [C:/msys64/home/chill/darktable/src/control/jobs/develop_jobs.c @ 55]
    53: {
    54:   dt_develop_t *dev = dt_control_job_get_params(job);
>   55:   dt_dev_process_image_job(dev);
    56:   return 0;
    57: }
000000006367F765 0000000004CB1FC0 0000000000000000 0000000000000000  libdarktable.dll!dt_control_work_res  [C:/msys64/home/chill/darktable/src/control/jobs.c @ 215]
   213: 
   214:     /* execute job */
>  215:     job->result = job->execute(job);
   216: 
   217:     dt_control_job_set_state(job, DT_JOB_STATE_FINISHED);
00007FF96B204F33 0000000004CB2E40 0000000000000000 0000000004CB1FC0  libwinpthread-1.dll!pthread_create_wrapper
00007FF9AC53B04A 00007FF9AC5906D0 0000000004CB1FC0 0000000000000000  msvcrt.dll!_beginthreadex
00007FF9AC53B11C 0000000000000000 0000000000000000 0000000000000000  msvcrt.dll!_endthreadex
00007FF9AAC87C24 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF9ACA8CEA1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart
parafin commented 4 years ago

May be related to #6801 if it's due to unaligned memory. I guess something has changed in regard to buffer allocation...

ralfbrown commented 4 years ago

Not buffer allocations -- _mm_load_ps and _mm_store_ps simply don't segfault on my machine, so I didn't catch that I was doing unaligned accesses when the image width is not a multiple of four.

chhil commented 4 years ago

Still crashes on current master, please could it be reopened.

git pull shows start and end of commits. From git://github.com/darktable-org/darktable 44fe67e70..5bfa1f2ed master -> origin/master

this is darktable 3.3.0+1463~g5bfa1f2ed reporting an exception:


Error occurred on Tuesday, November 10, 2020 at 10:52:58.

darktable.exe caused an Access Violation at location 000000006E941AFC in module libborders.dll Writing to location 00000000AA17C000.


AddrPC           Params
000000006E941AFC 0000000006242700 00007FF98C8B2EF8 0000000000000000  libborders.dll!set_outer_border_sse._omp_fn.0  [C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0/include/xmmintrin.h @ 980]
   978: _mm_store_ps (float *__P, __m128 __A)
   979: {
>  980:   *(__m128 *)__P = __A;
   981: }
   982: 
00007FF988D9DE30 000000005DF1FF90 0000000000000000 0000000000000000  libgomp-1.dll!omp_in_final
00007FF98C8B4F33 0000000053F1B520 0000000000000000 000000005DF1FF90  libwinpthread-1.dll!pthread_create_wrapper
00007FF9AC53B04A 00007FF9AC5906D0 000000005DF1FF90 0000000000000000  msvcrt.dll!_beginthreadex
00007FF9AC53B11C 0000000000000000 0000000000000000 0000000000000000  ms
ralfbrown commented 3 years ago

Do you still get a crash with "darktable --conf codepaths/SSE2=false" ? The new SSE codepath writes to exactly the same memory locations as the preexisting scalar codepath does, so if that version crashes with recent master, it has something to do with the buffer allocation.

I'll need an image and .xmp that triggers the crash to debug this.

chhil commented 3 years ago

It randomly happened once. If I can reproduce it on the image again I will share it.

chhil commented 3 years ago

@ralfbrown

"darktable --conf codepaths/SSE2=false" ?

I have never tried this.

The image xmp and current backtrace can be found here.

I had the crop module opened. I used the zoom to 100%. Opened closed the crop module and it crashed.

chhil commented 3 years ago

Image is initially fit to window. A zoom to 100% crashes it. Reproducible on windows always.

On my linux ubuntu 20 build running on wsl for windows does not crash.

chhil commented 3 years ago

Linux crash update.

mchhil@DESKTOP-MKCA8HN:~/darktable$ /opt/darktable/bin/darktable --version
this is darktable 3.3.0+1480~g0781e97ea
copyright (c) 2009-2020 johannes hanika
darktable-dev@lists.darktable.org

compile options:
  bit depth is 64 bit
  normal build
  SSE2 optimized codepath enabled
  OpenMP support enabled
  OpenCL support enabled
  Lua support enabled, API version 6.1.0
  Colord support enabled
  gPhoto2 support enabled
  GraphicsMagick support enabled
  ImageMagick support disabled
  OpenEXR support enabled

Same image, zoom 100%. Doesn't crash.

Then open and close different modules, it will crash.

On the shell I get the following but nothing is writtent to the /tmp folder.

mchhil@DESKTOP-MKCA8HN:~/darktable$ /opt/darktable/bin/darktable
an error occurred while trying to execute gdb. please check if gdb is installed on your system.
backtrace written to /tmp/darktable_bt_O6GGT0.txt
Segmentation fault (core dumped)
chhil commented 3 years ago

The linux backtrace obtained after installing gdb.

darktable_bt_KS0IT0.txt

TurboGit commented 3 years ago

Thanks for all the details. Can you try #6835.

chhil commented 3 years ago

I changed the 4 lines of borders.c and built it on linux and ran it. Performed the same steps and it crashed. This time no backtrace though. got a Segmentation fault (core dumped).

Windows , I am building it, it takes time. Will test it later.

chhil commented 3 years ago

Windows build fails as soon as I do a 100% zoom. Dialog shows backtrace created but there is no data in the backtrace file.

TurboGit commented 3 years ago

Too bad and I cannot reproduce... We really need a backtrace, maybe some other instances of non aligned memory access.

chhil commented 3 years ago

I can confirm the image + xmp that was shared in this issue no longer crashes current master DT build on my linux system.