Euphoria Ticket #1016: External functions returning C_DOUBLE are called twice

https://openeuphoria.org/forum/135284.wc

libmytest.c

/* libmytest */ 
 
#include <stdio.h> 
 
double hello(double x) 
{ 
 printf("Hello! Your number was %g\n",x); 
 return x*2.0; 
} 
 
int main() 
{ 
 return 1; 
} 

libmytest.e

include std/dll.e 
atom mylib = open_dll("libmytest.so") 
atom fn = define_c_func(mylib,"hello",{C_DOUBLE},C_DOUBLE) 
printf(1,"Got back: %g\n", c_func(fn,{123.456})) 

build

gcc -shared -o libmytest.so libmytest.c 

trace

$ gdb eui 
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 
Reading symbols from eui...(no debugging symbols found)...done. 
(gdb) break hello 
Function "hello" not defined. 
Make breakpoint pending on future shared library load? (y or [n]) y 
Breakpoint 1 (hello) pending. 
(gdb) run libmytest.e 
Starting program: /usr/local/bin/eui libmytest.e 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 
 
Breakpoint 1, 0x00007ffff701f62e in hello () from ./libmytest.so 
(gdb) bt 
#0  0x00007ffff701f62e in hello () from ./libmytest.so 
#1  0x000000000057b074 in call_c () 
#2  0x00000000005780e3 in do_exec () 
#3  0x0000000000578a63 in Execute () 
#4  0x000000000057d301 in start_backend () 
#5  0x000000000057def8 in machine () 
#6  0x00000000004274be in _68BackEnd () 
#7  0x00000000004fe69c in _2BackEnd () 
#8  0x00000000004fa93a in _74main () 
#9  0x000000000041e0bf in main () 
(gdb) cont 
Continuing. 
Hello! Your number was 123.456 
 
Breakpoint 1, 0x00007ffff701f62e in hello () from ./libmytest.so 
(gdb) bt 
#0  0x00007ffff701f62e in hello () from ./libmytest.so 
#1  0x000000000057a590 in icall_x86_64 () 
#2  0x000000000057b09d in call_c () 
#3  0x00000000005780e3 in do_exec () 
#4  0x0000000000578a63 in Execute () 
#5  0x000000000057d301 in start_backend () 
#6  0x000000000057def8 in machine () 
#7  0x00000000004274be in _68BackEnd () 
#8  0x00000000004fe69c in _2BackEnd () 
#9  0x00000000004fa93a in _74main () 
#10 0x000000000041e0bf in main () 
(gdb) cont 
Continuing. 
Hello! Your number was 123.456 
Got back: 246.912 
warning: Temporarily disabling breakpoints for unloaded shared library "./libmytest.so" 
[Inferior 1 (process 2575) exited normally] 
(gdb) quit 

Details

Type: Bug Report Severity: Major Category: Library Routine
Assigned To: ghaberek Status: Fixed Reported Release: 4.1.0
Fixed in SVN #: View VCS: none Milestone: 4.1.0

1. Comment by ghaberek Feb 28, 2021

Fixed in commit 4f1ec34

Search



Quick Links

User menu

Not signed in.

Misc Menu