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

cmsMLUgetWide produce invalid string in LCMS2.9 (twice the expected length) #163

Closed
Hombre57 opened this issue May 16, 2018 · 4 comments
Closed

Comments

@Hombre57
Copy link

Hombre57 commented May 16, 2018

On this line of code, count is 84 in LCMS2.9 while it is 42 in 2.8. The examined profile is RTv2_ACES-SP0.icc and cmsSigDeviceModelDescTag should contain g2.400000s12.923100!, which, in UTF-16, should be 42 byte long, inluding ending null chars.

Few lines below, g_utf16_to_utf8 fails to convert the 84 bytes' string (which seem logical).

@mm2 Is it a regression from 2.8 which is working fine, or did we missed something ?

Issue reported on IRC by @Beep6581 , I'll make the change in RT code but @Beep6581 will test it (Linux).

@mm2
Copy link
Owner

mm2 commented May 17, 2018

Please verify sizeof(wchar_t) on your compiler, it is quite posible it is 4 instead of 2. Then it is not UTF16.
The function returns bytes, if you want count you need to divide by sizeof(wchar_t),

@Hombre57
Copy link
Author

Thanks, didn't knew those subtleties.

@Beep6581 Here is some info about forcing gcc to use 2 bytes whar_t, with its difficulties and solutions. Could you test the -fshort-wchar solution ?

@Beep6581
Copy link

@Hombre57

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8dcf6793..8d25bdae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -376,6 +376,9 @@ if(OPTION_OMP)
     endif()
 endif()
 
+# Testing https://github.com/mm2/Little-CMS/issues/163
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fshort-wchar")
+
 # check for libfftw3f_omp
 include(CheckCSourceCompiles)
 if(OPENMP_FOUND)
