Comments (5)
It's probably caused by ::std::mem::forget(lib);
at link.rs:60
.
from x11-rs.
If you still have that code, can you post the valgrind output? That line with forget(lib)
shouldn't be causing any problems to my knowledge. The swap just before it ensures that lib
is null, and forget
is called just to prevent the destructor from being called. It's not a nice way to accomplish what I wanted, but I wrote that code when I was new to Rust <.<
Sorry for the delayed response. I haven't had time for x11-dl
since I started going back to college, and I don't have anyone else to maintain it for me.
from x11-rs.
Hi, no problem! The output is in the <details> tag, unless you mean something else?
from x11-rs.
Whoops! I guess I missed that.
Digging through this, I'm noticing how ugly my old code is and remembering that I was rushing to get it working at the time, but in the process, I remembered something that I was fighting with when I wrote the code.
There was an issue somebody opened a long time ago in which Xlib::open()
(for each library struct) was crasing on some systems because it was using an absurd amount of stack memory, so I changed the function in a way that guarantees that only one copy of the struct could possibly be allocated on the stack. The init
function initializes the members by taking a pointer to the huge struct instead of returning an instance on success, as you would normally do in Rust.
While I was making this change, something strange happened. I wrote the destructor for DynamicLibrary
to check if the handle
was null before calling dlclose
, which seemed like a simple solution to a simple problem at the time. The only member in DynamicLibrary
is the handle, so an instance initialized with mem::zeroed()
shouldn't cause any problems. But for some reason it did. The very simple destructor for the very simple struct was crashing, and to this day, I still have no idea why.
I used mem::swap()
and mem::forget()
to get around this weird problem. There are two instances of DynamicLibrary
: one within the library struct and a temporary one. The one inside the struct gets a valid handle
which should be cleaned up with dlclose
when it is dropped, while the temporary one (which should be null after the swap) goes away with mem::forget()
to prevent the somehow crashing destructor from being called.
Judging by the valgrind output, it looks like dlclose
isn't being called. In my code in another project, the only Xlib
struct instantiated is inside a lazy_static
, so you would expect it to never be destroyed, but if Xlib
is dropped, then I don't see any reason that dlclose
would not be called. This is unsatisfying to say, but I have no idea why the code isn't working (or why the destructor used to crash in the old code before I push the current code). Maybe there's something obvious going on that I'm just missing for some reason.
from x11-rs.
I'm not sure it's such a major problem to be honest, maybe just leave the issue open?
from x11-rs.
Related Issues (20)
- x11 vs x11-dl? HOT 3
- undefined reference to `XOpenDisplay' HOT 1
- Debug implementation for XEvent is unsound
- XCreateIC returns null incorrectly but only if another crate (tempfile) is present HOT 1
- XshmSegmentInfo can't be created and its fields should be public
- unify x11/x11-dl crates with dlib HOT 2
- Can't run test_x11 test of my lib-crate even with xlib feature enabled HOT 6
- X11 build dependency failed. HOT 3
- Xcomposite extension HOT 1
- Xdamage extension HOT 1
- How to use the Xfixes extension? HOT 7
- MacOS Support HOT 3
- Can't load shared library on NetBSD
- Missing constant `None`? HOT 3
- Xlib::open takes up a significant amount of the binary HOT 5
- What is the difference between x11 and x11-dl? HOT 2
- Add documentation for the differences between x11 and x11-dl HOT 1
- x11-dl linker error when building musl target on Ubuntu 20.04 with rust 1.72+
- Does x11 support cross-compiling?
- libxext is not linked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x11-rs.