Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#[dtor] does not match semantics of #[ctor] #284

Open
melvyn2 opened this issue Jun 2, 2023 · 6 comments
Open

#[dtor] does not match semantics of #[ctor] #284

melvyn2 opened this issue Jun 2, 2023 · 6 comments

Comments

@melvyn2
Copy link

melvyn2 commented Jun 2, 2023

Registering a function with atexit does not really match what I would expect from this crate/attribute. I would expect that, like __attribute__((destructor)), the function is called at module unload time, which could occur at a different time than actual program exit.

@mmastrac
Copy link
Owner

Most likely dtor will be disappearing in a 1.0 release as it's been finicky to get working. I just need some time to get around to doing that major release.

@mmastrac
Copy link
Owner

mmastrac commented Jul 1, 2023

FWIW I'd be open to a discussion of the future of the API, but I think it is difficult to get this working cross-platform.

@melvyn2
Copy link
Author

melvyn2 commented Jul 1, 2023

for *bsd and linux, link_section = ".fini_array" should work (haven't tested yet), and __DATA,__mod_term_func works for macos. I can't find a corresponding section for windows (though I haven't looked far), but it certainly is possible with DllMain.

@CGMossa
Copy link

CGMossa commented Nov 12, 2023

I was banking on dtor-functionality :(

@mmastrac
Copy link
Owner

For ctor 1, I'm going to split the dtor functionality out into its own crate, where we can experiment with different design decisions.

I've create a placeholder crate for dtor for now, published from this repo: https://crates.io/crates/dtor

@CGMossa
Copy link

CGMossa commented Feb 27, 2024

Thanks! Somehow, I encountered an inconsistency that made me drop the whole idea (that includes using dtor), but I still think there is room for dtor as a whole.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants