Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upC back-end: Passing struct by value fails #676
Comments
waywardmonkeys
added this to the 2014.1 milestone
Feb 9, 2014
waywardmonkeys
added
Compiler internals
labels
Feb 9, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
fracek
Jul 13, 2014
Member
I have the same problem when returning a struct by value.
Test case to reproduce this:
typedef struct git_oid {
unsigned char id[20];
} git_oid;
int my_function(git_oid *oid) {
return 0;
}
and
define C-struct <git-oid>
array slot git-oid$id :: <C-unsigned-char>, length: 20;
end;
define C-pointer-type <git-oid*> => <git-oid>;
define C-function my-function
output parameter out_ :: <git-oid*>;
result res :: <c-signed-int>;
c-name: "my_function";
end;
define function main
(name :: <string>, arguments :: <vector>)
let (err, oid) = my-function();
exit-application(0);
end function main;
stack trace:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
No next method.
No next method.
Breaking into debugger.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff6b458cb in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
37 ../nptl/sysdeps/unix/sysv/linux/pt-raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff6b458cb in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
#1 0x00007ffff768a8b2 in primitive_invoke_debugger (string=<optimized out>, arguments=0x5) at /home/cek/Dev/opendylan/sources/lib/run-time/c-primitives-debug.c:38
#2 0x00007ffff75e9aee in Kinvoke_debuggerVKiMM1I (condition_=<optimized out>) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/boot.c:7112
#3 0x00007ffff75ef822 in Khandle_missed_dispatchVKgI (d_=<optimized out>, parent_=<optimized out>, args_=0x7fffffffbd40) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/new-dispatch.c:14394
#4 0x00007ffff7681a02 in general_engine_node_n_engine (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2073
#5 0x00007ffff75fd451 in Kdefault_handlerVKdMM1I (condition_=0x4038) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/condition.c:2890
#6 0x00007ffff75ef822 in Khandle_missed_dispatchVKgI (d_=<optimized out>, parent_=<optimized out>, args_=0x7fffffffc1b0) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/new-dispatch.c:14394
#7 0x00007ffff7681a02 in general_engine_node_n_engine (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2073
#8 0x00007ffff79a9962 in Kdefault_last_handlerYcommon_dylan_internalsVcommon_dylanMM0I (condition_=<optimized out>, next_handler_=0x6b7820)
at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/common-extensions.c:1983
#9 0x00007ffff75fd2fd in KsignalVKdMM0I (condition_=0x6b5ea0, noise_=<optimized out>) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/condition.c:2712
#10 0x00007ffff75ef822 in Khandle_missed_dispatchVKgI (d_=<optimized out>, parent_=<optimized out>, args_=0x7fffffffcd50) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/new-dispatch.c:14394
#11 0x00007ffff7681a02 in general_engine_node_n_engine (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2073
#12 0x00007ffff75fd5ab in KerrorVKdMM0I (condition_=0x6b5ea0, noise_=<optimized out>) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/condition.c:2631
#13 0x00007ffff75ef822 in Khandle_missed_dispatchVKgI (d_=<optimized out>, parent_=<optimized out>, args_=0x7fffffffd210) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/new-dispatch.c:14394
#14 0x00007ffff7681a02 in general_engine_node_n_engine (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2073
#15 0x00007ffff75fd760 in KerrorVKdMM1I (string_=<optimized out>, arguments_=<optimized out>, arguments_=<optimized out>, string_=<optimized out>)
at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/condition.c:2604
#16 0x00007ffff642957f in Kpointer_valueVKcMc_ffiM10I (ptr_=<optimized out>, Urest_=<optimized out>, index_=<optimized out>) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../c-ffi/pointer-value.c:1885
#17 0x00007ffff767ed61 in key_mep_3 (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:1683
#18 0x00007ffff76830d0 in implicit_keyed_single_method_engine_1 (a1=0x4038, optionals=0x202) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2505
#19 0x00007ffff75ef822 in Khandle_missed_dispatchVKgI (d_=<optimized out>, parent_=<optimized out>, args_=0x7fffffffd820) at /home/cek/Desktop/test-c-struct/_build/build/test-c-struct/../common-dylan/../dylan/new-dispatch.c:14394
#20 0x00007ffff7681a02 in general_engine_node_n_engine (a1=<optimized out>) at /home/cek/Dev/opendylan/sources/lib/run-time/c-run-time.c:2073
#21 0x00007ffff7bdaf90 in Kmy_functionVtest_c_structI () at test-c-struct.c:916
#22 0x00007ffff7bdb14b in KmainVtest_c_structI (name_=<optimized out>, arguments_=<optimized out>) at test-c-struct.c:828
#23 _Init_test_c_struct__X_test_c_struct_for_user () at test-c-struct.c:1041
#24 0x00007ffff7deb85a in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffdda8, env=env@entry=0x7fffffffddb8) at dl-init.c:84
#25 0x00007ffff7deb943 in call_init (env=0x7fffffffddb8, argv=0x7fffffffdda8, argc=1, l=<optimized out>) at dl-init.c:36
#26 _dl_init (main_map=0x7ffff7ffe148, argc=1, argv=0x7fffffffdda8, env=0x7fffffffddb8) at dl-init.c:132
#27 0x00007ffff7dde1ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#28 0x0000000000000001 in ?? ()
#29 0x00007fffffffe1fa in ?? ()
#30 0x0000000000000000 in ?? ()
This on 64 bit Linux, using a recent-ish master build.
|
I have the same problem when returning a struct by value. Test case to reproduce this:
and
stack trace:
This on 64 bit Linux, using a recent-ish master build. |
waywardmonkeys
modified the milestones:
2014.1,
2015.1
Jan 24, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
waywardmonkeys commentedFeb 9, 2014
This works with HARP, so we should examine the differences between the code.
This is needed for things with the Objective C bridge.