-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
fpclibcmm.pas and signed symbol table. #211
Comments
Thanks for the feedback. IIRC it is not only about the symbol name itself. It is also about the whole library name. I usually resolve this potential issue by tuning the actual libc used at compilation time. So this is not specific to mORMot, but to the whole FPC tool chain. |
For instance, when compiled on a new Debian stable:
|
Hello. In case you dont want to risk future problem if a new table is assigned for the methods you use, just assign the GLIBC_2.2.5 for x86-64 and GLIBC_2.0 for i386, like this:
[EDIT] Changed defined(x86_64) with defined(cpux86_64) and defined(i386) with defined(cpui386) . |
Are you sure it is enough to work, especiallly if e.g. malloc() is defined as plain 'malloc' in another part of the project ? |
Not sure to understand, malloc() is unique but libc.so.6, depending of the version, can deal with many symbol tables for the malloc() method. Each symbol signed table works like a filter to warn the method that it should use the particularities of the assigned table. But maybe I did not catch the question. |
FPC - libc.pp was developed for x86_64, with the table GLIBC_2.2.5 with his particularities, like the stat record (but sadly FPC did not assign it for each libc.so.6 methods and at linking, because no signature was assigned, the linker assign the last table of the system, that can have other particularities than 2.2.5. and create problems. For Linux i386, FPC used GLIBC_2.0. |
Yes, I am totally sure, with lot of deep tests, that assigning the right table works. Note too that only Linux on x86_64 and i386 give problems. |
To check what table was assigned for each method in your binary, just do:
If there are some methods with > @GLIBC_2.2.5, like @GLIBC_2.34, it could have problems. [EDIT] In code of previous post, please note the change defined(x86_64) with defined(cpux86_64) and defined(i386) with defined(cpui386) . |
My concern is that even if I change all names to include the suffix, I still get the following error when compiling on a recent Linux and executing on an older Linux:
Do you know by chance how to specify the GLIBC needed when linking? |
here is the full
|
It sounds like the FPC RTL is the culprit. The GLIBC_2.33 is required for pthread calls, and also at lower level for |
Even the libc did change in its inialization section: they introduced a new |
synopse: if one does not already exist, try creating a symlink libdl.so that points to libdl.so.2 then compile again: sudo ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so fredvs told me about this a few weeks back, and i remember (i think) it solved a similar problem. cheers, |
@robert-rozee
and the main problem would remain anyway:
I don't see anything else than (cross-)compile from an old system |
Easy trick if you dont want to wait centuries that fpc fix it. Use fpc-ootb : https://github.com/fredvs/freepascal-ootb/releases/ You may test the "timeless" version of LazPaint compiled wit fpc-ootb: |
- on Linux Intel/AMD - see discussion at #211 for more information
When I look at https://forum.lazarus.freepascal.org/index.php?topic=58888.msg486611#msg486611 I am not confident your changes would ever be included in the trunk. |
Always the same strategy of Marcov, trying to impress with lots of complicated notions that have absolutely nothing to do. And of course he knows better how to use libc.so.6 than main-dev-libc Forian Weimer. I never doubted for a second that Marcov would accept these changes. I think Robert Rozee and I did everything we could to show the Big-Bug. Now if they don't want to fix it, too bad, I'm the maintainer of the MSEgui project and users are entitled to have a working binary, and the whole thing of compiling on an old distro is pure tinkering. |
It is sad, but it makes sense. Perhaps we could work with @LongDirtyAnimAlf to patch the RTL source directly in fpcupdeluxe? Do you have any documentation about how to use your stand-alone FPC compiler? |
With pleasure but @LongDirtyAnimAlf said that he wanted collaboration of fpc-dev:
Example:
Note that I will not do publicity for fpc-ootb, it is there only for convenience and, of course, if fpc commit the change, I will be happy to delete that fpc-ootb project. |
I tried the OOTB compiler by putting My guess is that @LongDirtyAnimAlf knows that any such patch is likely to be never included in the FPC RTL. |
Ooops, I did it too fast yesterday, I forgot to add the /tools directory. |
Hello. I try to run the build_fpc.sh with "original" fpc 3.2.2. and get that error:
With ootb and with fpres in /tools, I get the same error. Sure I miss something. |
you need to download the |
Ha, ok, I will jump into it tonight. |
OK, I get it and it compiles with fpc-ootb + /tools/fpres:
But I am disappointed...
There are same methods with 2 different tables assigned, like: 0000000000000000 DF UND 0000000000000000 (GLIBC_2.34) dlopen 0000000000000000 DF UND 0000000000000000 (GLIBC_2.2.5) dlclose 0000000000000000 DF UND 0000000000000000 (GLIBC_2.34) dlerror With official fpc there are only methods with (GLIBC_2.34) and with fpc-ootb, all apps tested have only (GLIBC_2.2.5), maybe it is good to have both (but I would prefer only 2.2.5). But there are good news only one table for __libstart_main and it is 2.2.5. ;-) And, like you noted, all the *.inc of cthreads.pp need to be patched too, this is for tonight. So remain a shadow, what if 2 tables are defined for a unique method, does libc.so.6 give the choice between 2 tables and use the newer if present? It should be nice but not ok for fpc, better only one table (or more code). What a fight! |
Do you know if mormot uses netwlibc ? Because there are defined dlopen, dlclose, dlerror,... too (without signature). There is also /fpc/packages/sqlite/src/sqlite3.inc where dlopen, dlclose, dlerror,... are declared too. If yes, that could explain why 2 tables are assigned. And those units/inc should be patched too. Mama mia. |
Some news from the front... Ok, ootb has all pthreads and friends methods with + LIBC_SUFFIX. The compiled release for Linux amd64 with /tools is here : And the compiled release for Linux i386 with /tools is there : I did try the mormot build_fpc.sh and it compiles ok. But doing I still get those: 0000000000000000 DF UND 0000000000000000 (GLIBC_2.34) pthread_join And with this some double table; 0000000000000000 DF UND 0000000000000000 (GLIBC_2.34) dlerror I did try in /mORMot2-master/src/core/mormot.core.os.posix.inc adding + LIBC_SUFFIX for each method, appart for sched_getaffinity who needs @GLIBC_2.3.4. But it did not help, the 2.34 tables are still there. I dont see why at the moment. It is very strange because with LazPaint compiled with ootb there is this:
0000000000000000 DF UND 0000000000000000 (GLIBC_2.2.5) wcrtomb And with all my msegui apps, even some using db there is this:
0000000000000000 DF UND 0000000000000000 (GLIBC_2.2.5) realloc I dont see at the moment why there is still 2.34 with mormot. I have to pause the combat, I need to sleep now. Fre;D |
use grep to search for occurrences of dlopen in the source tree of both ootb and the project you are compiling. there may be a function called dlopen with an external that has NO name parameter, or an external that specifies an UNVERSIONED dlopen symbol. fred: i am thinking that we had not considered externals to dlopen in user code or libraries. perhaps the compiler should halt with an error if it sees multiple versions of the same symbol? cheers, |
I have made the modifications. Now I don't have any issue reported, BUT there is an GPF when executing on an old Linux distribution:
:( @fredvs |
These patches are huge. Every libc call needs to be changed. It will be nearly impossible to track FPC-compiler and -rtl changes to be sure that this patch will succeed. |
Hello everybody.
Hum, by chance, do you know what commit in FPC 3.3.1 did fix the problem about variant? Thanks. Fre;D |
My link above in the mORMot/Synopse forum redirected to: I still don't understand what is wrong with the patched sqlilte3.o redirection, which triggers a GPF on old distributions. |
I will jump into it asap but what old distribution are you using, with what last symbol table?
Ha, ok, perfect, I will deeply study it and apply the fix in fpc-ootb if possible, Thanks. |
Yep, many thanks for the links, patch done for fpc-ootb.
That's the way I like it! You may try with the last re-compiled release: Linux i386: |
@LongDirtyAnimAlf Honestly, I don't see the relevance of using a .inc file, because we would need several files. We could just use a local constant. And some of the API entries do not involve the same suffix. @fredvs About the GPF on my old Ubuntu 16.04 machine, the culprit seems to be pthread_mutexattr_init as redirected from sqlite3.o.
I also tried on a good old |
Yeeep and now you may produce timeless mORMot applications! Many thanks for your attention, it is a pleasure to explore that jungle with you all. |
Hum, maybe trying with ootb that allows to link libraries with extended so number? Ok, ok, I leave, I promised to not do propaganda. |
- static pthread call did fail on some systems - runtime resolution seems fine on old distributions - we already have a pthread library loaded by mormot.core.os.posix.inc anyway - see #211 (comment)
About OpenSSL, we just can distribute the OpenSSL 1.1 or 3.x libraries with the executable, and mORMot does late-binding to it anyway. |
Hum, now that I do understand better the magic of signed symbol table, it seems to me that it would not be a bad idea if OpenSSL devs had opted for such magic in OpenSSL. But ok, your LUTI integration does the magic. |
@LongDirtyAnimAlf @fredvs Also note that |
If I propose a patch, Marcov will directly refuse it.
It will do a patch from official fpc 3.2.2 to last fpc-ootb commit.
Ha, ok, thanks for this, I will restore the original asap. Fre;D |
I need some advice on the following calls towards libc. The listed function need another GLIBC version, as stated in the list.
|
Hum, not sure for this. Note that with all the new changes maybe I am wrong now. |
Maybe using "extended custom" LIBC_SUFFIX?
Example: |
do any of us have the ability to extend the compiler back-end to add a parameter to external? if so, then consider adding an optional parameter useBASE | useAUTO | useNONE. useBASE would trigger the compiler to search the shared library for all occurrences of the glibc function name, and then match to the BASE one (earliest in list of version numbers). it would use readelf to do this; useAUTO would do the same, but search for the name containing "@@". this would behave much the same as existing, but take the search for "@@" away from the linker; useNONE would be for future use, so once we figure out how to stop the linker from versioning any unversioned symbols we can create binaries without any symbol versioning. then the patch to the RTL would just require appending useBASE after each external statement. see my last posting on the fpc forum where i mention this as an addendum. it is a development from an idea presented by marcov. cheers, |
Hum, I think you are right, I disabled in dlfcnh.inc all the + LIBC_SUFFIX, recompile fpc-ootb and indeed no more GLIBC_2.34. Excellent, so very few code to change (and I did lot of work for nothing ;-) ). |
Hola, pas trop vite... Indeed libc.pp is not used for Linux 64 bit but it is not the case for 32 bit. Now, is libc.pp really needed for Linux 32 bit? I think mainly about the Rpi ARM32 that uses still the 32 bit OS ( 64 bit is under hard development ). |
Re-hello. Tried this: commented all the *.inc that are in libc.pp.
So at the moment we may not forget libc.pp for Linux 32 bit... |
Just don't make any change to the libc unit. It is not allowed at all.
I don't understand your point about |
Hello. Sorry but libc.pp is used for Linux 32 bit. Maybe the doc says libc.pp is not used but it is. You may try this, in libc.pp, add something wrong like "xxxxxx" and then try to recompile fpc for Linux 32 bit. You will see that there will be a error. |
As I wrote, only |
Here result when compling fpc and in libc.pp added dummy line 'xxxxxxx';
I check the source also when compiling it ;-) |
I guess it is not used by the FPC compiler itself (otherwise it would be very weird), but it is part of the RTL. |
I agree that maybe the majority of RTL units that use libc.pp are units that nobody will use. But, in case of somebody wants to use one of those unit that uses libc.pp, there is now a good libc.pp that assign symbols table. OK, it is not the best argument. ( I try to find one to defend the hard work I did in that f*** libc.pp ). But you are right, that libc.pp will be used very rarely . |
Yes, for the patch to fpc I would not add it (but in fpc-ootb it does not hurt to be there). |
Hello Rob. Yes, good I dea but, imho, before to think to play with the script for the linker following Marcov idea, first fix the Big-Bug. Once fpc can run without the Big-Bug, then yes, why not play with a linker-script (that will never work, I did try this, no freedom with the script-options). I want also thank you for all the hard work we did to explore that jungle (without any help from fpc-devs). I am very happy now with fpc-ootb that really works like in a Barbie world. So, I will stop the combat (we have been fighting for this for almost 2 months) and I wish you good luck + big courage with the fpc-devs and your proposals. Thanks also to everybody here (Rob, AB, DonAlfredo, ...) for your open-mind and patience. Fre;D |
Hello.
Not assigning proper signed symbol table for a method from libc.so.6 could give big problems.
See the (hot) topic here:
https://forum.lazarus.freepascal.org/index.php/topic,58888.msg486269.html#msg486269
The text was updated successfully, but these errors were encountered: