Thread overview
UDA segfaults compiler
Jul 17
Elmar
Jul 18
Basile B.
Jul 18
Elmar
July 17

Hello D people,

I found a segmentation fault which I can reproduce with dmd and ldc2.

The attack code is simple:

alias getOne = @(0) function int () => 1;

It works without the UDA but segfaults with it. I found it because I wanted to have user-defined attributes to the return values of functions. I can't put the UDA after function so I put it before.

I believe, this is a forgotton corner case or something because the compiler tells me, UDAs are not allowed in alias definitions.

July 18

On Saturday, 17 July 2021 at 16:33:54 UTC, Elmar wrote:

>

Hello D people,

I found a segmentation fault which I can reproduce with dmd and ldc2.

The attack code is simple:

alias getOne = @(0) function int () => 1;

It works without the UDA but segfaults with it. I found it because I wanted to have user-defined attributes to the return values of functions. I can't put the UDA after function so I put it before.

I believe, this is a forgotton corner case or something because the compiler tells me, UDAs are not allowed in alias definitions.

This is an assertion failure in the parser, reported here.

The code you write should not compile because the FunctionLiteral rule does not include the UserDefinedAttributes one.

July 18

On Sunday, 18 July 2021 at 17:37:52 UTC, Basile B. wrote:

>

On Saturday, 17 July 2021 at 16:33:54 UTC, Elmar wrote:

>

Hello D people,

I found a segmentation fault which I can reproduce with dmd and ldc2.

The attack code is simple:

alias getOne = @(0) function int () => 1;

It works without the UDA but segfaults with it. I found it because I wanted to have user-defined attributes to the return values of functions. I can't put the UDA after function so I put it before.

I believe, this is a forgotton corner case or something because the compiler tells me, UDAs are not allowed in alias definitions.

This is an assertion failure in the parser, reported here.

The code you write should not compile because the FunctionLiteral rule does not include the UserDefinedAttributes one.

Thank you very much for clarification :-) ! I figured out UDAs are supposed to be attached to symbols only and because of compile-time staticness they can only be passed to a function via an alias-parameter but can't be passed to an op-function or constructor unfortunately. The deprecated dual-context makes it harder to pass them to methods and some other functions.

Thank you for adding the report!