Skip to content

gas parser: segfault in yasm_expr_get_intnum() #83

@emaste

Description

@emaste

Trying to build https://github.com/freebsd/freebsd/blob/master/sys/crypto/skein/amd64/skein_block_asm.s with yasm segfaults:

% ./yasm -p gas .../sys/crypto/skein/amd64/skein_block_asm.s
zsh: segmentation fault (core dumped) ./yasm -p gas

Host is FreeBSD 10.3, yasm source at 51af408

* (lldb) thread #1: tid = 102773, 0x0000000000467188 yasm`yasm_expr_get_intnum(ep=0x00007fffffffd7c8, calc_bc_dist=0) + 84 at expr.c:1377, stop reason = invalid address (fault address: 0x0)
    frame #0: 0x0000000000467188 yasm`yasm_expr_get_intnum(ep=0x00007fffffffd7c8, calc_bc_dist=0) + 84 at expr.c:1377
   1374 {
   1375     *ep = yasm_expr_simplify(*ep, calc_bc_dist);
   1376
-> 1377     if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_INT)
   1378         return (*ep)->terms[0].data.intn;
   1379     else
   1380         return (yasm_intnum *)NULL;
(lldb) bt
* thread #1: tid = 102773, 0x0000000000467188 yasm`yasm_expr_get_intnum(ep=0x00007fffffffd7c8, calc_bc_dist=0) + 84 at expr.c:1377, stop reason = invalid address (fault address: 0x0)
  * frame #0: 0x0000000000467188 yasm`yasm_expr_get_intnum(ep=0x00007fffffffd7c8, calc_bc_dist=0) + 84 at expr.c:1377
    frame #1: 0x000000000044042f yasm`eval_expr(pp=0x0000000801424020, arg1=0x0000000801415008) + 163 at gas-preproc.c:484
    frame #2: 0x000000000044060c yasm`eval_if(pp=0x0000000801424020, negate=0, arg1=0x0000000801415008) + 108 at gas-preproc.c:541
    frame #3: 0x0000000000442709 yasm`process_line(pp=0x0000000801424020, line_ptr=0x00007fffffffe038) + 825 at gas-preproc.c:1203
    frame #4: 0x0000000000442db2 yasm`gas_preproc_get_line(preproc=0x0000000801424020) + 283 at gas-preproc.c:1336
    frame #5: 0x000000000046ed9b yasm`preproc_input(parser_gas=0x00007fffffffe1d0, buf=0x0000000801426000, max_size=7689) + 81 at gas-token.re:64
    frame #6: 0x000000000046f144 yasm`fill(parser_gas=0x00007fffffffe1d0, cursor=0x0000000801426000) + 599 at gas-token.re:123
    frame #7: 0x000000000046f514 yasm`gas_parser_lex(lvalp=0x00007fffffffe330, parser_gas=0x00007fffffffe1d0) + 279 at gas-token.c:264
    frame #8: 0x000000000042abba yasm`gas_parser_parse(parser_gas=0x00007fffffffe1d0) + 578 at gas-parse.c:1742
    frame #9: 0x0000000000425f0b yasm`gas_parser_do_parse(object=0x0000000801420080, pp=0x0000000801424020, save_input=0, linemap=0x0000000801413040, errwarns=0x00000008014113e0) + 403 at gas-parser.c:83
    frame #10: 0x0000000000402821 yasm`do_assemble + 1819 at yasm.c:521
    frame #11: 0x0000000000403084 yasm`main(argc=4, argv=0x00007fffffffe540) + 1486 at yasm.c:752
    frame #12: 0x0000000000401abf yasm`_start(ap=<unavailable>, cleanup=<unavailable>) + 367 at crt1.c:72

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions