Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » theide with libclang
Re: theide with libclang [message #58970 is a reply to message #58966] Mon, 03 October 2022 10:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Lance 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
Re: theide with libclang [message #58971 is a reply to message #58968] Mon, 03 October 2022 10:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
[quote title=Tom1 wrote on Mon, 03 October 2022 10:05]Mirek,

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
Re: theide with libclang [message #58972 is a reply to message #58969] Mon, 03 October 2022 11:30 Go to previous messageGo to next message
Tom1
Messages: 1217
Registered: March 2007
Senior Contributor
mirek wrote on Mon, 03 October 2022 11:34
Tom1 wrote on Mon, 03 October 2022 10:05
Mirek,

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 Go to previous messageGo to next message
Tom1
Messages: 1217
Registered: March 2007
Senior Contributor
[quote title=mirek wrote on Mon, 03 October 2022 11:48]Tom1 wrote on Mon, 03 October 2022 10:05
Mirek,

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 Go to previous messageGo to next message
Tom1
Messages: 1217
Registered: March 2007
Senior 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 #58976 is a reply to message #58974] Mon, 03 October 2022 13:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 03 October 2022 11:45
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


Thank you, very helpful. So I guess we can rule out dynamic loading and it now appears to be 14 specific.

I guess there is some bug in using the API.

Mirek
Re: theide with libclang [message #58978 is a reply to message #58970] Mon, 03 October 2022 15:51 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 534
Registered: March 2007
Contributor
mirek wrote on Mon, 03 October 2022 04:37
Lance 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 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
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:
index.php?t=getfile&id=6670&private=0

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 #58992 is a reply to message #58979] Sat, 08 October 2022 19:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Klugier wrote on Mon, 03 October 2022 23:20
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:
index.php?t=getfile&id=6670&private=0


I now strongly believe this is libclang bug. When I comment out ide/clang/Visitor.cpp:378

// CXPrintingPolicy_FullyQualifiedName,


, there seems to be no more crashes.

And it always crashes on the same node (standard library to_pointer method).

Can you (I mean everybody with crashing libclang) check above (while I am thinking about how to fix this).

Mirek
Re: theide with libclang [message #58993 is a reply to message #58992] Sat, 08 October 2022 21:29 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 534
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
/usr/bin/llvm-config-15

and
/usr/bin/llvm-config-14

but not
/usr/bin/llvm-config


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 #58994 is a reply to message #58992] Sat, 08 October 2022 21:54 Go to previous messageGo to next message
Tom1
Messages: 1217
Registered: March 2007
Senior Contributor
Hi Mirek,

Same here: No more crashes after commenting out.

BR,

Tom

Update: And by the way: I'm really seriously missing the auto completion for macros...

[Updated on: Sat, 08 October 2022 22:11]

Report message to a moderator

Re: theide with libclang [message #58995 is a reply to message #58994] Sat, 08 October 2022 23:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 08 October 2022 21:54
Hi Mirek,

Same here: No more crashes after commenting out.

BR,

Tom

Update: And by the way: I'm really seriously missing the auto completion for macros...


It is in todo list for now.

Mirek

Re: theide with libclang [message #58997 is a reply to message #58995] Sun, 09 October 2022 20:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Workaround is in master.

I have also tried to

- do something with Linux performance - hopefully indexer threads now should have lower priority, maybe
- changed default Assist settings - lower the number of threads etc... (but if you have already started theide, settings are already in config)

Let is hope this will move us past linux issues....
Re: theide with libclang [message #58998 is a reply to message #58997] Sun, 09 October 2022 21:19 Go to previous messageGo to next message
Tom1
Messages: 1217
Registered: March 2007
Senior Contributor
Hi Mirek,

Seems to run fine now in Linux Mint 21 here. Smile

However, should this workaround be POSIX only, or what are the consequences in Windows?:
#define UBUNTU2204_WORKAROUND // there appears to be a bug in Ubuntu 22.04.1LTS libclang 14

Best regards,

Tom
Re: theide with libclang [message #58999 is a reply to message #58998] Sun, 09 October 2022 23:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Tom1 wrote on Sun, 09 October 2022 21:19
Hi Mirek,

Seems to run fine now in Linux Mint 21 here. Smile

However, should this workaround be POSIX only, or what are the consequences in Windows?:
#define UBUNTU2204_WORKAROUND // there appears to be a bug in Ubuntu 22.04.1LTS libclang 14

Best regards,

Tom


Workaround basically implements what is crashing in another way. I will be better to keep the code the same for both platforms.

I could probably do without #define, it more or less for documentation purposes...

Mirek
Re: theide with libclang [message #59022 is a reply to message #58579] Sat, 15 October 2022 11:33 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
libclangd seems to have a problem with header files.
It expects a "}" at the end of the header file and it thinks the opening bracket is at a negative line number.
I see this with other header files too.
Upp Version 16497 on Windows 10 64 bit.

In "CurrentContext.cpp" there is no matching bracket for
namespace Upp {


index.php?t=getfile&id=6683&private=0



  • Attachment: ide.png
    (Size: 69.93KB, Downloaded 326 times)

[Updated on: Sat, 15 October 2022 13:39]

Report message to a moderator

Re: theide with libclang [message #59023 is a reply to message #59022] Sun, 16 October 2022 13:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
peterh wrote on Sat, 15 October 2022 11:33
libclangd seems to have a problem with header files.
It expects a "}" at the end of the header file and it thinks the opening bracket is at a negative line number.
I see this with other header files too.
Upp Version 16497 on Windows 10 64 bit.

In "CurrentContext.cpp" there is no matching bracket for
namespace Upp {


index.php?t=getfile&id=6683&private=0





Thanks. I am aware of that, this is one of bugs to address. Work in progress.
Re: theide with libclang [message #59070 is a reply to message #59023] Wed, 26 October 2022 16:00 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 534
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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Lance wrote on Wed, 26 October 2022 16:00
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.


Bug reports are always welcome!
Re: theide with libclang [message #59075 is a reply to message #59070] Thu, 27 October 2022 12:21 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Lance wrote on Wed, 26 October 2022 16:00

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


This part should be now fixed in master.
Previous Topic: Impressive improvement in stl::vector when dealing with raw memory.
Next Topic: about unicode supporting
Goto Forum:
  


Current Time: Wed Jun 12 20:12:36 CEST 2024

Total time taken to generate the page: 0.02185 seconds