Thread 62 "rawtherapee" hit Breakpoint 1, rtengine::ImProcFunctions::lab2rgbOut (this=0x7fff78002240, lab=0x7fff78003fd0, cx=0, cy=0, cw=900, ch=604, icm=..., ga=0x0) at /home/morgan/programs/code-rawtherapee/rtengine/iplab2rgb.cc:331
331                                             wchar_t *buffer = new wchar_t[count];
(gdb) bt
#0  rtengine::ImProcFunctions::lab2rgbOut (this=0x7fff78002240, lab=0x7fff78003fd0, cx=0, cy=0, cw=900, ch=604, icm=..., ga=0x0) at /home/morgan/programs/code-rawtherapee/rtengine/iplab2rgb.cc:331
#1  0x00005555562d7c4b in rtengine::(anonymous namespace)::ImageProcessor::stage_finish (this=0x7fff8d91bbe0) at /home/morgan/programs/code-rawtherapee/rtengine/simpleprocess.cc:1304
#2  0x00005555562d1e5a in rtengine::(anonymous namespace)::ImageProcessor::normal_pipeline (this=0x7fff8d91bbe0) at /home/morgan/programs/code-rawtherapee/rtengine/simpleprocess.cc:115
#3  0x00005555562d1dcb in rtengine::(anonymous namespace)::ImageProcessor::operator() (this=0x7fff8d91bbe0) at /home/morgan/programs/code-rawtherapee/rtengine/simpleprocess.cc:100
#4  0x00005555562d960e in rtengine::processImage (pjob=0x55555fcb2400, errorCode=@0x55555fcb9b10: 0, pl=0x555557c699e0, flush=false) at /home/morgan/programs/code-rawtherapee/rtengine/simpleprocess.cc:1632
#5  0x0000555555c98a55 in sigc::pointer_functor4<rtengine::ProcessingJob*, int&, rtengine::ProgressListener*, bool, rtengine::IImagefloat*>::operator() (this=0x55555fcb9b00, _A_a1=@0x55555fcb9b08: 0x55555fcb2400, _A_a2=@0x55555fcb9b10: 0, _A_a3=@0x55555fcb9b18: 0x555557c699e0, _A_a4=@0x55555fcb9b20: false) at /usr/include/sigc++-2.0/sigc++/functors/ptr_fun.h:225
#6  0x0000555555c969cd in sigc::adaptor_functor<sigc::pointer_functor4<rtengine::ProcessingJob*, int&, rtengine::ProgressListener*, bool, rtengine::IImagefloat*> >::operator()<rtengine::ProcessingJob*&, int&, rtengine::ProgressListener*&, bool&> (this=0x55555fcb9af8, _A_arg1=@0x55555fcb9b08: 0x55555fcb2400, _A_arg2=@0x55555fcb9b10: 0, _A_arg3=@0x55555fcb9b18: 0x555557c699e0, _A_arg4=@0x55555fcb9b20: false) at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:149
#7  0x0000555555c93d4e in sigc::bind_functor<-1, sigc::pointer_functor4<rtengine::ProcessingJob*, int&, rtengine::ProgressListener*, bool, rtengine::IImagefloat*>, rtengine::ProcessingJob*, int, rtengine::ProgressListener*, bool, sigc::nil, sigc::nil, sigc::nil>::operator() (this=0x55555fcb9af0) at /usr/include/sigc++-2.0/sigc++/adaptors/bind.h:1693
#8  0x0000555555c90e00 in sigc::internal::slot_call0<sigc::bind_functor<-1, sigc::pointer_functor4<rtengine::ProcessingJob*, int&, rtengine::ProgressListener*, bool, rtengine::IImagefloat*>, rtengine::ProcessingJob*, int, rtengine::ProgressListener*, bool, sigc::nil, sigc::nil, sigc::nil>, rtengine::IImagefloat*>::call_it (rep=0x55555fcb9ac0) at /usr/include/sigc++-2.0/sigc++/functors/slot.h:114
#9  0x0000555555c98e5f in sigc::slot0<rtengine::IImagefloat*>::operator() (this=0x55555fcb9aa8) at /usr/include/sigc++-2.0/sigc++/functors/slot.h:513
#10 0x0000555555c96e58 in sigc::adaptor_functor<sigc::slot0<rtengine::IImagefloat*> >::operator() (this=0x55555fcb9aa0) at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:256
#11 0x0000555555c9421d in sigc::internal::slot_call<sigc::slot0<rtengine::IImagefloat*>, rtengine::IImagefloat*>::call_it (rep=0x55555fcb9a70) at /usr/include/sigc++-2.0/sigc++/functors/slot.h:461
#12 0x0000555555c943b4 in sigc::internal::signal_emit0<rtengine::IImagefloat*, sigc::nil>::emit (impl=0x55555fcb9b30) at /usr/include/sigc++-2.0/sigc++/signal.h:705
#13 0x0000555555c91218 in sigc::signal0<rtengine::IImagefloat*, sigc::nil>::emit (this=0x55555fc98cb0) at /usr/include/sigc++-2.0/sigc++/signal.h:2800
#14 0x0000555555c8e27b in ProgressConnector<rtengine::IImagefloat*>::workingThread (this=0x55555fc98cb0) at /home/morgan/programs/code-rawtherapee/rtgui/progressconnector.h:86
#15 0x0000555555c9a74e in sigc::bound_mem_functor0<void, ProgressConnector<rtengine::IImagefloat*> >::operator() (this=0x55555fc9e5c8) at /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1991
#16 0x0000555555c9905c in sigc::adaptor_functor<sigc::bound_mem_functor0<void, ProgressConnector<rtengine::IImagefloat*> > >::operator() (this=0x55555fc9e5c0) at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:256
#17 0x0000555555c970b3 in sigc::internal::slot_call0<sigc::bound_mem_functor0<void, ProgressConnector<rtengine::IImagefloat*> >, void>::call_it (rep=0x55555fc9e590) at /usr/include/sigc++-2.0/sigc++/functors/slot.h:114
#18 0x00007ffff43e1172 in ?? () from /usr/lib64/libglibmm-2.4.so.1
#19 0x00007ffff52543f8 in ?? () from /usr/lib64/libglib-2.0.so.0
#20 0x00007ffff10aaa53 in ?? () from /lib64/libpthread.so.0
#21 0x00007ffff0de22df in clone () from /lib64/libc.so.6
(gdb) print buffer
$1 = 0x44a36bd9449bdd09 <error: Cannot access memory at address 0x44a36bd9449bdd09>
(gdb) step
[LWP 10674 exited]
332                                             count = cmsMLUgetWide(modelDescMLU, "eng", "USA", buffer, count); // now put the string in the buffer
(gdb) print buffer
$2 = 0x7fff78001200 L"\x268\x7800", <incomplete sequence \x7fff>
(gdb) x/84bu 0x7fff78001200
0x7fff78001200: 104     2       0       120     255     127     0       0
0x7fff78001208: 104     2       0       120     255     127     0       0
0x7fff78001210: 144     18      0       120     255     127     0       0
0x7fff78001218: 0       0       0       0       0       0       0       0
0x7fff78001220: 16      18      0       120     255     127     0       0
0x7fff78001228: 0       0       0       0       0       0       0       0
0x7fff78001230: 128     18      0       120     255     127     0       0
0x7fff78001238: 0       0       0       0       0       0       0       0
0x7fff78001240: 176     18      0       120     255     127     0       0
0x7fff78001248: 0       0       0       0       0       0       0       0
0x7fff78001250: 192     18      0       120
(gdb) c
Continuing.

(rawtherapee:10497): glibmm-ERROR **:
unhandled exception (type std::exception) in signal handler:
what: stod

@mm2
Copy link
Owner

mm2 commented May 18, 2018

Not sure about what you are reporting here. The lcms function just reads the codes, with no interpretation.

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

No branches or pull requests

3 participants