Bug 307 – Inline assembler function call

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2006-08-23T02:06:00Z
Last change time
2015-06-09T05:14:54Z
Keywords
ice-on-valid-code
Assigned to
dvdfrdmn
Creator
m.faustino

Comments

Comment #0 by m.faustino — 2006-08-23T02:06:58Z
Using inline assembler to make a function call makes the compiler generate a segmentation fault: //----------------------------------------------- void main() { asm { call f; } } void f() {} //----------------------------------------------- With gdc 0.19, dmd 0.162 (gcc version 4.0.3).
Comment #1 by bugzilla — 2006-09-19T15:22:49Z
Not reproducible with DMC 0.167.
Comment #2 by thomas-dloop — 2006-09-20T11:53:13Z
This is a GDC issue(-> Product). Source and destination overlap in memcpy(0x52699C0, 0x52699C8, 24) at 0x4A21C9E: memcpy (mc_replace_strmem.c:116) by 0xB9054: Array::remove(unsigned) (array.c:146) by 0x1289E7: CompoundStatement::semantic(Scope*) (statement.c:330) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Invalid read of size 1 at 0x4A21D32: memcpy (mc_replace_strmem.c:405) by 0xB9054: Array::remove(unsigned) (array.c:146) by 0x1289E7: CompoundStatement::semantic(Scope*) (statement.c:330) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Address 0x52699D8 is 0 bytes after a block of size 40 alloc'd at 0x4A20F51: realloc (vg_replace_malloc.c:306) by 0x1048B3: Mem::realloc(void*, unsigned long) (mem.c:90) by 0xB8BEF: Array::reserve(unsigned) (array.c:71) by 0xB8D21: Array::push(void*) (array.c:94) by 0x11ACE7: Parser::parseStatement(int) (parse.c:2471) by 0x11C251: Parser::parseContracts(FuncDeclaration*) (parse.c:2091) by 0x11A165: Parser::parseDeclarations() (parse.c:2009) by 0x11929C: Parser::parseDeclDefs(int) (parse.c:186) by 0x122321: Parser::parseModule() (parse.c:125) by 0x113EC5: Module::parse(bool) (module.c:554) by 0x1467A1: d_parse_file(int) (d-lang.cc:921) by 0x654D88: toplev_main (toplev.c:1838) Invalid read of size 1 at 0x4A21D3B: memcpy (mc_replace_strmem.c:405) by 0xB9054: Array::remove(unsigned) (array.c:146) by 0x1289E7: CompoundStatement::semantic(Scope*) (statement.c:330) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Address 0x52699D9 is 1 bytes after a block of size 40 alloc'd at 0x4A20F51: realloc (vg_replace_malloc.c:306) by 0x1048B3: Mem::realloc(void*, unsigned long) (mem.c:90) by 0xB8BEF: Array::reserve(unsigned) (array.c:71) by 0xB8D21: Array::push(void*) (array.c:94) by 0x11ACE7: Parser::parseStatement(int) (parse.c:2471) by 0x11C251: Parser::parseContracts(FuncDeclaration*) (parse.c:2091) by 0x11A165: Parser::parseDeclarations() (parse.c:2009) by 0x11929C: Parser::parseDeclDefs(int) (parse.c:186) by 0x122321: Parser::parseModule() (parse.c:125) by 0x113EC5: Module::parse(bool) (module.c:554) by 0x1467A1: d_parse_file(int) (d-lang.cc:921) by 0x654D88: toplev_main (toplev.c:1838) Invalid read of size 1 at 0x4A21D42: memcpy (mc_replace_strmem.c:405) by 0xB9054: Array::remove(unsigned) (array.c:146) by 0x1289E7: CompoundStatement::semantic(Scope*) (statement.c:330) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Address 0x52699DA is 2 bytes after a block of size 40 alloc'd at 0x4A20F51: realloc (vg_replace_malloc.c:306) by 0x1048B3: Mem::realloc(void*, unsigned long) (mem.c:90) by 0xB8BEF: Array::reserve(unsigned) (array.c:71) by 0xB8D21: Array::push(void*) (array.c:94) by 0x11ACE7: Parser::parseStatement(int) (parse.c:2471) by 0x11C251: Parser::parseContracts(FuncDeclaration*) (parse.c:2091) by 0x11A165: Parser::parseDeclarations() (parse.c:2009) by 0x11929C: Parser::parseDeclDefs(int) (parse.c:186) by 0x122321: Parser::parseModule() (parse.c:125) by 0x113EC5: Module::parse(bool) (module.c:554) by 0x1467A1: d_parse_file(int) (d-lang.cc:921) by 0x654D88: toplev_main (toplev.c:1838) Invalid read of size 1 at 0x4A21D4B: memcpy (mc_replace_strmem.c:405) by 0xB9054: Array::remove(unsigned) (array.c:146) by 0x1289E7: CompoundStatement::semantic(Scope*) (statement.c:330) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Address 0x52699DB is 3 bytes after a block of size 40 alloc'd at 0x4A20F51: realloc (vg_replace_malloc.c:306) by 0x1048B3: Mem::realloc(void*, unsigned long) (mem.c:90) by 0xB8BEF: Array::reserve(unsigned) (array.c:71) by 0xB8D21: Array::push(void*) (array.c:94) by 0x11ACE7: Parser::parseStatement(int) (parse.c:2471) by 0x11C251: Parser::parseContracts(FuncDeclaration*) (parse.c:2091) by 0x11A165: Parser::parseDeclarations() (parse.c:2009) by 0x11929C: Parser::parseDeclDefs(int) (parse.c:186) by 0x122321: Parser::parseModule() (parse.c:125) by 0x113EC5: Module::parse(bool) (module.c:554) by 0x1467A1: d_parse_file(int) (d-lang.cc:921) by 0x654D88: toplev_main (toplev.c:1838) Invalid read of size 8 at 0x17E707: AsmProcessor::slotExp(Expression*) (d-asm-i386.h:2008) by 0x181208: AsmProcessor::parse() (d-asm-i386.h:2101) by 0x17C731: AsmStatement::semantic(Scope*) (d-asm-i386.h:1204) by 0x128A3F: CompoundStatement::semantic(Scope*) (statement.c:344) by 0xF1E2C: FuncDeclaration::semantic3(Scope*) (func.c:753) by 0x112A25: Module::semantic3() (module.c:697) by 0x146C76: d_parse_file(int) (d-lang.cc:982) by 0x654D88: toplev_main (toplev.c:1838) by 0x182387: main (main.c:35) Address 0x5000000BE is not stack'd, malloc'd or (recently) free'd ./a.d:0: interner Compiler-Fehler: Speicherzugriffsfehler Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.gentoo.org/> for instructions.
Comment #3 by braddr — 2006-11-25T15:08:16Z
Mass reassignment of gdc bugs from me to David.
Comment #4 by dvdfrdmn — 2006-12-16T21:16:22Z
Fixed in GDC 0.20