Re: Link error when compiling with -fsanitize=undefined
On Fri, Sep 17, 2021 at 10:22:28PM +0200, Kornel Benko wrote: > Am Fri, 17 Sep 2021 20:24:17 +0200 > schrieb Jean-Marc Lasgouttes : > > > Le 17/09/2021 à 20:21, Scott Kostyshak a écrit : > > > /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of > > > value 128, > > > which is not a valid value for type 'ColorCode' > > > /usr/include/c++/10/tuple:1693:70: > > > runtime error: load of value 128, which is not a valid value for type > > > 'ColorCode' /usr/include/c++/10/bits/stl_function.h:386:20: runtime > > > error: load of > > > value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:366:35: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:367:39: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:457:17: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:10: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:31: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:55: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:536:13: > > > runtime error: > > > load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:174:6: > > > runtime > > > error: load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:179:9: > > > runtime > > > error: load of value 128, which is not a valid value for type > > > 'ColorCode' > > > /home/scott/lyxbuilds/master/repo/src/support/Changer.h:41:59: runtime > > > error: load of value 128, which is not a valid value for type > > > 'ColorCode' > > > /home/scott/lyxbuilds/master/repo/src/support/Changer.h:45:56: runtime > > > error: load of value 128, which is not a valid value for type > > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:191:9: > > > runtime error: > > > load of value 128, which is not a valid value for type 'ColorCode' > > > > > > I don't have time to study how to fix it, but at least I can note it here > > > in case > > > anyone does. > > > > This seems more interesting indeed. Looks like the same value > > everywhere. I suspect we create synthetic color values in some > > circumstances. > > > > JMarc > > Seems, like an option for sanitize in cmake would be handy. > LYX_OPTION(DEBUG_SANITIZE "Enable sanitize check" OFF GCC) > > ... > if (LYX_DEBUG_SANITIZE) > # some magic statements > endif() > > Kornel That would be nice but might be some work and I don't know if others are interested. I think it's nice because the run-time hit on performance isn't bad. For example, with -fsanitize=undefined, I don't even notice it is slower. With ASAN it is noticeably slower (although still usable as opposed to using LyX with Valgrind). Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: Link error when compiling with -fsanitize=undefined
Am Fri, 17 Sep 2021 20:24:17 +0200 schrieb Jean-Marc Lasgouttes : > Le 17/09/2021 à 20:21, Scott Kostyshak a écrit : > > /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of > > value 128, > > which is not a valid value for type 'ColorCode' > > /usr/include/c++/10/tuple:1693:70: > > runtime error: load of value 128, which is not a valid value for type > > 'ColorCode' /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: > > load of > > value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:366:35: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:367:39: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:457:17: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:10: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:31: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:55: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:536:13: runtime > > error: > > load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:174:6: > > runtime > > error: load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:179:9: > > runtime > > error: load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:41:59: > > runtime > > error: load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:45:56: > > runtime > > error: load of value 128, which is not a valid value for type > > 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:191:9: runtime > > error: > > load of value 128, which is not a valid value for type 'ColorCode' > > > > I don't have time to study how to fix it, but at least I can note it here > > in case > > anyone does. > > This seems more interesting indeed. Looks like the same value > everywhere. I suspect we create synthetic color values in some > circumstances. > > JMarc Seems, like an option for sanitize in cmake would be handy. LYX_OPTION(DEBUG_SANITIZE "Enable sanitize check" OFF GCC) ... if (LYX_DEBUG_SANITIZE) # some magic statements endif() Kornel pgpfpFgR9Osbt.pgp Description: Digitale Signatur von OpenPGP -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: Link error when compiling with -fsanitize=undefined
Le 17/09/2021 à 20:21, Scott Kostyshak a écrit : /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /usr/include/c++/10/tuple:1693:70: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:366:35: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:367:39: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:457:17: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:10: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:31: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:55: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:536:13: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:174:6: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:179:9: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:41:59: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:45:56: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:191:9: runtime error: load of value 128, which is not a valid value for type 'ColorCode' I don't have time to study how to fix it, but at least I can note it here in case anyone does. This seems more interesting indeed. Looks like the same value everywhere. I suspect we create synthetic color values in some circumstances. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: Link error when compiling with -fsanitize=undefined
On Fri, Sep 17, 2021 at 12:11:46PM +0200, Jean-Marc Lasgouttes wrote: > Le 16/09/2021 à 22:13, Kornel Benko a écrit : > > Am Thu, 16 Sep 2021 15:12:34 -0400 > > schrieb Scott Kostyshak : > > > > > I was curious about compiling with -fsanitize=undefined. > > > > > > When building (with CMake), I get the following: > > > > -lz /usr/bin/ld: > > > CMakeFiles/tex2lyx.dir/dummy_impl.cpp.o:(.data.rel+0x118): undefined > > > reference to `typeinfo for lyx::xml::FontTag' collect2: error: ld > > > returned 1 exit status > > > > > > Any tip on how to solve this? > > > > We may need to include src/xml.cpp to the list of files for tex2lyx. > > (line src/tex2lyx/CMakeLists.txt:13) > > It is because we use dummy versions of some structures in order to limit the > external code required in tex2lyx. This means that the virtual functions > declared in the .h files are in general not implemented in the tex2lyx part. > I do not think that adding the file is a good idea, since as you saw it > means re-adding lots of code. Remember that the previous situation was that > we had to compile the same .cpp file into a normal and a tex2lyx version. > This was awful. > > What would a clean solution be? Looking at dummy_impl.cpp, I see > > 1/ Alert(). This could be a signal, that could be bound properly as needed. > > 2/ getMessages/getGuiMessages. Could be a signal too. > > 3/ Formats: this is nonsense. Lexer should rely on gzstream to read zipped > files seamlessly (it will do the right thing when the stream is not zipped, > AFAIU). There is no need to rely on Formats there. This would allow to move > it to support/. This has been on a todo list of mine for some time, but not > deemed uergent. Feel free to try. > > 4/ LaTeXFeatures: not sure. > > 5/ alignmentToCSS. This helper function should probably be moved elsewhere. > > 6/ lyx_exit. Maybe a signal again? > > 7/ StartTag stuff. I do not remember why this is needed. What happens if you > remove it? > > I think this stuff in dummy_functions.cpp should be seen as indication that > our code is not cleanly separated enough. Thank you for breaking down the issue, JMarc. I could see that something tricky was going on but I didn't understand the purpose, or what possible alternatives would be. I followed Kornel's approach of just compiling the main LyX binary with the option. It seemed to work, and I might have gotten something useful: /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /usr/include/c++/10/tuple:1693:70: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /usr/include/c++/10/bits/stl_function.h:386:20: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:366:35: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:367:39: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:457:17: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:10: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:31: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:435:55: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:536:13: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:174:6: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/MetricsInfo.cpp:179:9: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:41:59: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/support/Changer.h:45:56: runtime error: load of value 128, which is not a valid value for type 'ColorCode' /home/scott/lyxbuilds/master/repo/src/Color.cpp:191:9: runtime error: load of value 128, which is not a valid value for type 'ColorCode' I don't have time to study how to fix it, but at least I can note it here in case anyone does. Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: Link error when compiling with -fsanitize=undefined
Le 16/09/2021 à 22:13, Kornel Benko a écrit : Am Thu, 16 Sep 2021 15:12:34 -0400 schrieb Scott Kostyshak : I was curious about compiling with -fsanitize=undefined. When building (with CMake), I get the following: -lz /usr/bin/ld: CMakeFiles/tex2lyx.dir/dummy_impl.cpp.o:(.data.rel+0x118): undefined reference to `typeinfo for lyx::xml::FontTag' collect2: error: ld returned 1 exit status Any tip on how to solve this? We may need to include src/xml.cpp to the list of files for tex2lyx. (line src/tex2lyx/CMakeLists.txt:13) It is because we use dummy versions of some structures in order to limit the external code required in tex2lyx. This means that the virtual functions declared in the .h files are in general not implemented in the tex2lyx part. I do not think that adding the file is a good idea, since as you saw it means re-adding lots of code. Remember that the previous situation was that we had to compile the same .cpp file into a normal and a tex2lyx version. This was awful. What would a clean solution be? Looking at dummy_impl.cpp, I see 1/ Alert(). This could be a signal, that could be bound properly as needed. 2/ getMessages/getGuiMessages. Could be a signal too. 3/ Formats: this is nonsense. Lexer should rely on gzstream to read zipped files seamlessly (it will do the right thing when the stream is not zipped, AFAIU). There is no need to rely on Formats there. This would allow to move it to support/. This has been on a todo list of mine for some time, but not deemed uergent. Feel free to try. 4/ LaTeXFeatures: not sure. 5/ alignmentToCSS. This helper function should probably be moved elsewhere. 6/ lyx_exit. Maybe a signal again? 7/ StartTag stuff. I do not remember why this is needed. What happens if you remove it? I think this stuff in dummy_functions.cpp should be seen as indication that our code is not cleanly separated enough. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: Link error when compiling with -fsanitize=undefined
Am Thu, 16 Sep 2021 21:12:38 -0400 schrieb Scott Kostyshak : > On Thu, Sep 16, 2021 at 10:13:15PM +0200, Kornel Benko wrote: > > Am Thu, 16 Sep 2021 15:12:34 -0400 > > schrieb Scott Kostyshak : > > > > > I was curious about compiling with -fsanitize=undefined. > > > > > > When building (with CMake), I get the following: > > > > > > [ 93%] Linking CXX executable ../../bin/tex2lyx > > > cd /home/scott/lyxbuilds/master/CMakeBuild/src/tex2lyx && /usr/bin/cmake > > > -E > > > cmake_link_script CMakeFiles/tex2lyx.dir/link.txt --verbose=1 > > > /usr/lib/ccache/c++ > > > -Wall -Wextra -Wno-deprecated-copy --std=c++20 -DENABLE_ASSERTIONS=1 > > > -fsanitize=undefined -fno-strict-aliasing -O0 -g3 -D_DEBUG > > > -fsanitize=undefined > > > -rdynamic CMakeFiles/tex2lyx.dir/Context.cpp.o > > > CMakeFiles/tex2lyx.dir/Parser.cpp.o > > > CMakeFiles/tex2lyx.dir/Preamble.cpp.o CMakeFiles/tex2lyx.dir/boost.cpp.o > > > CMakeFiles/tex2lyx.dir/dummy_impl.cpp.o CMakeFiles/tex2lyx.dir/math.cpp.o > > > CMakeFiles/tex2lyx.dir/table.cpp.o CMakeFiles/tex2lyx.dir/tex2lyx.cpp.o > > > CMakeFiles/tex2lyx.dir/text.cpp.o > > > CMakeFiles/tex2lyx.dir/__/graphics/GraphicsParams.cpp.o > > > CMakeFiles/tex2lyx.dir/__/insets/ExternalTemplate.cpp.o > > > CMakeFiles/tex2lyx.dir/__/insets/ExternalTransforms.cpp.o > > > CMakeFiles/tex2lyx.dir/__/insets/InsetLayout.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Author.cpp.o > > > CMakeFiles/tex2lyx.dir/__/CiteEnginesList.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Color.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Counters.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Encoding.cpp.o > > > CMakeFiles/tex2lyx.dir/__/FloatList.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Floating.cpp.o > > > CMakeFiles/tex2lyx.dir/__/FontInfo.cpp.o > > > CMakeFiles/tex2lyx.dir/__/LaTeXPackages.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Layout.cpp.o > > > CMakeFiles/tex2lyx.dir/__/LayoutFile.cpp.o > > > CMakeFiles/tex2lyx.dir/__/LayoutModuleList.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Lexer.cpp.o > > > CMakeFiles/tex2lyx.dir/__/ModuleList.cpp.o > > > CMakeFiles/tex2lyx.dir/__/TextClass.cpp.o > > > CMakeFiles/tex2lyx.dir/__/Spacing.cpp.o > > > CMakeFiles/tex2lyx.dir/__/version.cpp.o > > > -o ../../bin/tex2lyx ../../lib/libsupport.a > > > -lmagic /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.15.2 > > > /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.2 > > > -lz /usr/bin/ld: > > > CMakeFiles/tex2lyx.dir/dummy_impl.cpp.o:(.data.rel+0x118): > > > undefined reference to `typeinfo for lyx::xml::FontTag' collect2: error: > > > ld > > > returned 1 exit status > > > > > > Any tip on how to solve this? > > > > > > Scott > > > > We may need to include src/xml.cpp to the list of files for tex2lyx. > > (line src/tex2lyx/CMakeLists.txt:13) > > Thanks! Your suggestion worked for this linker error, but then I got new > linker errors. > I kept adding to the list, but I keep getting new linker errors. Currently I > have the > following: > > --- a/src/tex2lyx/CMakeLists.txt > +++ b/src/tex2lyx/CMakeLists.txt > @@ -14,7 +14,7 @@ foreach(_src graphics/GraphicsParams insets/ExternalTemplate > insets/ExternalTransforms insets/InsetLayout Author CiteEnginesList > Color > Counters Encoding FloatList Floating FontInfo LaTeXPackages Layout > LayoutFile LayoutModuleList Lexer ModuleList TextClass > - Spacing version) > + Spacing version xml Layout Paragraph BufferParams) > list(APPEND LINKED_sources ${TOP_SRC_DIR}/src/${_src}.cpp) > list(APPEND LINKED_headers ${TOP_SRC_DIR}/src/${_src}.h) > endforeach(_src) > > But I still get linker errors. I can keep proceeding to add them individually > if that > is what we need to do. But I wanted to check to make sure that's what we > should do. > > I should add that being able to compile with -fsanitize=undefined is not so > important. > If this seems like a tricky issue, I am fine to give up for now :) > > Scott We could omit the flag for tex2lyx compilation. I suppose, we need this flag only for the lyx-executable. So adding the flags in src/CMakeLists.txt as add_compile_options("-fsanitize=undefined") ... target_link_options(${_lyx} "-fsanitize=undefined") Hope this is correct. Kornel pgpkvk1CBJEos.pgp Description: Digitale Signatur von OpenPGP -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel