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

Make NativeCall complain about the declaration of CPointers with attributes. #1767

Open
JJ opened this issue Apr 24, 2018 · 1 comment
Open

Comments

@JJ
Copy link
Collaborator

JJ commented Apr 24, 2018

The Problem

NativeCall does not complain when a CPointer has some internal structure. For instance

class p_timespec is repr('CPointer') {
    has uint32 $.tv_sec;
    has long $.tv_nanosecs;
}

Expected Behavior

CPointers shouldn't have any internal structure, and CStructs are actually pointers to that. So it should probably issue some helpful hint that what you're looking for is actually CStruct.

Actual Behavior

You can use it alright, it coredumps without any error mesage.

Steps to Reproduce

Run this

use v6;

use NativeCall;

class p_timespec is repr('CPointer') {
    has uint32 $.tv_sec;
    has long $.tv_nanosecs;
}
    
sub clock_gettime(uint32 $clock-id, p_timespec $tspec --> uint32) is native(Str) { * };

my p_timespec $this-time .=new;

my $result = clock_gettime( 0, $this-time);

say "$result, $this-time";

Result:

[3]    29411 segmentation fault (core dumped)  perl6 --ll-exception is-repr.p6

Environment

I'm using perl6 2018.03 in Ubuntu 14.04.

@lizmat
Copy link
Contributor

lizmat commented Apr 24, 2018

Perhaps some way to check / complain about such a situation in ClassHOW.compose?

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

3 participants