-
Notifications
You must be signed in to change notification settings - Fork 18
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
dynamic_cast triggering DSI exception with -use-dynld #77
Comments
It seems the classic C++ problem that happens when you create a virtual class but don't define a non virtual destructor. And this cause problems when the object is destroyed. |
Any quick fix/workaround available? |
Am 2019-10-28 08:56, schrieb Hubert Maier:
@afxgroup [1]
Any quick fix/workaround available?
Don't use shared objects. You would need to supply an uptodate
libstdc++.so otherwise and differentiate this one from one that is
installed. It isn't worth the trouble.
|
That isn't possible, I'm afraid. Also, if there would be an up to date libstdc++.so, it wouldn't be a hassle to provide it, since I'm using a local sobjs dir with all mandatory (shared) libraries together with the app. Is the problem known and maybe already fixed? |
Am 2019-10-28 12:30, schrieb Hubert Maier:
That isn't possible, I'm afraid.
I can't build the app static anymore because of it's size.
I'm hitting the ram barrier (2 GB installed, only approx. 1.5 GB
usable), will run out of memory and ultimately crash on linking.
Linking statically or shared against libstdc++.a should not have such a
dramatic effect (unless you use lto). If linking against .so really
helps you out of this problem it would hit the same limit sooner than
later anyway.
Also, if there would be an up to date libstdc++.so, it wouldn't be a
hassle to provide it, since I'm using a local sobjs dir with all
mandatory (shared) libraries together with the app.
Is the problem known and maybe already fixed?
Linking against libstd++.a in a shared fashion is not recommended
because of the unclear ABI (the --thread=anative is nothing official).
If you supply your own .so objects you can do it as you like of course,
but there won't be any libstdc++.so from my side for end users because
the new ones are incompatible with the old ones and this will create a
mess. Until there is no official channel for this, and no official
solution for different flavour of shared objects, you should not use it
in a shared fashion.
If the purpose of using libstdc++.so is just a workaround for some other
problem it is much better to address the other problem.
Regarding the problem, have you checked that the proper "libstdc++.so"
is used (and not the one that sits in SOBJS:)?
|
@sba1 For me, the purpose of using dynamic linkage would be due to size of the binary and also sometimes the licenses. I'm also wondering would it be easy to support "gold" linker and would that help with Raziel's scenario? https://en.wikipedia.org/wiki/Gold_(linker) I created a local "sobjs" directory and copied libstdc++.so and libgcc.so there. According to GrimReaper, libstdc++.so was used from the local directory. I made another test where I assigned SOBJS: to RAM disk, and copied libc.so, libstdc++.so and libgcc.so (from GCC:lib) to RAM: and it still crashes. |
Am 2019-10-28 19:43, schrieb capehill:
@sba1 [1] For me, the purpose of using dynamic linkage would be due to
size of the binary and also sometimes the licenses.
Licenses would probably the only reason I could imagine that could
justify .so on AmigaOS, indeed. How this is applies on AmigaOS is a
different question though.
At the moment, you have to supply the .so file for your program so
binary size is not much of a difference. In fact, in the current
implementation of the .so you don't save any RAM at runtime as they are
not really shared (only the code is shared). License issues apart, .so
doen't have much benefit.
I'm also wondering
would it be easy to support "gold" linker and would that help with
Raziel's scenario? https://en.wikipedia.org/wiki/Gold_(linker)
A different linker could help of course depending on its implementation.
I created a local "sobjs" directory and copied libstdc++.so and
libgcc.so there. According to GrimReaper, libstdc++.so was used from
the local directory. I made another test where I assigned SOBJS: to
RAM disk, and copied libc.so, libstdc++.so and libgcc.so (from
GCC:lib) to RAM: and it still crashes.
Please also make sure that the compiler picks the correct .so at compile
time. There should be different flavours available: At least one for
clib2 and one for newlib (clib2 is unlikely to work with the threaded
model). If you mix them up, it is very probable that they fail. This is
the problem I was talking about: there is no way to differentiate
different flavours of the .so.
That doesn't mean that there is no problem in the current
implementation, but what is different with dynamic_cast than on any
other functions?
Anyway, given the limited resources we I have I suggest to stick to
static linking.
|
I'm afraid it is...see, the shared objects that are used to be linked into the executable aren't the problem, they are small enough to get linked.
Actually no. The solution is, to use every engine as "plugin", which is nothing else but a shared "library", load only if a game from said engine is requested by the main app.
Hmm, maybe I misunderstand, but i don't link shared to the static libstdc++.a.
Again, maybe I misunderstand, so don't get me wrong, but I don't need a libstdc++.so...I'd need a fix for the obvious and reproducable crash inside libstdc++. And one more thing I don't really understand...if a program links with libstdc++.so and no end user version will ever be available how would such a program work for end users in any way without providing the shared object?
Yes, I renamed the old libstdcc.so and only use gcc8.3.0's libstdc++.so everywhere, so it is picked up. Overall your answer is sadly very discouraging. |
Am 2019-10-29 00:05, schrieb Hubert Maier:
>> Also, if there would be an up to date libstdc++.so, it wouldn't be
>> a hassle to provide it, since I'm using a local sobjs dir with all
>> mandatory (shared) libraries together with the app. Is the problem
>> known and maybe already fixed?
> Linking against libstd++.a in a shared fashion is not recommended
> because of the unclear ABI (the --thread=anative is nothing
> official).
Hmm, maybe I misunderstand, but i don't link shared to the static
libstdc++.a.
That wouldn't work anyway, let alone all the linker errors I would
get, if I'd try to do so.
What I meant was linking against libstdc++ as a shared object (ignore
the suffix I used).
>> If you supply your own .so objects you can do it as you like of
>> course, but there won't be any libstdc++.so from my side for end
>> users because the new ones are incompatible with the old ones and
>> this will create a mess.
Again, maybe I misunderstand, so don't get me wrong, but I don't need
a libstdc++.so...I'd need a fix for the obvious and reproducable crash
inside libstdc++.
According to the initial report, crash will happen when linking against
libstdc++ using the dynamic linker and not when linking statically.
There were a lot of similar reports with other functions. And the
solution here was to make sure that the correct libstc++.so is used both
when linking and when running.
And one more thing I don't really understand...if a program links with
libstdc++.so and no end user version will ever be available how would
such a program work for end users in any way without providing the
shared object?
The obvious solution is to discourage the shared objects until solutions
to the problems (high probability of mixing up all flavors) I mentioned
are found and implemented and there is a channel to distribute new
versions. This only counts for libstdc++ but not for plugin-like
interfaces that are unique for a particular application.
Regarding the reported problem it is simply not clear where the problem
is. It could be
1) Mixup of shared objects (clib2 vs newlib2)
2) Usage of clib2 shared objects (I'm not sure how well this works with
a thread model as clib2 is not threadsafe)
3) Bug in binutils
4) Bug in elf.library
5) Some other weird thing.
I'm not yet convinced whether 1) and 2) is not a likely cause.
3), 4), and 5) are much harder to research and in particular 4) would
make it nearly impossible to see a fix in the distant future.
I also think that we can rule out a bug in libstdc++ because it is
working with the static linking.
Yes, I renamed the old libstdcc.so and only use gcc8.3.0's
libstdc++.so everywhere, so it is picked up.
Which ones (newlib vs clib2)? Does this also hold for all the other
involved shared objects?
Overall your answer is sadly very discouraging.
I know that resources are scarce and the overall outlook is grim, but
I had hoped for something to look forward to.
Unfortunately that will mean 2.1.0 will be the last release of scummvm
for amigaos4...
You can still try to link it via a cross compiler or disable few of
seldom used engines or to mix up static/shared. For instance, you could
try to link the libstdc++ statically to main program and still have keep
these plugins as .so. However, I don't know anything about the structure
of the scrummvm.
|
1+2) I'm not using clib2.
Newlib only Yes, I wrote a script that extracts and installs all needed sobjs from the main app (readelf -d) and copy them from sdk:local/newlib/lib to the apps personal sobjs drawer. |
Am 2019-10-29 11:20, schrieb Hubert Maier:
Yes, I wrote a script that extracts and installs all needed sobjs from
the main app (readelf -d) and copy them from sdk:local/newlib/lib to
the apps personal sobjs drawer.
So, everything that was used while compiling is also used while
running.
Just for the record: You tried the same minimal example as given by
capehill and observe the crash with all the correct .so files?
You don't observe the crash if you use some other functions, like
std::cout etc.?
|
No, not yet. All the information given is with scummvm.
I don't have a cross compiler set up, I don't even have a suitable system to do so and honestly, I would like to avoid using a foreign system to build amigaos4 binaries. The second idea is interesting, though. The problem is, that i already tried building scummvm that way and it errored on linking, due to the mix-up of shared and static. |
Thinking some more about it...would it also work if I simply remove/move libstdc++.so, so it isn't found by the linker (sdk: and sobjs:) and only provide libstdc++.a in the search path? Would that work and would libstdc++ then be linked statically? |
Am 2019-10-30 00:38, schrieb Hubert Maier:
Thinking some more about it...would it also work if I simply
remove/move libstdc++.so, so it isn't found by the linker (sdk: and
sobjs:) and only provide libstdc++.a in the search path?
I think that you would a linker error in this case.
Would that work and would libstdc++ then be linked statically?
There should be a special option: -static-libstdc++ which should force
the static linking of the library.
That way I could still link everything else shared, but could
circumvent the libstdc++.so bug?!
I don't know, there may be other side effects when following this
though.
|
However i've compiled and tested on Sam460 with all latest beta updates and that example doesn't crash. With or without virtual. I've compiled it with ubuntu cross compiler 8.3.0 |
Oh? Thank you |
i've tried that option but it seems not work. The shared object is always linked |
:-( |
I don't get a crash with the minimal example from post #1. i do get an output in the shell which reads readelf tells me this Dynamic section at offset 0x40cc contains 18 entries: and the example was linked with version SOBJS:libc.so file full libgcc.so 894549 ----rw-d 23-Oct-19 21:47:14 |
Well, the "simplified" one doesn't lonk for me, i get The "normal" one is attached |
dyncast_normal.lha.zip |
It should be .cpp. Not sure what is going on there. Please note that I had to zip my lha (Github..) but when I download my attachment, it's .cpp file for sure. |
Yep, i was c&ping your code, seems there is a stray char somewhere. Downloaded and i get a crash |
So, i "fixed" it, if you can call that fixing. Short: The reason of the crash is not some error in libstdc++ (at least, i don't think so anymore), but because of a "faulty/foreign/whatever" directory structure on my end. Long: I've lost too much hair and nerves over that one, so bear with me as you all should share some of the misery i was going through ;-) The luck i was granted was the fact that i still had ONE scummvm source dir which produced a working binary (no crash, no oddities, all of the games running and the best thing...it was a shared build!!!) First step: Second step: Third step: I also remembered that i had to move the good directory across partitions when i wanted to copy it (WB copy complained about a locked file and refused to "copy clone"), it the other day. I did a test by "copy clone"ing the good directory and IT CRASHED...What the heck??? Next i copied the good directory across partitions and back to where it was (renaming it and deleting all of the other [bad] directories). Last step: Having cornered the problem to being something wrong with the directory structure, i now blame ScummVM's filesystem access. I didn't test any more possibilities, but i guess that already gives an idea on what might be going wrong. I do have a request now and i know this is asking very much, given your time constraints and dedication to other projects. It's here and it's hopefully not very big. I will do any changes locally and test myself of course. Pretty please? |
I had same problem in many of my ports and this happens with filesystem.. But most of the time the culprit was JXFS. Even if in my opinion is a mix of file system and newlib. |
sigh :-( Did you find a workaround for your ports (apart from my hack to manually create the directory structures)? Are those problems still due with the beta NGFS (you are a betatester, i assume?) As much as i like to have and work with these shared builds (now that they work), i feel like i'm constantly treading on thin ice on a warm spring day...and it already crackles all around me. Thank you for the feedback |
No. No solution except to test everything first on FFS (or at least SFS). JXFS is one of the fastest file systems we have but is bugged and no more updated by Joerg. |
Confirmed crashing in ram: when using a directory structure created with mkdir |
So the crash points still to dynamic_cast or? Of all those dynamic_casts in ScummVM, majority seems to be in "titanic" engine according to Github search. |
Yep, it still does |
Update: I don't get it in dynamic_cast anymore and i also don't get DAR zero accesses (updated newlib fixed that) Progress? This is where i get the crash now, everytime Anyone can give me a new hint, maybe? btw2: The workaround/hack with the "sane" directory" structure doesn't work anymore either. Crash log for task "scummvm" Register dump: FPR (Floating Point Registers, NaN = Not a Number): FPSCR (Floating Point Status and Control Register): 0x82004000 SPRs (Special Purpose Registers): 680x0 emulated registers: Symbol info: Stack trace: PPC disassembly: System information: CPU Machine |
@raziel- that is a zero page hit, please check disassembly + registers. I think DAR display is wrong (IIRC there is some difference depending whether you look at the Grim Reaper display vs. serial line?). R26 is zero anyway. So I fetched the latest ScummVM and build it (gmake clean; gmake) on GCC 10.2. With -use-dynld I get dynamic_cast related crash, binary loads with static linkage. I copied libstd++.so and libgcc.so to local SOBJS/ directory. I get the crash when loading the ScummVM launcher, no games needed. Here is what I have on serial now: |
Ok...standing by. Thank you |
i would try to compile it with my clib2 and SDL2 (i've successfully compiled) but as i told you i have a strange error on ScummVM compilation and so i can't check what is wrong |
@raziel- https://www.amigans.net/modules/xforum/viewtopic.php?post_id=121395#forumpost121395 Okay so I'm not building with "plugins", I have only enabled -use-dynld in ScummVM makefile to trigger the dynamic_cast-related DSI. I can try to build the plugins versions too. |
Just to rule out every possibility, yes that would be nice Btw: if you use the inst_ext_so.rexx script from dists/amigaos you dont need to go hunting for the sobjs. Inst_ext_so.rexx your-shared-exe full-path-to-your-shared-exe and it will gather and copy all needed sobjs to a subdir called sobjs where your binary is. |
I don't have your emails anymore, please could you post your error here? |
I got your crash reproduced. I don't understand it completely but it seems to me, that symbol called "mini_CurrentContext" (exported by SDL2) is not visible or accessible to ScummVM when plugin-compilation is used. I tried to print the pointer but it just crashed(!). The idea is that minigl.library needs to set this pointer and then application is implicitly using it when making those gl* calls. So I added a hack on ScummVM side, like: extern "C" { And then I was able to print the pointer and ScummVM continued until the DSI caused by dynamic_cast ;) So regarding this OpenGL-related issue we need to understand what is difference between plugin vs. normal build, but we should probably discuss it somewhere else and leave this thread for dynamic_cast-related puzzles. |
Ok, At least you found inconsistency, if not a bug, so thats a good thing. |
i had the same problem with SDL and mini_CurrentContext on clib2. I had to add -lGL to get it but it cause double definitions functions sometimes because they are defined in both SDL and GL |
But wouldn't that mean that SDL is simply missing a definition GL has? Bear with me if i ask stupid questions... |
SDL doesn't miss a definition. It seems to miss the implementation. Take a look at SDL code `/* The client program needs access to this context pointer
This means that is defined there but never assigned. So you should add the code to assign it into your program. However i don't know why it is defined in SDL but never assigned. maybe @capehill know the SDL code better than us |
MiniGL sets the pointer during MakeCurrent. This is an old mechanism (SDL1 has it) and not invented by me so I don't know the detailed history. minigl.h: #define CC mini_CurrentContext MGLAPI void mglMakeCurrent(void *context) It works okay in normal scenarios with libSDL2.a and libSDL2.so. However now there is something new which trigger issues in ScummVM plugin build. But this is off-topic until someone points a connection to C++ dynamic_cast. |
Yes, indeed. MiniGL not SDL. That's why if you don't link the exe with MiniGL it find the undefined references. But libGL.a is a static library and maybe cause problems with shared objects if linked against it |
Hello there, I spent the last weeks trying to debug this with @raziel- for our new cross-compilation toolchain. Long story short, the ELF dynamic linker (elf.library) of AmigaOS doesn't seem to handle R_PPC_ADDR32 for dynamic symbols. For the problem specifically described here, one needs to be quite fluent with GCC handling of RTTI (more information at Itanium ABI followed by GCC). The crash comes from dynamic_cast when it tries to execute |
/worship @lephilousophe |
I can confirm that the patch fixes DSI crash in dynamic_cast with native builds. |
I recompiled simple example using https://github.com/sodero/adtools/releases/tag/10.3.0_2 and it worked without crash. Closing this ticket. Thank you. Do you think this issue should be checked further by elf.library maintainers? |
Yes, it should be checked and possibly fixed there. |
@capehill, I don't understand. The sodero tag doesn't include my patch. |
Funny, regarding this I build my local shared scummvm based on this release, I think, and it works aswell...intruiging. |
I just did a quick one-off build and shared the binary on GitHub. The patch is included in the binary in other words. Instead of commiting I created this PR. Much better than having two repos. |
Ah, that explains it. Thank you |
@sodero thanks for the explanation. |
There was a report ( http://www.amigans.net/modules/xforum/viewtopic.php?post_id=116034#forumpost116034 ) that dynamic_cast crashes with DSI when using shared objects. I was trying to create a simpler example to reproduce the crash but got a different symptom.
The example crashes with 2 conditions: -use-dynld and virtual inheritance. Switching to static objects or removing "virtual" keyword seems to remove DSI exception.
GCC 10.2.0.
EDIT: simplified example more and added -gstabs. Added binary archive too.
dyncast_crash.zip
EDIT2: added DSI into title.
EDIT3: removed ISI from title, updated GCC version from 8 to 10.
dyncast_new_serial_log.txt
The text was updated successfully, but these errors were encountered: