Home » Developing U++ » U++ Developers corner » theide with libclang
|
|
| Re: theide with libclang [message #58864 is a reply to message #58860] |
Tue, 20 September 2022 13:09   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
Novo wrote on Sun, 18 September 2022 21:23valgrind explains everything.
While it is definitely a good idea, only one of these errors seems libclang related and fixable and it happens on theide exit. Anyway, now fixed.
That said, everything valigrind says is worth investigation. I was able to fix many of these issues (in master now), unfortunately it looks like majority of remaining problems is cairo related (these happen when we are reading images from gtk).
Any help identifying the cause(s) is welcome.
Mirek
[Updated on: Tue, 20 September 2022 13:11] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58873 is a reply to message #58864] |
Tue, 20 September 2022 19:16   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 20 September 2022 07:09Novo wrote on Sun, 18 September 2022 21:23valgrind explains everything.
While it is definitely a good idea, only one of these errors seems libclang related and fixable and it happens on theide exit. Anyway, now fixed.
That said, everything valigrind says is worth investigation. I was able to fix many of these issues (in master now), unfortunately it looks like majority of remaining problems is cairo related (these happen when we are reading images from gtk).
Any help identifying the cause(s) is welcome.
Mirek
Thanks a lot! TheIde doesn't crash anymore.
I personally do not see any cairo problems. I guess Void Linux has a better valgrind exceptions list.
The only problem I do see is an uninitialized value in Ide::Serialize.
Interestingly, this problem depends on when you close TheIde.
I guess this data is uninitialized during libclang indexing/reindexing.
My command line:
valgrind --track-origins=yes --log-file=memchk.txt ~/dvlp/cpp/code/upp/out/CLANG.Debug.Debug_Full.Gui.Shared/ide
Regards,
Novo
|
|
|
|
|
|
| Re: theide with libclang [message #58875 is a reply to message #58873] |
Tue, 20 September 2022 19:37   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
Novo wrote on Tue, 20 September 2022 19:16mirek wrote on Tue, 20 September 2022 07:09Novo wrote on Sun, 18 September 2022 21:23valgrind explains everything.
While it is definitely a good idea, only one of these errors seems libclang related and fixable and it happens on theide exit. Anyway, now fixed.
That said, everything valigrind says is worth investigation. I was able to fix many of these issues (in master now), unfortunately it looks like majority of remaining problems is cairo related (these happen when we are reading images from gtk).
Any help identifying the cause(s) is welcome.
Mirek
Thanks a lot! TheIde doesn't crash anymore.
I personally do not see any cairo problems. I guess Void Linux has a better valgrind exceptions list.
The only problem I do see is an uninitialized value in Ide::Serialize.
Interestingly, this problem depends on when you close TheIde.
I guess this data is uninitialized during libclang indexing/reindexing.
I am getting that one (in Ide::Serialize) too; my guts feeling is that it is not related to libclang, just some old serialisation bug like forgotten unitialised variable. Want to hunt that down, but it is time consuming....
What about those "_dl_catch_exception " things? Does not look like U++ fault, right?
[Updated on: Tue, 20 September 2022 19:38] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58877 is a reply to message #58579] |
Tue, 20 September 2022 20:13   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
OK looks like I had a bad repo. I rebuilt and I'm back in. I'm still having excessive memory usage though and another curious thing I noticed is that it reindexes the file I have open in the editor regardless of whether it's changed. If I click away to another app and back to theide it will reindex. It never frees memory, even if I switch to another package entirely.
I'm not getting the clang error in the console anymore though, so that appears to be fixed. I am, however, getting freezes if I cancel a build.
[Updated on: Tue, 20 September 2022 20:40] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58880 is a reply to message #58579] |
Wed, 21 September 2022 00:33   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
Once I replaced those memcmp instructions with strnlen it shut up address sanitizer. They're probably fine but at least I was able to get further and... there was nothing worthwhile except the usual font stuff.
Found another errata to potentially test. If I go into any sufficiently complex package (like CtrlCore or CtrlLib) and hold down alt + down arrow to cycle through/open as many files as quickly as possible, libclang gets stuck in an infinite reparsing loop on one file until I click off to another file. I'm assuming this is because I'm leaving the last parsable .cpp/.h file and moving into other non-parseable file types rapidly.
Edit also if you left ctrl click a symbol with indexing turned off it will still try to index but pin a core instead.
[Updated on: Wed, 21 September 2022 00:49] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58881 is a reply to message #58875] |
Wed, 21 September 2022 01:33   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 20 September 2022 13:37
I am getting that one (in Ide::Serialize) too; my guts feeling is that it is not related to libclang, just some old serialisation bug like forgotten unitialised variable. Want to hunt that down, but it is time consuming....
One time I ran valgring I saw ZERO problems. I didn't believe my eyes. I reran it and got this Ide::Serialize problem. This is why I think it depends on something else.
mirek wrote on Tue, 20 September 2022 13:37
What about those "_dl_catch_exception " things? Does not look like U++ fault, right?
It is hard to tell. In my latest rerun I didn't get this "_dl_catch_exception " thing.
I believe it happens when I close TheIde before it finishes loading of libclang data.
I'm closing it via unorthodox window manager called herbstluft, which is sending a message to TheIde, I believe.
So, something gets interrupted in the middle, I guess.
Theoretically, a loader should automatically unload everything correctly ...
Regards,
Novo
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #58890 is a reply to message #58884] |
Wed, 21 September 2022 22:09   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
Thanks for doing this stuff Mirek. I was looking through the code trying to figure it out and learn about libclang ASTs but I simply don't know enough about TheIDE's internal operations (or libclang) to make heads or tails of it. I also swear I find you everywhere.
I came across you on Stack Overflow asking about libclang, then a couple of weeks ago I was reading some posts from Andrei Alexandrescu and I saw you in there too.
As for libclang one of the strange problems I had that shouldn't happen is that clang_parseTranslationUnit was returning a translation unit of 0 and as a consequence Dispose() was never getting called. I wasn't able to fix it because it mysteriously stopped happening and I don't know if it's anything I did. All I did was put in the hook for clang_parseTranslationUnit2 to see if it would give me a more meaningful error... but that turned out to be useless. It stopped happening even after I switched back.
The only other change I made was I hooked clang_defaultReparseOptions and passed that to clang_reparseTranslationUnit. Supposedly it provides some default options that improve performance, don't really know if it did... so I flailed around uselessly for a few hours. The other behavior I had and am still having is that it's not simply parsing and then calling reparse after the initial parse, it's calling both every time. Once I got into CurrentFileThread it got too deep into TheIDE internals to understand what was going on.
[Updated on: Wed, 21 September 2022 22:14] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58900 is a reply to message #58884] |
Fri, 23 September 2022 05:41   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Wed, 21 September 2022 04:52
Thanks, fixed.
Thanks a lot!
Could you also fix a problem below, please?
./umk reference SMTP CLANG -busr
/home/buildbot/worker/l-upp/build/uppsrc/Core/SMTP/Smtp.cpp:457:2: error: expected expression
DDUMP(GetMessage(true));
^
/home/buildbot/worker/l-upp/build/uppsrc/Core/Diag.h:159:26: note: expanded from macro 'DDUMP'
#define DDUMP(x) @ // To clean logs after debugging, this produces error in release mode
^
1 error generated.
Regards,
Novo
|
|
|
|
| Re: theide with libclang [message #58901 is a reply to message #58884] |
Fri, 23 September 2022 05:52   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Wed, 21 September 2022 04:52Novo wrote on Wed, 21 September 2022 01:56I've got a different call stack with Ide::Serialize.
Maybe it will help to locate a problem.
Thanks, fixed. (Unfortunately it was complete non-bug that could not have influenced anything real, just unitialized variable that is never used again).
I do see two problems with valgrind messages:
1) Tons of "uninitialized value" messages hide real problems.
2) Nobody will use Upp with commercial apps for a very simple reason: who knows what kind of problems can be caused by these "uninitialized values".
IMHO, Upp should be checked with all available valgrind tools and all available sanitizers. At least before release.
Regards,
Novo
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #58906 is a reply to message #58904] |
Sat, 24 September 2022 04:41   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
I don't know how much improvement we can expect in, say half an year's time. At the moment, I Ctrl+Left click on a member function in a moderately complex project, the parsing starts and goes on for ever. At least 30 minutes past and no idea how much longer it's going to take. In contrast, it used to work so smoothly.
Theoretically moving to libclang is the right thing to do, but there is a huge chance it may render theide completely useless.
Some system info
Quote:
Upp version: 16443
OS: Ubuntu 22.04.1 LTS x86_64
CPU: Intel i7-8650U (8) @ 4.200GHz
GPU: Intel UHD Graphics 620
Memory: 3757MiB / 15875MiB
PS: I tested with Examples/HomeBudget. In HomeBudget.cpp, Ctrl+left click some member function, eg LoadCategories(...) to start parsing. Now roughly 10 minutes past, still parsing. Something might not be right.
[Updated on: Sat, 24 September 2022 05:08] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58907 is a reply to message #58906] |
Sat, 24 September 2022 07:26   |
 |
peterh
Messages: 108 Registered: November 2018 Location: Germany
|
Experienced Member |
|
|
Fortunately I can say, on my computer it works almost immediately.
I am on Windows 10 64 bit.
The computer is a Ryzen 7, 32 GByte Memory.
I had a look into taskmanager. Total memory used was 12 GBytes.
I had some other programs open, Browser, email, Fotoviewer Faststone, Fotosoftware.
TheIde used 2 GBytes and had the biggest memory chunk in use.
I can imagine, if the computer had less memory, if the drive is a harddrive and not a SSD, and if TheIDE temporarily wants more memory, then the computer would start swapping and it could terribly slow down.
(If it had an SSD it could be faster, but would lead to unneccessary SSD wear) (I have a SSD but I hope it will not be used for swapping)
Fortunately swapping does not happen here.
It might be useful to monitor and report this machine data and properties.
Possibly reboot and do not start other programs than TheIDE and compare the behavior and memory consumption.
So far I know, libclangd can be disabled in the setup. This could be a solution as a last ressort if memory is low.
[Updated on: Sat, 24 September 2022 07:47] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58909 is a reply to message #58579] |
Sat, 24 September 2022 08:44   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
OK, so one week in, I guess I owe the community a bit of explanation about libclang and the way theide uses it...
So, obviously what libclang does is parsing the files and giving info about them. Additionally, it can provide autocomplete lists at specified point in the source files, but NOT HEADERS (and also not inside templates, but that is store for another time).
The important thing to know is that parsing the file with all headers is long: on my not so slow machine, it can take up to several seconds to parse the file. To remedy this, libclang has a concept of "preamble" and "reparsing". Preamble is basically automated precompiled header - if file starts with multiple headers, preamble is creating and when after the first parse the file is reparsed or autocomplete requested, preamble is used to greatly speedup the process. With preamble, autocomplete (after the first parse) is almost immediate. That said, premable creation is sort of fragile. Also, normally it gets created in system temp directory, which would be fine unless sometimes libclang does not delete it. But it can be solved be setting env variable which we do now.
So what we do now is the when you start editing some file, in the background thread the first parse of the file is started with a request to create preamble. In theide, you can know that this is happening by left bar going "sort of orange" for a couple of seconds - it does that each time file is parsed or reparsed. If you then change the file, it gets (after some time of inactivity) reparsed again. Parsing current file gets it ready for autocomplete, but also provides information about file for file annotations, current file navigation and "jumps" (Alt-J / Ctrl clicks).
Originally, there was just one parsed file, which meant each time after switching to another file it had to have that initial a couple of seconds parsing period. Later I have added a cache, there are now several files with parsed info. Downside is that each "parsing unit" consumes a lot of memory, about 300MB so with 12 entries in the cache, you can do the math....
Include files that clang is unable to process: What we do is that we find "master file" - the well defined file that includes the header and we pretend that we are parsing that one. It is not so simple: we still want to use preamble to make things fast and if we just parsed master file and hoped to catch the info include file from it, it would not work with preambles as our include file would actually be in preamble. I have spent a lot of time trying to solve this: What we actually do now is that we create a syntetic file content that actually manually does including so that it all works (it is hard to explain in detail; in assist diagnostic mode you can see the content of the syntetic file with Assist/Current parsed file content).
So that is about all I can say about "current file" without going into gruesome details; if you want to study the code, libclang/CurrentFile.cpp and ide/AssistTrick.cpp are good starting points.
Next troublesome part of code is "Indexer" - that is something that scans the whole sources and creates a program database of, well, everything everywhere. That is needed for Navigator and Alt+J command. We are using blitz(like) process there and we are running that in multiple threads. Now there is "Scheduler" (Indexer::SchedulerThread()) thread that scans for changed files and basically prepares jobs for "Indexing" (Indexer::IndexerThread) threads. Once again, each of indexer threads can eat up to 300MB of memory, so finetuning default values will take some time. More indexer threads mean faster reindexing but perhaps too much memory...
In terms of slowdown/freezing during reindexing, well, the plan was to give indexer threads really low priority. It should be possible with
clang_CXIndex_setGlobalOptions(clang.index, CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
but maybe this does not work as expected in Linux. In Windows, it seems to work fine.
Now for testing and troubleshooting, please note that there is "Assist diagnostics" option in Assist/Debug. When active, it will start reporting in Console what it is doing and also there are new entries at the end of assist menu, showing a dump of actual index, errors libclang reported during parsing and what was given to clang to parse as current file.
So if e.g. there is no autocomplete for include files, please check "Current file parse errors" and "Current parsed file content".
I know this is a big change (and one I was extremly hesitant to do) and not everything works smoothly at this point, but hopefully all will be finetuned in time. I guess we fixed a lot already in the first week....
Mirek
[Updated on: Sat, 24 September 2022 08:47] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58910 is a reply to message #58909] |
Sat, 24 September 2022 09:53   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
Nah, Mirek, I don't feel I'm owed an explanation 
Windows users seem to be OK, like you said it's linux that needs some love. In my case I had an ancient version of libclang 7.0 sitting in /usr/local/lib. Once I zapped that the excessive memory consumption disappeared so I'm pretty sure that was libclang. I updated to 15 and things are still looking good. I did find valgrind complain about some branches on uninitialized variables in theide itself:
==562946== Conditional jump or move depends on uninitialised value(s)
==562946== at 0x56DB7A: Upp::CodeEditor::DirtyFrom(int) (CodeEditor.cpp:74)
==562946== by 0x5A2DEF: Upp::TextCtrl::Insert0(int, Upp::WString const&) (Text.cpp:799)
==562946== by 0x5A3C2E: Upp::TextCtrl::InsertU(int, Upp::WString const&, bool) (Text.cpp:935)
==562946== by 0x5A3FB7: Upp::TextCtrl::Insert(int, Upp::WString const&, bool) (Text.cpp:980)
==562946== by 0x315C96: Upp::TextCtrl::Insert(int, Upp::WString const&) (TextEdit.h:218)
==562946== by 0x5A4E6B: Upp::TextCtrl::Paste(Upp::WString const&) (Text.cpp:1153)
==562946== by 0x3075CD: Console::Append(Upp::String const&) (Console.cpp:77)
==562946== by 0x326EDB: Console::operator<<(Upp::String const&) (ide.h:127)
==562946== by 0x3CA52A: Ide::PutConsole(char const*) (idewin.cpp:50)
==562946== by 0x46B05A: PutConsole(char const*) (Ide.cpp:9)
==562946== by 0x34EC3E: AssistEditor::SyncMaster() (IncludeTrick.cpp:18)
==562946== by 0x3536C7: AssistEditor::NewFile(bool) (Assist.cpp:438)
==562946==
==562946== Conditional jump or move depends on uninitialised value(s)
==562946== at 0x56D63F: Upp::CodeEditor::GetSyntax(int) (CodeEditor.cpp:29)
==562946== by 0x56DC5B: Upp::CodeEditor::GetRefreshInfo(int) (CodeEditor.cpp:94)
==562946== by 0x56DEFA: Upp::CodeEditor::PostInsert(int, Upp::WString const&) (CodeEditor.cpp:111)
==562946== by 0x5A335E: Upp::TextCtrl::Insert0(int, Upp::WString const&) (Text.cpp:851)
==562946== by 0x5A3C2E: Upp::TextCtrl::InsertU(int, Upp::WString const&, bool) (Text.cpp:935)
==562946== by 0x5A3FB7: Upp::TextCtrl::Insert(int, Upp::WString const&, bool) (Text.cpp:980)
==562946== by 0x315C96: Upp::TextCtrl::Insert(int, Upp::WString const&) (TextEdit.h:218)
==562946== by 0x5A4E6B: Upp::TextCtrl::Paste(Upp::WString const&) (Text.cpp:1153)
==562946== by 0x3075CD: Console::Append(Upp::String const&) (Console.cpp:77)
==562946== by 0x326EDB: Console::operator<<(Upp::String const&) (ide.h:127)
==562946== by 0x3CA52A: Ide::PutConsole(char const*) (idewin.cpp:50)
==562946== by 0x46B05A: PutConsole(char const*) (Ide.cpp:9)
I was also able to trigger a crash of TheIDE by just holding down Ctrl+Space for a minute or so to make it continually attempt to autocomplete, put some pressure on it. Unfortunately it only happens in release mode, I cannot reproduce it in debug mode.
|
|
|
|
| Re: theide with libclang [message #58911 is a reply to message #58910] |
Sat, 24 September 2022 10:03   |
 |
peterh
Messages: 108 Registered: November 2018 Location: Germany
|
Experienced Member |
|
|
Hi,
I have reported 3 GB memory in windows.
I must add, I had the IDE open for probably 2 days.
Normally I do not shut down my computer but put it to sleep at night or when I do not use it.
I have now rebooted and after opening TheIDE with the same project and having tried "Homebudget" also, it consumes only 300MB.
[Updated on: Sat, 24 September 2022 10:05] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58915 is a reply to message #58912] |
Sat, 24 September 2022 10:30   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
mirek wrote on Sat, 24 September 2022 10:16
It was not meant specifically for you...
Serves me right for attempting to be conciliatory.
Quote:
In your case I remember complaining about headers. Do they work now?
I'll get latest and check. But the list of outstanding issues I have:
1. Includes don't autocomplete
2. Parser gets stuck in a reparse loop if I cycle through files in a project using alt+down and hit a file that is not code (like a .lay or .iml file)
3. Alt+C, which you are already working on
Quote:
As for old libclang... I can put limit for minimal version, e.g. libclang 10 (I am quite sure that one works), what do you think?
Sounds good.
[Updated on: Sat, 24 September 2022 10:34] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58917 is a reply to message #58912] |
Sat, 24 September 2022 11:10   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
Mirek,
The problem appears to manifest with assist_cursor in Assist.cpp line 502.
It gathers all of the potential include files appropriately but assist_cursor never matches current pos so it returns before performing the completion.
void AssistEditor::PopUpAssist(bool auto_insert)
{
LTIMING("PopUpAssist");
int pos = GetCursor();
ReadIdBackPos(pos, false);
if(pos != assist_cursor)
return;
EDIT It's uninitialized. The only place I can find it being set is around line 463 but there's an early return
include_assist = false;
if(IncludeAssist())
return;
int pos = GetCursor();
ReadIdBackPos(pos, false); // libclang does not work well if file is not truncated for autocomplete (?)
assist_cursor = pos;
before assist_cursor is set. If I move that block of code after the pos set it shows the files but it has strange index numbers next to the icons. <- never mind, that appears to be for debugging purposes and doesn't appear in release mode.
So the fix is:
int pos = GetCursor();
ReadIdBackPos(pos, false); // libclang does not work well if file is not truncated for autocomplete (?)
assist_cursor = pos;
include_assist = false;
if(IncludeAssist())
return;
[Updated on: Sat, 24 September 2022 19:43] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58918 is a reply to message #58908] |
Sat, 24 September 2022 15:00   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
mirek wrote on Sat, 24 September 2022 02:08
Is autocomplete working?
No.It is not. Is it because libclang not present in my system?
PS:
I already have clang installed. After I installed libclang-dev, key event in theide will immediately crash theide with error message
Quote:
Fatal Error!
Invalid memory access!
The libclang.so shipped with most recent(?) libclang-dev(1:14.0-55~exp2) doesn't seem to work with theide. It's most likely to be some kind of chaos in my system.
ps2: Now even after I remove'd libclang-dev, theide in upp version 16443 won't work. You don't even need to type in anything, it will crash itself with invalid memory access in just a few seconds(when background parsing threads start). It looks like a libclang version problem. For now, I will go back to upp version 16303 on which autocomplete works fine.
[Updated on: Sat, 24 September 2022 15:54] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58920 is a reply to message #58918] |
Sat, 24 September 2022 19:55   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
Lance wrote on Sat, 24 September 2022 15:00
ps2: Now even after I remove'd libclang-dev, theide in upp version 16443 won't work. You don't even need to type in anything, it will crash itself with invalid memory access in just a few seconds(when background parsing threads start). It looks like a libclang version problem. For now, I will go back to upp version 16303 on which autocomplete works fine.
I didn't try dev packages, I just uninstalled clang through package manager and ran
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
to bring everything to clang-15, including libclang. Should work with debian/apt systems.
[Updated on: Sat, 24 September 2022 19:57] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #58923 is a reply to message #58920] |
Sat, 24 September 2022 23:09   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
This is the problem I'm currently trying to work out but not getting anywhere yet:
https://files.catbox.moe/t4kcpd.mp4
It will get stuck in a reparse loop. Same thing also happens occasionally when I'm exiting TheIDE. Note that it happens when I move rapidly to a resource-type file. I didn't capture it in the video but it behaves normally and exits the loop if I go back to a parseable .cpp or .h file, so it's not stuck that way permanently - it is just attempting to redo the same old job repeatedly until it gets a new job. When it happens on exit it becomes permanently stuck.
[Updated on: Sun, 25 September 2022 03:06] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58924 is a reply to message #58920] |
Sun, 25 September 2022 02:13   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
jjacksonRIAB wrote on Sat, 24 September 2022 13:55Lance wrote on Sat, 24 September 2022 15:00
ps2: Now even after I remove'd libclang-dev, theide in upp version 16443 won't work. You don't even need to type in anything, it will crash itself with invalid memory access in just a few seconds(when background parsing threads start). It looks like a libclang version problem. For now, I will go back to upp version 16303 on which autocomplete works fine.
I didn't try dev packages, I just uninstalled clang through package manager and ran
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
to bring everything to clang-15, including libclang. Should work with debian/apt systems.
Thank you, jjacksonRIAB! Your command worked fine and I was able to upgrade my libclang. Unfortunately the problem remains with UPP version 16443: theide will crash in a few seconds after a package is open with "Invalid Memory Access" error.
[Updated on: Sun, 25 September 2022 02:14] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #58929 is a reply to message #58927] |
Sun, 25 September 2022 15:30   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Klugier wrote on Sun, 25 September 2022 09:28Hello Lance,
Could you open ide project and build it in debug mode. After that in TheIDE in debug mode (under debugger) open examples/Days package. Thanks to that we should be able to obtain callstack of the crash.
If you have trouble with opening uppsrc/ide package due to crash in TheIDE, disable clang parsing in Settings (Assist tab and first option from the left). Screenshot below:

Klugier
libclang.so obviously is successfully detected. In the generated theide, I opened examples/AddressBook, I can observe the right panel populated with parsed results, gradually, starting from blank.
This time it took much longer for the generated theide to crash. Unfortunately nothing useful could be obtained from that/after that.

As you can see, I can either Wait(and it eventually bring me to the same screen) or Force Quit the generated debug-mode theide which end the generated debug-mode theide completely,leaving me no chance to check the call stack.
In the host theide(which creates the debug-mode theide), I have something like this...oh, I can not update more than one picture, anyways, it bears no information and should not be of any relevance anyways.
[Updated on: Sun, 25 September 2022 16:13] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #58930 is a reply to message #58929] |
Sun, 25 September 2022 15:47   |
 |
Klugier
Messages: 1117 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello Lance,
OK, I see where the problem is. We are dynamically loading libclang without notify the user about the actions of this operation. It must change and in situation when we do not detect it we should show error and siabled parsing...
Here is the code in TheIDE (ide/main.cpp):
#ifdef PLATFORM_POSIX
void TryLoadLibClang() // Should return bool...
{
String libdir = TrimBoth(Sys("llvm-config --libdir"));
if(LoadLibClang(libdir + "/libclang.so"))
return;
if(LoadLibClang("/usr/lib/libclang.so"))
return;
for(int i = 20; i >= 10; i--)
if(LoadLibClang("/usr/lib/llvm-" + AsString(i) + "/lib/libclang.so"))
return;
}
#endif
#ifdef flagMAIN
GUI_APP_MAIN
#else
void AppMain___()
#endif
{
#ifdef PLATFORM_POSIX
TryLoadLibClang(); // If it fails... just notrmal execution without any notification or error. However user will now if libclang is conffigured correctly?
#endif
// Above operation fails and we are starting to use libclang, it can not end good...
The above code must be fixed and then you can try to run TheIDE. If you do not have correctly set libclang then you should see the error.
-------------------
Edit: In general I assume that for your configuration there is a problem with finding libclang.so and lack of this library is causing crash.
Klugier
U++ - one framework to rule them all.
[Updated on: Sun, 25 September 2022 15:55] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 25 14:36:17 GMT+2 2026
Total time taken to generate the page: 0.01662 seconds
|