Skip to content

Bug : segmentation fault #31

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

Closed
pfeatherstone opened this issue Apr 26, 2022 · 8 comments
Closed

Bug : segmentation fault #31

pfeatherstone opened this issue Apr 26, 2022 · 8 comments

Comments

@pfeatherstone
Copy link
Contributor

Expected Behavior

We expect the following to work.

Actual Behavior

We get a segmentation fault.
It breaks when using local_storage and using move semantics.
The library just moves or swaps the underlying pointers. That won't work. Explicit move constructors MUST be called.
So I believe void_ptr should be upgraded to include:

  using ptr_t = void *;
  using del_t = void (*)(ptr_t);
  using copy_t = ptr_t (*)(ptr_t);
  using move_t = ptr_t(*)(ptr_t);
  
  ptr_t ptr;
  del_t del;
  copy_t copy;
  move_t move;

Steps to Reproduce the Problem

Run the godbolt link.

Specifications

Run on any system and it will break.

@pfeatherstone
Copy link
Contributor Author

If i run on my local machine i get output:

s1 `���-��` addr : 0x7fff2dc0c350
s2 `world` addr : 0x7fff2dc0c380

@pfeatherstone
Copy link
Contributor Author

I've had a go at fixing this. I'm not convinced the changes to void_ptr are trivial.

@pfeatherstone
Copy link
Contributor Author

First bug is use of std::aligned_storage<Size, Alignment> instead of std::aligned_storage_t<Size, Alignment>

@pfeatherstone
Copy link
Contributor Author

@krzysztof-jusiak any ideas ?

@pfeatherstone
Copy link
Contributor Author

I think i've fixed the library. But it definitely isn't polished. Here is a godbolt link

@kris-jusiak
Copy link
Contributor

nice @pfeatherstone 🗜️ Could you create a PR, please? thanks

@pfeatherstone
Copy link
Contributor Author

@krzysztof-jusiak Yes no problem

@pfeatherstone
Copy link
Contributor Author

Solved

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

No branches or pull requests

2 participants