Skip to content
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

std.signals Segfault could take other delegates than member function pointers #9772

Open
dlangBugzillaToGithub opened this issue May 2, 2019 · 8 comments

Comments

@dlangBugzillaToGithub
Copy link

codemyst reported this on 2019-05-02T17:23:17Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=19842

CC List

  • Ajieskola

Description

When passing a lambda instead of a delegate to connect, it causes the app to segfault.

Tested with DMD 2.085.1.

Here's the most basic sample app that will reproduce the issue:

==========
import std.signals;
import std.stdio;

class Test
{
    mixin Signal!(int);

    void run ()
    {
        emit (1);
    }
}

class Tester
{
    void initialize ()
    {
        Test test = new Test ();
        test.connect ((int a) => trigger (a));
    }

    void trigger (int a)
    {
        writeln (a);
    }
}

void main ()
{
    Tester t = new Tester ();
    t.initialize ();
}
==========
@dlangBugzillaToGithub
Copy link
Author

Ajieskola commented on 2021-06-07T13:22:26Z

Lambda is a delegate in this context. I'm testing with v2.096.0 release canditate and latest Phobos.

This bug does not trigger only with lambda, it triggers with any delegate that is not a class member function.

The documentation does warn that the delegates must be class delegates, but it does not say that that they must be member function pointers. This needs to be clarified, or preferably it should be made to work with non-member-function delegates too.

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-06-07T13:59:02Z

@dukc created dlang/phobos pull request #8137 "Issue 19842 - only class member functions must be used be used as slots" mentioning this issue:

- Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8137

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-06-08T12:32:38Z

@dukc created dlang/phobos pull request #8139 "Issue 19842 - only class member functions must be used be used as slots" mentioning this issue:

- Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8139

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-06-08T12:34:02Z

@dukc created dlang/phobos pull request #8140 "Issue 19842 - only class member functions must be used be used as slots" mentioning this issue:

- Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8140

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-07-13T10:33:44Z

dlang/phobos pull request #8140 "Issue 19842 - only class member functions must be used be used as slots" was merged into stable:

- 235d3ba9bedf8cd7a9f697231b03f37bac9fd7d3 by Ate Eskola:
  Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8140

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-07-20T08:54:53Z

@MartinNowak created dlang/phobos pull request #8172 "merge stable" mentioning this issue:

- Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8172

@dlangBugzillaToGithub
Copy link
Author

dlang-bot commented on 2021-07-23T06:23:41Z

dlang/phobos pull request #8172 "merge stable" was merged into master:

- 06983381cf824cfae7b8a77d29b0b2fa8fe13c6f by Ate Eskola:
  Issue 19842 - only class member functions must be used be used as slots

https://github.com/dlang/phobos/pull/8172

@dlangBugzillaToGithub
Copy link
Author

Ajieskola commented on 2021-08-25T13:41:01Z

The documetation is now clarified, but it still would be a nice plus for the slot to accept any delegate of the correct type. I changed the severity to enhancement.

@thewilsonator thewilsonator removed P2 OS:Linux Issues specific to Linux Arch:x86_64 Issues specific to x86_64 labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants