Csound Csound-dev Csound-tekno Search About

macro heavy orc segfaulting parser

Date2016-02-19 05:42
FromKelly Hirai
Subjectmacro heavy orc segfaulting parser
Attachmentswii_jazz2.orc  wii-w1.sco  
heres the back trace from a fresh git pull and attached are the sco and
orc pair.

i haven't used this in a couple years, (csound5) but i'm pretty sure it
worked without a segfault.

sorry this is a bit of a dump. if i have time over the weekend i will
try to pair it down to a simpler case. 

kelly

(gdb) run wii_jazz.orc wii-w1.sco
Starting program: /usr/local/bin/csound wii_jazz.orc wii-w1.sco
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
virtual_keyboard real time MIDI plugin for Csound
0dBFS level = 32768.0
Csound version 6.07 (double samples) Feb 18 2016
libsndfile-1.0.26
orchname:  wii_jazz.orc
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
defining argument _WIIINIT__MOTE as...#0#

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00, yyscanner=0x70cc60)
at /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
1200          uint64_t locn = PARM->locn;
(gdb) backfull
Undefined command: "backfull".  Try "help".
(gdb) back full
#0  0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00,
yyscanner=0x70cc60) at
/home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
        n = 808333369
#1  0x00007ffff7b2c5d2 in csound_prelex (csound=0x604010,
yyscanner=0x70cc60) at
/home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:490
        x = 0x7ffff7333c00
        y = 0x0
        n = 0
        yy_current_state = 104
        yy_cp = 0x7ffff7a3854e  "H\201\354", 
        yy_bp = 0x70e881 ""
        yy_act = 104
        yyg = 0x70cc60
#2  0x00007ffff7b442e0 in csoundParseOrc (csound=0x604010, str=0x0) at
/home/khirai/csound/src/csound6/csound/Engine/new_orc_parser.c:183
        qq = {yyscanner = 0x70cc60, macros = 0x70e630, alt_stack =
0x70e710, macro_stack_ptr = 1, macro_stack_size = 10, ifdefStack = 0x0,
isIfndef = 0 '\000',
          isString = 0 '\000', line = 1, locn = 258, llocn = 0, depth =
1, lstack = {1, 2, 63, 0 }}
        err = 32767
        O = 0x611828
#3  0x00007ffff7b42834 in csoundCompileOrc (csound=0x604010, str=0x0) at
/home/khirai/csound/src/csound6/csound/Engine/csound_orc_compile.c:1764
        root = 0x0
        retVal = 0
        tmpExitJmp = {{__jmpbuf = {0, -1606305545584315664, 4199216,
140737488342560, 0, 0, 1606306095917495024, 1606287919737271024},
__mask_was_saved = 0,
            __saved_mask = {__val = {0 }}}}
#4  0x00007ffff7a3d1a9 in csoundCompileArgs (csound=0x604010, argc=2,
argv=0x7fffffffce28) at
/home/khirai/csound/src/csound6/csound/Top/main.c:257
        O = 0x611828
        s = 0x604010 "\316z\243\367\377\177"
        xfile = 0x0
        n = 0
        csdFound = 0
        fileDir = 0x701f90 "k\016&\345\377\177"
#5  0x00007ffff7a3df95 in csoundCompile (csound=0x604010, argc=3,
argv=0x7fffffffce28) at
/home/khirai/csound/src/csound6/csound/Top/main.c:511
        result = 32767
#6  0x0000000000401845 in main (argc=3, argv=0x7fffffffce28) at
/home/khirai/csound/src/csound6/csound/frontends/csound/csound_main.c:316
        csound = 0x604010
        fname = 0x0
        i = 3
        result = 4199216
        nomessages = 0
(gdb)



Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-02-19 07:34
FromOeyvind Brandtsegg
SubjectRe: macro heavy orc segfaulting parser
I think you need to terminate the macro expansions. For example $MOTE
should be $MOTE.
At least I had this issue when updating an instrument from Csound5 to 6.
I tried doing this in your document, and it did not solve the problem
(although I still think you need to do this as well).
You also have some macro expansions for which I can find no argument
in the macro definition. For example
#define WIIINSTR(MOTE) ...
has in it this code:
   kskip_$MOTE tab kskipidx_$MOTE, $TAB_RHY
not sure if this is the bottom of it either, we'll see...

I think the problem lies in the WIIINSTR macro.
Can you try to clean it up, or strip it down?

all best
Oeyvind

2016-02-19 6:42 GMT+01:00 Kelly Hirai :
> heres the back trace from a fresh git pull and attached are the sco and
> orc pair.
>
> i haven't used this in a couple years, (csound5) but i'm pretty sure it
> worked without a segfault.
>
> sorry this is a bit of a dump. if i have time over the weekend i will
> try to pair it down to a simpler case.
>
> kelly
>
> (gdb) run wii_jazz.orc wii-w1.sco
> Starting program: /usr/local/bin/csound wii_jazz.orc wii-w1.sco
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> virtual_keyboard real time MIDI plugin for Csound
> 0dBFS level = 32768.0
> Csound version 6.07 (double samples) Feb 18 2016
> libsndfile-1.0.26
> orchname:  wii_jazz.orc
> rtaudio: ALSA module enabled
> rtmidi: ALSA Raw MIDI module enabled
> defining argument _WIIINIT__MOTE as...#0#
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00, yyscanner=0x70cc60)
> at /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
> 1200          uint64_t locn = PARM->locn;
> (gdb) backfull
> Undefined command: "backfull".  Try "help".
> (gdb) back full
> #0  0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00,
> yyscanner=0x70cc60) at
> /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
>         n = 808333369
> #1  0x00007ffff7b2c5d2 in csound_prelex (csound=0x604010,
> yyscanner=0x70cc60) at
> /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:490
>         x = 0x7ffff7333c00
>         y = 0x0
>         n = 0
>         yy_current_state = 104
>         yy_cp = 0x7ffff7a3854e  "H\201\354",  sequence \350>
>         yy_bp = 0x70e881 ""
>         yy_act = 104
>         yyg = 0x70cc60
> #2  0x00007ffff7b442e0 in csoundParseOrc (csound=0x604010, str=0x0) at
> /home/khirai/csound/src/csound6/csound/Engine/new_orc_parser.c:183
>         qq = {yyscanner = 0x70cc60, macros = 0x70e630, alt_stack =
> 0x70e710, macro_stack_ptr = 1, macro_stack_size = 10, ifdefStack = 0x0,
> isIfndef = 0 '\000',
>           isString = 0 '\000', line = 1, locn = 258, llocn = 0, depth =
> 1, lstack = {1, 2, 63, 0 }}
>         err = 32767
>         O = 0x611828
> #3  0x00007ffff7b42834 in csoundCompileOrc (csound=0x604010, str=0x0) at
> /home/khirai/csound/src/csound6/csound/Engine/csound_orc_compile.c:1764
>         root = 0x0
>         retVal = 0
>         tmpExitJmp = {{__jmpbuf = {0, -1606305545584315664, 4199216,
> 140737488342560, 0, 0, 1606306095917495024, 1606287919737271024},
> __mask_was_saved = 0,
>             __saved_mask = {__val = {0 }}}}
> #4  0x00007ffff7a3d1a9 in csoundCompileArgs (csound=0x604010, argc=2,
> argv=0x7fffffffce28) at
> /home/khirai/csound/src/csound6/csound/Top/main.c:257
>         O = 0x611828
>         s = 0x604010 "\316z\243\367\377\177"
>         xfile = 0x0
>         n = 0
>         csdFound = 0
>         fileDir = 0x701f90 "k\016&\345\377\177"
> #5  0x00007ffff7a3df95 in csoundCompile (csound=0x604010, argc=3,
> argv=0x7fffffffce28) at
> /home/khirai/csound/src/csound6/csound/Top/main.c:511
>         result = 32767
> #6  0x0000000000401845 in main (argc=3, argv=0x7fffffffce28) at
> /home/khirai/csound/src/csound6/csound/frontends/csound/csound_main.c:316
>         csound = 0x604010
>         fname = 0x0
>         i = 3
>         result = 4199216
>         nomessages = 0
> (gdb)
>
>
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Date2016-02-22 05:27
FromKelly Hirai
SubjectRe: macro heavy orc segfaulting parser
so i couldn't get this simple orc sco pair to run. same segfault in the
same lex call.

if i pack it into a csd, it works. 
k.

;; dbg.sco ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
i 1 0 5
e

;; dbg.orc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

#define F(arg)
#
 
#
    instr 1

$F(0)
    endin

;;  dbg.csd  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


-odac           -iadc     -d     ;;;RT audio I/O



; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

#define F(arg)
#
 
#
    instr 1

$F(0)
    endin





i 1 0 2
e








On 02/19/2016 02:34 AM, Oeyvind Brandtsegg wrote:
> I think you need to terminate the macro expansions. For example $MOTE
> should be $MOTE.
> At least I had this issue when updating an instrument from Csound5 to 6.
> I tried doing this in your document, and it did not solve the problem
> (although I still think you need to do this as well).
> You also have some macro expansions for which I can find no argument
> in the macro definition. For example
> #define WIIINSTR(MOTE) ...
> has in it this code:
>    kskip_$MOTE tab kskipidx_$MOTE, $TAB_RHY
> not sure if this is the bottom of it either, we'll see...
>
> I think the problem lies in the WIIINSTR macro.
> Can you try to clean it up, or strip it down?
>
> all best
> Oeyvind
>
> 2016-02-19 6:42 GMT+01:00 Kelly Hirai :
>> heres the back trace from a fresh git pull and attached are the sco and
>> orc pair.
>>
>> i haven't used this in a couple years, (csound5) but i'm pretty sure it
>> worked without a segfault.
>>
>> sorry this is a bit of a dump. if i have time over the weekend i will
>> try to pair it down to a simpler case.
>>
>> kelly
>>
>> (gdb) run wii_jazz.orc wii-w1.sco
>> Starting program: /usr/local/bin/csound wii_jazz.orc wii-w1.sco
>> [Thread debugging using libthread_db enabled]
>> Using host libthread_db library "/lib64/libthread_db.so.1".
>> virtual_keyboard real time MIDI plugin for Csound
>> 0dBFS level = 32768.0
>> Csound version 6.07 (double samples) Feb 18 2016
>> libsndfile-1.0.26
>> orchname:  wii_jazz.orc
>> rtaudio: ALSA module enabled
>> rtmidi: ALSA Raw MIDI module enabled
>> defining argument _WIIINIT__MOTE as...#0#
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00, yyscanner=0x70cc60)
>> at /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
>> 1200          uint64_t locn = PARM->locn;
>> (gdb) backfull
>> Undefined command: "backfull".  Try "help".
>> (gdb) back full
>> #0  0x00007ffff7b31ee3 in csound_pre_line (cf=0x701f00,
>> yyscanner=0x70cc60) at
>> /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:1200
>>         n = 808333369
>> #1  0x00007ffff7b2c5d2 in csound_prelex (csound=0x604010,
>> yyscanner=0x70cc60) at
>> /home/khirai/csound/src/csound6/csound/Engine/csound_pre.lex:490
>>         x = 0x7ffff7333c00
>>         y = 0x0
>>         n = 0
>>         yy_current_state = 104
>>         yy_cp = 0x7ffff7a3854e  "H\201\354", > sequence \350>
>>         yy_bp = 0x70e881 ""
>>         yy_act = 104
>>         yyg = 0x70cc60
>> #2  0x00007ffff7b442e0 in csoundParseOrc (csound=0x604010, str=0x0) at
>> /home/khirai/csound/src/csound6/csound/Engine/new_orc_parser.c:183
>>         qq = {yyscanner = 0x70cc60, macros = 0x70e630, alt_stack =
>> 0x70e710, macro_stack_ptr = 1, macro_stack_size = 10, ifdefStack = 0x0,
>> isIfndef = 0 '\000',
>>           isString = 0 '\000', line = 1, locn = 258, llocn = 0, depth =
>> 1, lstack = {1, 2, 63, 0 }}
>>         err = 32767
>>         O = 0x611828
>> #3  0x00007ffff7b42834 in csoundCompileOrc (csound=0x604010, str=0x0) at
>> /home/khirai/csound/src/csound6/csound/Engine/csound_orc_compile.c:1764
>>         root = 0x0
>>         retVal = 0
>>         tmpExitJmp = {{__jmpbuf = {0, -1606305545584315664, 4199216,
>> 140737488342560, 0, 0, 1606306095917495024, 1606287919737271024},
>> __mask_was_saved = 0,
>>             __saved_mask = {__val = {0 }}}}
>> #4  0x00007ffff7a3d1a9 in csoundCompileArgs (csound=0x604010, argc=2,
>> argv=0x7fffffffce28) at
>> /home/khirai/csound/src/csound6/csound/Top/main.c:257
>>         O = 0x611828
>>         s = 0x604010 "\316z\243\367\377\177"
>>         xfile = 0x0
>>         n = 0
>>         csdFound = 0
>>         fileDir = 0x701f90 "k\016&\345\377\177"
>> #5  0x00007ffff7a3df95 in csoundCompile (csound=0x604010, argc=3,
>> argv=0x7fffffffce28) at
>> /home/khirai/csound/src/csound6/csound/Top/main.c:511
>>         result = 32767
>> #6  0x0000000000401845 in main (argc=3, argv=0x7fffffffce28) at
>> /home/khirai/csound/src/csound6/csound/frontends/csound/csound_main.c:316
>>         csound = 0x604010
>>         fname = 0x0
>>         i = 3
>>         result = 4199216
>>         nomessages = 0
>> (gdb)
>>
>>
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-02-22 08:07
FromTarmo Johannes
SubjectRe: macro heavy orc segfaulting parser

I have had similar problems - if to use sco and orc separately and they contain macros, csoundĀ  from develop branch crashes(or I have not checked lately) 6.06 works. I was trying to pin out on what conditions the crash exactly happens, but have not done it yet...
Tarmo

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-02-22 16:05
Fromjpff
SubjectRe: macro heavy orc segfaulting parser
I can reproduce and am investigating.  Looks like macros in orc files. 
Currently not sure what is different from csd case.
==John

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here