Link error when compiling with -fsanitize=undefined
Scott Kostyshak
skostysh at lyx.org
Fri Sep 17 18:21:54 UTC 2021
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 <skostysh at lyx.org>:
> >
> > > 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210917/e90672df/attachment.asc>
More information about the lyx-devel
mailing list