Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 17, 2010 [Issue 4199] New: D2 core.sys.posix.setjmp segfaults | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4199 Summary: D2 core.sys.posix.setjmp segfaults Product: D Version: 2.041 Platform: Other OS/Version: FreeBSD Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: sean@invisibleduck.org ReportedBy: rsinfu@gmail.com --- Comment #0 from Shin Fujishiro <rsinfu@gmail.com> 2010-05-17 00:41:40 PDT --- This program core dumps on FreeBSD (and it should on Linux): -------------------- import core.sys.posix.setjmp; void main() { jmp_buf st = void; setjmp(st); assert(0); // trap; not reached due to the bug } -------------------- The C standard defines jmp_buf as an array. In C and D1, the definition works since arrays (static arrays) are passed to functions by reference. But in D2, static arrays are passed by value! Hence the above program core dumps. So, setjmp() and longjmp() must be declared as: -------------------- int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 17, 2010 [Issue 4199] D2 core.sys.posix.*: array parameters of C functions must be ref | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | http://d.puremagic.com/issues/show_bug.cgi?id=4199 Shin Fujishiro <rsinfu@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Platform|Other |All Summary|D2 core.sys.posix.setjmp |D2 core.sys.posix.*: array |segfaults |parameters of C functions | |must be ref OS/Version|FreeBSD |All --- Comment #1 from Shin Fujishiro <rsinfu@gmail.com> 2010-05-17 06:17:01 PDT --- Hmm, the problem seems more generic. More functions in core.sys.posix.* take array parameters, and these are not ref-ed. A good example is pipe(): -------------------- import std.stdio; import core.sys.posix.unistd; // int pipe(int[2]); void main() { int[2] pp; pipe(pp); writeln("Hello, world."); // not reached! } -------------------- The pipe() must be declared like: int pipe(ref int[2]). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 17, 2010 [Issue 4199] D2 core.sys.posix.*: array parameters of C functions must be ref | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | http://d.puremagic.com/issues/show_bug.cgi?id=4199 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution| |DUPLICATE --- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-05-17 06:34:35 PDT --- *** This issue has been marked as a duplicate of issue 3604 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation