Home » Developing U++ » U++ Developers corner » theide with libclang
|
|
|
|
| Re: theide with libclang [message #58972 is a reply to message #58969] |
Mon, 03 October 2022 11:30   |
Tom1
Messages: 1319 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Mon, 03 October 2022 11:34Tom1 wrote on Mon, 03 October 2022 10:05Mirek,
I installed and had success with libclang-11! It does not crash with LCLANG flag.
* /home/tom/out/uppsrc/CLANG.Blitz.Gui.Lclang.Shared/ide 03.10.2022 11:02:44, user: tom
11:02:44:268 INFO GuiMainFn_(): Version: 16466 (64 bit) (wchar32) (CLANG) (C++14) (Gtk) Compiled: 10/03/2022 10:55:02
Without the flag it goes with libclang-14 and crashes:
* /home/tom/out/uppsrc/CLANG.Blitz.Gui.Shared/ide 03.10.2022 10:59:52, user: tom
10:59:52:892 INFO libclang path:/usr/lib/llvm-14/lib/libclang.so
10:59:52:893 INFO GuiMainFn_(): Version: 16466 (64 bit) (wchar32) (CLANG) (C++14) (Gtk) Compiled: 10/03/2022 10:59:10
****************** PANIC: Invalid memory access!
Best regards,
Tom
Can you try to LCLANG with libclang-14? (by changing build method paths)
Anyway, if this is holds true, it would be both great and sort of bad - there will be a lot of work fixing install process for clang, even maybe ide/Builders. Hopefully the community will help with that...
Mirek
Yes, this was my first test today and it failed. That's why I decided to try libclang-11 in the first place.
BR,
Tom
|
|
|
|
| Re: theide with libclang [message #58973 is a reply to message #58971] |
Mon, 03 October 2022 11:35   |
Tom1
Messages: 1319 Registered: March 2007
|
Ultimate Contributor |
|
|
[quote title=mirek wrote on Mon, 03 October 2022 11:48]Tom1 wrote on Mon, 03 October 2022 10:05Mirek,
I installed and had success with libclang-11! It does not crash with LCLANG flag.
* /home/tom/out/uppsrc/CLANG.Blitz.Gui.Lclang.Shared/ide 03.10.2022 11:02:44, user: tom
11:02:44:268 INFO GuiMainFn_(): Version: 16466 (64 bit) (wchar32) (CLANG) (C++14) (Gtk) Compiled: 10/03/2022 10:55:02
What about dynamically loaded libclang-11?
Mirek
Yes, libclang-11 works without crash when loading dynamically as well:
* /home/tom/out/uppsrc/CLANG.Blitz.Gui.Shared/ide 03.10.2022 12:33:52, user: tom
12:33:52:324 INFO libclang path:/usr/lib/llvm-11/lib/libclang.so
12:33:52:324 INFO GuiMainFn_(): Version: 16466 (64 bit) (wchar32) (CLANG) (C++14) (Gtk) Compiled: 10/03/2022 10:59:10
BR,
Tom
|
|
|
|
| Re: theide with libclang [message #58974 is a reply to message #58973] |
Mon, 03 October 2022 11:45   |
Tom1
Messages: 1319 Registered: March 2007
|
Ultimate Contributor |
|
|
Mirek,
Further on: libclang-11, libclang-12 and libclang-13 do not crash when loading dynamically. It's just libclang-14 that crashes here.
BR,
Tom
|
|
|
|
|
|
| Re: theide with libclang [message #58978 is a reply to message #58970] |
Mon, 03 October 2022 15:51   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
mirek wrote on Mon, 03 October 2022 04:37Lance wrote on Mon, 03 October 2022 00:58
I was able to do some screen shots of supposed calling stack, hopefully it means something to you.
You do not need to do it this way (if you are debugging with theide): There is a menu item in Debug that copies backtrace of all threads to clipboard.
Mirek
I see. Thanks.
----------------------------------
Thread: 1
futex_wait (private=0, expected=2, futex_word=0x555556869ca8 <Upp::sHeapLock2+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
----------------------------------
Thread: 2
../sysdeps/unix/sysv/linux/poll.c:29
----------------------------------
Thread: 3
../sysdeps/unix/sysv/linux/poll.c:29
----------------------------------
Thread: 4
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 5
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 6
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 7
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 8
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 9
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 10
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 11
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 12
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 13
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 15
syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
----------------------------------
Thread: 17
../sysdeps/unix/sysv/linux/poll.c:29
----------------------------------
Thread: 18
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 19
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 20
/lib/x86_64-linux-gnu/libclang-14.so.13
----------------------------------
Thread: 21
futex_wait (private=0, expected=2, futex_word=0x555556869ca8 <Upp::sHeapLock2+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
----------------------------------
Thread: 22
Upp::BlkHeap<Upp::HugeHeapDetail, 4096>::DbgFreeFill (p=<error reading variable: Cannot access memory at address 0x7fffc5fed1b8>, size=<error reading variable: Cannot access memory at address 0x7fffc5fed1b0>) at /home/lance/upp.src/uppsrc/Core/HeapImp.h:93
----------------------------------
Thread: 23
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 24
./nptl/futex-internal.c:57
./nptl/futex-internal.c:87
./nptl/futex-internal.c:139
----------------------------------
Thread: 25
futex_wait (private=0, expected=2, futex_word=0x5555568d01d8 <Upp::sGLock+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
----------------------------------
Thread: 29
futex_wait (private=0, expected=2, futex_word=0x555556869ca8 <Upp::sHeapLock2+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
----------------------------------
Thread: 31
futex_wait (private=0, expected=2, futex_word=0x555556869ca8 <Upp::sHeapLock2+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
----------------------------------
Thread: 32
futex_wait (private=0, expected=2, futex_word=0x555556869ca8 <Upp::sHeapLock2+8>) at ../sysdeps/nptl/futex-internal.h:146
./nptl/lowlevellock.c:49
|
|
|
|
| Re: theide with libclang [message #58979 is a reply to message #58978] |
Mon, 03 October 2022 23:20   |
 |
Klugier
Messages: 1119 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello,
I just installed Ubuntu 22.04.01 (LTS) and I managed to reproduce the problem. After opening project, the crash happen after 4-5 seconds of running indexer. Thanks to --noclang option I managed to build TheIDE under debug mode. Here is the screenshot from the crash and callstack:

It seems that it crashes when calling clang_getCursorPrettyPrinted in ClangCursorInfo::RawId() method:
force_inline
String ClangCursorInfo::RawId()
{
if(!hasraw_id) {
raw_id = FetchString(clang_getCursorPrettyPrinted(cursor, pp_id)); // Last call in TheIDE code base before crash...
hasraw_id = true;
}
return raw_id;
}
-----
I have 14.0.0-1ubuntu1, on Manajaro I have 14.0.6 and there is no crash.
-----
Once change the line to:
raw_id = FetchString(clang_getCursorPrettyPrinted(cursor, nullptr));
Fixed the problem, however I am not sure what is this code doing, so there is a chance that it will break something...
Klugier
U++ - one framework to rule them all.
[Updated on: Mon, 03 October 2022 23:50] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #58993 is a reply to message #58992] |
Sat, 08 October 2022 21:29   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Mirek:
No more crashes after the line is commented out. I have tested with both llvm-14 and llvm-15.
For some reason, neither llvm-14 nor llvm-15 generate some symlinks that should be in exist for ide to properly load libclang dynamically.
I have
and
but not
Also, I believe I also need to manually create
sudo ln -s /usr/lib/llvm-15/lib/libclang.so.1 /usr/lib/llvm-15/lib/libclang.so
As we cannot control how llvm installation creates symlinks, for smoother user experience, should we alter the detecting logic to accommodate this situation?
Regards,
Lance
BTW, the speed when built in release mode is quite good.
[Updated on: Sat, 08 October 2022 21:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #59070 is a reply to message #59023] |
Wed, 26 October 2022 16:00   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Not sure if this problem is unique to me: on Ubuntu 22.10+UPP.16512 (and some other recent versions),
"Find..." function cannot be used. Ctrl+F, type in string to search, won't work.
Another problem. Add new help topic will crash TheIDE. For a test,
* open "examples/AddressBook", navigate to "AddressBook.cpp" if not already in it.
* In the class "AddressBook", click any member variable or function to add cocumentation [a cyan square to the left of the function/variable line];
* in the popup menu, choose "New reference topic"
* in the "New Topic" dialog, in the Template field, change it to "Reference-en_us (in uppsrc)"
* Click "OK" button
The ide crash with invalid memory access.
I am sorry. I know Mirek has been tirelessly working on integrating libclang to theide. Not criticizing, not meaning to distract, just trying to bring awareness.
|
|
|
|
| Re: theide with libclang [message #59071 is a reply to message #59070] |
Wed, 26 October 2022 22:07   |
 |
mirek
Messages: 14291 Registered: November 2005
|
Ultimate Member |
|
|
Lance wrote on Wed, 26 October 2022 16:00Not sure if this problem is unique to me: on Ubuntu 22.10+UPP.16512 (and some other recent versions),
"Find..." function cannot be used. Ctrl+F, type in string to search, won't work.
Another problem. Add new help topic will crash TheIDE. For a test,
* open "examples/AddressBook", navigate to "AddressBook.cpp" if not already in it.
* In the class "AddressBook", click any member variable or function to add cocumentation [a cyan square to the left of the function/variable line];
* in the popup menu, choose "New reference topic"
* in the "New Topic" dialog, in the Template field, change it to "Reference-en_us (in uppsrc)"
* Click "OK" button
The ide crash with invalid memory access.
I am sorry. I know Mirek has been tirelessly working on integrating libclang to theide. Not criticizing, not meaning to distract, just trying to bring awareness.
Bug reports are always welcome!
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #59094 is a reply to message #59076] |
Tue, 01 November 2022 23:32   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Thank you, Mirek! Both are fixed in UPP version 16523.
Another bug I found a few weeks (maybe months) ago. I tested with version 16523 and it's still there.
To reproduce the experience, move away or rename libclang.so/dll etc so that it cannot be detected when theide starts. Or, change
bool TryLoadLibClang()
at line 120 in <ide/main.cpp> to fail the LibClang loading:
bool TryLoadLibClang()
{
// add the following line to
return false; // make sure detection fails.
String libdir = TrimBoth(Sys("llvm-config --libdir"));
int q = FindIndex(CommandLine(), "--clangdir");
if(q >= 0 && q + 1 < CommandLine().GetCount()) {
libdir = CommandLine()[q + 1];
CommandLineRemove(q, 2);
}
if(LoadLibClang(libdir))
return true;
if(LoadLibClang("/usr/lib"))
return true;
for(int i = 200; i >= 10; i--)
if(LoadLibClang("/usr/lib/llvm-" + AsString(i) + "/lib"))
return true;
return false;
}
F5 to compile and run the modified theide, in it, open button.cpp from <examples/Button>, left click on, for example the word 'TopWindow', the assist++ will start a dialog that will never end unless cancelled.
I am not sure if there are other occassions like this when assist++ will be started by some other key combinations or mouse events, even though theide knows and even prompted the end users of "libclang detection failure". This is no longer bothering me, but could confuse a person who starts to try UPP.
[Updated on: Wed, 02 November 2022 00:22] Report message to a moderator
|
|
|
|
| Re: theide with libclang [message #59096 is a reply to message #59094] |
Wed, 02 November 2022 00:15   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Another more like a feature request:
Take for example, the following code:
class Person
{
int age_;
public:
int get_age()const { return age_; }
void set_age(int age){ age_ = age; }
__declspec(property(get=get_age, put = set_age)) int age;
};
theide/Assist++ will put a red rect at the beginning of __declspec, with error message ...'__declspec' attributes are not enabled; use '-fdeclspec'..., even though the flag has been turned on. This is kind of a fictitious example. The real issue here is, the flags I set in "Setup > Build Methods" for CLANG, under common c++ options
-std=c++20 -Wno-logical-op-parentheses -fdeclspec
is not respected by assist++.
So if someone wants to try some c++20 new language features, assist++ will stick to builtin option of '-std=c++14' and keep bugging him.
[Updated on: Wed, 02 November 2022 00:17] Report message to a moderator
|
|
|
|
|
|
| Re: theide with libclang [message #59100 is a reply to message #59096] |
Wed, 02 November 2022 10:21   |
 |
mirek
Messages: 14291 Registered: November 2005
|
Ultimate Member |
|
|
Lance wrote on Wed, 02 November 2022 00:15Another more like a feature request:
Take for example, the following code:
class Person
{
int age_;
public:
int get_age()const { return age_; }
void set_age(int age){ age_ = age; }
__declspec(property(get=get_age, put = set_age)) int age;
};
theide/Assist++ will put a red rect at the beginning of __declspec, with error message ...'__declspec' attributes are not enabled; use '-fdeclspec'..., even though the flag has been turned on. This is kind of a fictitious example. The real issue here is, the flags I set in "Setup > Build Methods" for CLANG, under common c++ options
-std=c++20 -Wno-logical-op-parentheses -fdeclspec
is not respected by assist++.
So if someone wants to try some c++20 new language features, assist++ will stick to builtin option of '-std=c++14' and keep bugging him.
Well, this will be a bit complicated: We are not sure that libclang version is able to support -std=c++20.... Any ideas?
(In general, libclang is not the same thing as clang, so we cannot really use options from build method... Adding " -Wno-logical-op-parentheses -fdeclspec" as fixed options makes sense though.)
Mirek
|
|
|
|
| Re: theide with libclang [message #59103 is a reply to message #59097] |
Wed, 02 November 2022 15:58   |
 |
mirek
Messages: 14291 Registered: November 2005
|
Ultimate Member |
|
|
Lance wrote on Wed, 02 November 2022 01:58It might be something messed up in my system.
Quote:
Any chance you are trying to search in very long file? In that case, incremental search is disabled (and you need to push "Find next" button).
No.
Quote:
Do you see bottom bar with text?
Yes.
Quote:
Can you type text into into the field?
Yes.
Quote:
Have you tried pressing next/previous buttons?
Yes, nothing happen. O occurrence, or something like that.
Quote:
What about Find in files?
This has always worked fine.
By the way, if I don't go through the menu, but use Ctrl+F instead, I receive a ding, but nothing happen afterwards, not even the text field for entering text to be searched.
I have overwritten the previous compiled version of ide. Above replies are according to my memory. I don't think they matter any more since that problem might be unique to me.
I have installed 22.10 in Virtual Box and tested:

all seems fine 
(On the positively negative note, theide crashed the first time I have run it. I have noticed this before in Windows, so now it is officially a new phantom bug to fix...)
[Updated on: Wed, 02 November 2022 16:00] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #59110 is a reply to message #59106] |
Thu, 03 November 2022 20:06   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
additional c++ options for libclang works like a charm in most recent version 16528.
The setting is through:
Main Menu: Setup -> Settings ...
in Assist tab
Second last item "libclang additional options"
After I set it to
-Wno-logical-op-parentheses -std=c++20 -fdeclspec the following sample code are properly understood by Assist++
class Person
{
int age_;
public:
int get_age()const { return age_; }
void set_age(int age){ age_ = age; }
__declspec(property(get=get_age, put = set_age)) int age;
};
template <class T>
concept A = requires(T t) {
++t;
};
Wonderful! Imaging how much work it will involve if libclang is not used and we have to update the homegrown c++ parser to provide intellisense to the ever-updating c++ language.
I remember a while ago I dug into the parser while trying to add support to attribute: it is so complicated and involving that I had to give up.
It's great to see that libclang-powered assist++ becomes quite usable in rapid pace.
[Updated on: Thu, 03 November 2022 20:10] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: theide with libclang [message #59207 is a reply to message #59205] |
Thu, 24 November 2022 03:12  |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
mirek wrote on Wed, 23 November 2022 04:46Lance wrote on Wed, 23 November 2022 00:44Hi Mirek:
In dark theme, the error texts is not legible.

BR,
Lance
Hopefully fixed, thanks for reporting.
Thanks for the quick response. I will check github tomorrow. Version 16566 as of now still not fixed.
PS: Just compiled ver 16575. The problem is gone. Thanks!
[Updated on: Sat, 26 November 2022 01:07] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Mon Sep 14 09:49:44 GMT+2 2026
Total time taken to generate the page: 0.02670 seconds
|