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
NativeCall segfault on rw struct pointer #4260
Comments
From jns@gellyfish.co.ukA large category of C library functions will take a pointer to a struct use v6; Program received signal SIGSEGV, Segmentation fault. ================================================================================================ foo.c: use v6; |
From @hoelzroOn 2015-05-24 04:54:10, jns@gellyfish.co.uk wrote:
I'm wondering if the reason for this is that struct utsname's members are char [] of unspecified sizes, rather than char *. |
The RT System itself - Status changed from 'new' to 'open' |
From @skidsThe problem is that struct utsname is different sizes on different kernels. At any rate in this specific case, you'd need shaped native CArray attributes |
From @ninerI'm rejecting this ticket because the given example is simply wrong. The fields in struct utsname are character arrays. The docs specify them as e.g. char sysname[]; which is a bit misleading as one would assume that this is the same as char *sysname. The NOTES section however explains that the length of those arrays differs from system to system. /usr/include/linux/utsname.h defines it as char sysname[__NEW_UTS_LEN + 1]; with #define __NEW_UTS_LEN 64 So the fields in the Utsname structs must be 65 bytes in length. The only way I know to express this with current NativeCall features is this piece of beauty: use v6.c; class Utsname is repr('CStruct') { sub uname(Utsname $utsname is rw --> int32) is native { ... } my $a = Utsname.new; uname($a); say join '', $a.^attributes.map({chr $_.get_value($a)}); |
@niner - Status changed from 'open' to 'rejected' |
From jns@gellyfish.co.ukNo I think you're right. A naive ticket :) On Thu, 2016-10-06 at 13:45 -0700, Stefan Seifert via RT wrote:
|
Migrated from rt.perl.org#125243 (status was 'rejected')
Searchable as RT125243$
The text was updated successfully, but these errors were encountered: