Skip to content

Instantly share code, notes, and snippets.

@tmmsartor
Last active February 12, 2021 21:30
Show Gist options
  • Save tmmsartor/ab8a5dc79838471ca85864bacbeaea43 to your computer and use it in GitHub Desktop.
Save tmmsartor/ab8a5dc79838471ca85864bacbeaea43 to your computer and use it in GitHub Desktop.
casadi_issue_2611

See casadi/casadi#2611 and the attached files.

In particular the following lines from format_paramlist.c:

   int n = Len(paramlist);
   int i;

   bool print_sep = false;
   for (i=0;i<n;++i) {
   	Hash *node = Getitem(paramlist, i);

are compiled by gcc8 in the following instructions (the rest in format_paramlist_gcc8.S)

   ad1e8:	e8 23 42 f8 ff       	callq  31410 <DohLen>
   ad1ed:	31 f6                	xor    %esi,%esi
   ad1ef:	48 89 df             	mov    %rbx,%rdi
   ad1f2:	89 44 24 24          	mov    %eax,0x24(%rsp)
   ad1f6:	e8 c5 49 f8 ff       	callq  31bc0 <DohGetitem>

Which means that (Getitem) is called directly after (Len) without performing any checks and if Getitem is called with list with zero len it the assertion in the fuction will fail

how to replicate

Assembly code is generated with the following copilation commands

$ export CC="gcc-8" && export CXX="g++-8"
# $ export CC="gcc-7" && export CXX="g++-7"
$ ./autogen
$ ./configure --prefix=$HOME/.local
$ make -j4

and then disassembled with

$ objdump -d --demangle swig > swig.S

The gdb backtrace can be obtained with:

(gdb) file /home/user/.local/bin/swig
# (gdb) break DOH/list.c:167 if n>= l->nitems
(gdb) break Modules/lang.cxx:3956
(gdb) run -v -matlab -DSWIG_TYPE_TABLE=casadi -fvirtual -DWITH_DEPRECATED_FEATURES -outdir swig/matlab -c++ -I.. -I. -o swig/casadiMATLAB_wrap.cxx ../swig/casadi.i
00000000000ab540 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)>:
ab540: 41 57 push %r15
ab542: 41 56 push %r14
ab544: 49 89 fe mov %rdi,%r14
ab547: 41 55 push %r13
ab549: 41 54 push %r12
ab54b: 48 89 f7 mov %rsi,%rdi
ab54e: 55 push %rbp
ab54f: 53 push %rbx
ab550: 48 83 ec 48 sub $0x48,%rsp
ab554: 48 89 74 24 08 mov %rsi,0x8(%rsp)
ab559: 48 89 54 24 28 mov %rdx,0x28(%rsp)
ab55e: 48 89 4c 24 30 mov %rcx,0x30(%rsp)
ab563: 4c 89 44 24 38 mov %r8,0x38(%rsp)
ab568: 4c 89 4c 24 20 mov %r9,0x20(%rsp)
ab56d: e8 0e 56 f8 ff callq 30b80 <DohLen>
ab572: 85 c0 test %eax,%eax
ab574: 0f 8e 7f 01 00 00 jle ab6f9 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1b9>
ab57a: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi
ab57f: 31 f6 xor %esi,%esi
ab581: 41 89 c7 mov %eax,%r15d
ab584: 31 ed xor %ebp,%ebp
ab586: e8 a5 5d f8 ff callq 31330 <DohGetitem>
ab58b: 49 89 c5 mov %rax,%r13
ab58e: eb 49 jmp ab5d9 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x99>
ab590: 48 8b 54 24 20 mov 0x20(%rsp),%rdx
ab595: 48 8d 35 01 69 0e 00 lea 0xe6901(%rip),%rsi # 191e9d <typeinfo name for XML+0x27a>
ab59c: 31 c0 xor %eax,%eax
ab59e: 4c 89 f7 mov %r14,%rdi
ab5a1: e8 ca 78 f8 ff callq 32e70 <DohPrintf>
ab5a6: 41 39 df cmp %ebx,%r15d
ab5a9: 0f 84 4a 01 00 00 je ab6f9 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1b9>
ab5af: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi
ab5b4: 89 de mov %ebx,%esi
ab5b6: 89 dd mov %ebx,%ebp
ab5b8: e8 73 5d f8 ff callq 31330 <DohGetitem>
ab5bd: 48 8b 94 24 80 00 00 mov 0x80(%rsp),%rdx
ab5c4: 00
ab5c5: 48 8d 35 d1 68 0e 00 lea 0xe68d1(%rip),%rsi # 191e9d <typeinfo name for XML+0x27a>
ab5cc: 49 89 c5 mov %rax,%r13
ab5cf: 4c 89 f7 mov %r14,%rdi
ab5d2: 31 c0 xor %eax,%eax
ab5d4: e8 97 78 f8 ff callq 32e70 <DohPrintf>
ab5d9: 48 8d 35 db 28 0e 00 lea 0xe28db(%rip),%rsi # 18debb <typeinfo name for R+0xdec>
ab5e0: 4c 89 ef mov %r13,%rdi
ab5e3: 8d 5d 01 lea 0x1(%rbp),%ebx
ab5e6: e8 b5 58 f8 ff callq 30ea0 <DohGetattr>
ab5eb: 48 85 c0 test %rax,%rax
ab5ee: 75 a0 jne ab590 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x50>
ab5f0: 48 8d 35 1a 31 0c 00 lea 0xc311a(%rip),%rsi # 16e711 <typeinfo name for GO+0xb8e>
ab5f7: 4c 89 ef mov %r13,%rdi
ab5fa: e8 a1 58 f8 ff callq 30ea0 <DohGetattr>
ab5ff: 48 8d 35 11 31 0c 00 lea 0xc3111(%rip),%rsi # 16e717 <typeinfo name for GO+0xb94>
ab606: 4c 89 ef mov %r13,%rdi
ab609: 49 89 c4 mov %rax,%r12
ab60c: e8 8f 58 f8 ff callq 30ea0 <DohGetattr>
ab611: 48 8d 3d d5 66 0e 00 lea 0xe66d5(%rip),%rdi # 191ced <typeinfo name for XML+0xca>
ab618: 48 89 44 24 18 mov %rax,0x18(%rsp)
ab61d: e8 fe aa f8 ff callq 36120 <DohNewString>
ab622: 48 8d 35 f0 5a 0e 00 lea 0xe5af0(%rip),%rsi # 191119 <typeinfo name for TCL8+0x7a>
ab629: 89 ea mov %ebp,%edx
ab62b: 48 89 c7 mov %rax,%rdi
ab62e: 48 89 44 24 10 mov %rax,0x10(%rsp)
ab633: 31 c0 xor %eax,%eax
ab635: e8 36 78 f8 ff callq 32e70 <DohPrintf>
ab63a: 48 8d 3d ac 66 0e 00 lea 0xe66ac(%rip),%rdi # 191ced <typeinfo name for XML+0xca>
ab641: e8 da aa f8 ff callq 36120 <DohNewString>
ab646: 48 8d 35 cc 5a 0e 00 lea 0xe5acc(%rip),%rsi # 191119 <typeinfo name for TCL8+0x7a>
ab64d: 48 89 c7 mov %rax,%rdi
ab650: 49 89 c5 mov %rax,%r13
ab653: 89 da mov %ebx,%edx
ab655: 31 c0 xor %eax,%eax
ab657: e8 14 78 f8 ff callq 32e70 <DohPrintf>
ab65c: 4d 85 e4 test %r12,%r12
ab65f: 0f 84 c3 00 00 00 je ab728 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1e8>
ab665: 41 83 ff 01 cmp $0x1,%r15d
ab669: 0f 84 a1 00 00 00 je ab710 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1d0>
ab66f: 48 8b 7c 24 28 mov 0x28(%rsp),%rdi
ab674: e8 87 53 f8 ff callq 30a00 <DohCopy>
ab679: 48 89 c5 mov %rax,%rbp
ab67c: 48 8b 54 24 18 mov 0x18(%rsp),%rdx
ab681: 48 8d 35 8e 30 0c 00 lea 0xc308e(%rip),%rsi # 16e716 <typeinfo name for GO+0xb93>
ab688: b9 01 00 00 00 mov $0x1,%ecx
ab68d: 48 89 ef mov %rbp,%rdi
ab690: e8 db 61 f8 ff callq 31870 <DohReplace>
ab695: 48 8d 35 74 30 0c 00 lea 0xc3074(%rip),%rsi # 16e710 <typeinfo name for GO+0xb8d>
ab69c: b9 01 00 00 00 mov $0x1,%ecx
ab6a1: 4c 89 e2 mov %r12,%rdx
ab6a4: 48 89 ef mov %rbp,%rdi
ab6a7: e8 c4 61 f8 ff callq 31870 <DohReplace>
ab6ac: 48 8d 35 33 77 0c 00 lea 0xc7733(%rip),%rsi # 172de6 <typeinfo name for V8Emitter+0x586>
ab6b3: b9 01 00 00 00 mov $0x1,%ecx
ab6b8: 4c 89 ea mov %r13,%rdx
ab6bb: 48 89 ef mov %rbp,%rdi
ab6be: e8 ad 61 f8 ff callq 31870 <DohReplace>
ab6c3: 48 8b 54 24 10 mov 0x10(%rsp),%rdx
ab6c8: 48 8d 35 1b 77 0c 00 lea 0xc771b(%rip),%rsi # 172dea <typeinfo name for V8Emitter+0x58a>
ab6cf: b9 01 00 00 00 mov $0x1,%ecx
ab6d4: 48 89 ef mov %rbp,%rdi
ab6d7: e8 94 61 f8 ff callq 31870 <DohReplace>
ab6dc: 48 8d 35 ba 67 0e 00 lea 0xe67ba(%rip),%rsi # 191e9d <typeinfo name for XML+0x27a>
ab6e3: 31 c0 xor %eax,%eax
ab6e5: 48 89 ea mov %rbp,%rdx
ab6e8: 4c 89 f7 mov %r14,%rdi
ab6eb: e8 80 77 f8 ff callq 32e70 <DohPrintf>
ab6f0: 41 39 df cmp %ebx,%r15d
ab6f3: 0f 85 b6 fe ff ff jne ab5af <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x6f>
ab6f9: 48 83 c4 48 add $0x48,%rsp
ab6fd: 31 c0 xor %eax,%eax
ab6ff: 5b pop %rbx
ab700: 5d pop %rbp
ab701: 41 5c pop %r12
ab703: 41 5d pop %r13
ab705: 41 5e pop %r14
ab707: 41 5f pop %r15
ab709: c3 retq
ab70a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
ab710: 48 8b 7c 24 30 mov 0x30(%rsp),%rdi
ab715: e8 e6 52 f8 ff callq 30a00 <DohCopy>
ab71a: 48 89 c5 mov %rax,%rbp
ab71d: e9 5a ff ff ff jmpq ab67c <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x13c>
ab722: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
ab728: 48 8b 7c 24 38 mov 0x38(%rsp),%rdi
ab72d: e8 ce 52 f8 ff callq 30a00 <DohCopy>
ab732: 48 8d 35 ad 76 0c 00 lea 0xc76ad(%rip),%rsi # 172de6 <typeinfo name for V8Emitter+0x586>
ab739: 4c 89 ea mov %r13,%rdx
ab73c: b9 01 00 00 00 mov $0x1,%ecx
ab741: 48 89 c7 mov %rax,%rdi
ab744: 49 89 c4 mov %rax,%r12
ab747: e8 24 61 f8 ff callq 31870 <DohReplace>
ab74c: 48 8b 54 24 10 mov 0x10(%rsp),%rdx
ab751: 48 8d 35 92 76 0c 00 lea 0xc7692(%rip),%rsi # 172dea <typeinfo name for V8Emitter+0x58a>
ab758: b9 01 00 00 00 mov $0x1,%ecx
ab75d: 4c 89 e7 mov %r12,%rdi
ab760: e8 0b 61 f8 ff callq 31870 <DohReplace>
ab765: e9 fb fe ff ff jmpq ab665 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x125>
ab76a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
00000000000ad1b0 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)>:
ad1b0: 41 57 push %r15
ad1b2: 4c 8d 3d c4 5b 0e 00 lea 0xe5bc4(%rip),%r15 # 192d7d <typeinfo name for XML+0x27a>
ad1b9: 41 56 push %r14
ad1bb: 49 89 fe mov %rdi,%r14
ad1be: 48 89 f7 mov %rsi,%rdi
ad1c1: 41 55 push %r13
ad1c3: 41 54 push %r12
ad1c5: 55 push %rbp
ad1c6: 31 ed xor %ebp,%ebp
ad1c8: 53 push %rbx
ad1c9: 48 89 f3 mov %rsi,%rbx
ad1cc: 48 83 ec 48 sub $0x48,%rsp
ad1d0: 48 89 34 24 mov %rsi,(%rsp)
ad1d4: 48 89 54 24 28 mov %rdx,0x28(%rsp)
ad1d9: 48 89 4c 24 30 mov %rcx,0x30(%rsp)
ad1de: 4c 89 44 24 38 mov %r8,0x38(%rsp)
ad1e3: 4c 89 4c 24 18 mov %r9,0x18(%rsp)
ad1e8: e8 23 42 f8 ff callq 31410 <DohLen>
ad1ed: 31 f6 xor %esi,%esi
ad1ef: 48 89 df mov %rbx,%rdi
ad1f2: 89 44 24 24 mov %eax,0x24(%rsp)
ad1f6: e8 c5 49 f8 ff callq 31bc0 <DohGetitem>
ad1fb: 49 89 c5 mov %rax,%r13
ad1fe: eb 37 jmp ad237 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x87>
ad200: 48 8b 54 24 18 mov 0x18(%rsp),%rdx
ad205: 4c 89 fe mov %r15,%rsi
ad208: 4c 89 f7 mov %r14,%rdi
ad20b: 31 c0 xor %eax,%eax
ad20d: e8 0e 65 f8 ff callq 33720 <DohPrintf>
ad212: 48 8b 3c 24 mov (%rsp),%rdi
ad216: 89 de mov %ebx,%esi
ad218: 89 dd mov %ebx,%ebp
ad21a: e8 a1 49 f8 ff callq 31bc0 <DohGetitem>
ad21f: 48 8b 94 24 80 00 00 mov 0x80(%rsp),%rdx
ad226: 00
ad227: 4c 89 fe mov %r15,%rsi
ad22a: 4c 89 f7 mov %r14,%rdi
ad22d: 49 89 c5 mov %rax,%r13
ad230: 31 c0 xor %eax,%eax
ad232: e8 e9 64 f8 ff callq 33720 <DohPrintf>
ad237: 48 8d 35 68 1a 0e 00 lea 0xe1a68(%rip),%rsi # 18eca6 <typeinfo name for R+0xd17>
ad23e: 4c 89 ef mov %r13,%rdi
ad241: 8d 5d 01 lea 0x1(%rbp),%ebx
ad244: e8 e7 44 f8 ff callq 31730 <DohGetattr>
ad249: 48 85 c0 test %rax,%rax
ad24c: 75 b2 jne ad200 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x50>
ad24e: 4c 89 ef mov %r13,%rdi
ad251: 48 8d 35 d9 23 0c 00 lea 0xc23d9(%rip),%rsi # 16f631 <typeinfo name for GO+0xb8e>
ad258: e8 d3 44 f8 ff callq 31730 <DohGetattr>
ad25d: 48 8d 35 d3 23 0c 00 lea 0xc23d3(%rip),%rsi # 16f637 <typeinfo name for GO+0xb94>
ad264: 4c 89 ef mov %r13,%rdi
ad267: 49 89 c4 mov %rax,%r12
ad26a: e8 c1 44 f8 ff callq 31730 <DohGetattr>
ad26f: 48 8d 3d 57 59 0e 00 lea 0xe5957(%rip),%rdi # 192bcd <typeinfo name for XML+0xca>
ad276: 48 89 44 24 10 mov %rax,0x10(%rsp)
ad27b: e8 c0 96 f8 ff callq 36940 <DohNewString>
ad280: 89 ea mov %ebp,%edx
ad282: 48 8d 35 70 4d 0e 00 lea 0xe4d70(%rip),%rsi # 191ff9 <typeinfo name for TCL8+0x7a>
ad289: 48 89 c7 mov %rax,%rdi
ad28c: 48 89 44 24 08 mov %rax,0x8(%rsp)
ad291: 31 c0 xor %eax,%eax
ad293: e8 88 64 f8 ff callq 33720 <DohPrintf>
ad298: 48 8d 3d 2e 59 0e 00 lea 0xe592e(%rip),%rdi # 192bcd <typeinfo name for XML+0xca>
ad29f: e8 9c 96 f8 ff callq 36940 <DohNewString>
ad2a4: 89 da mov %ebx,%edx
ad2a6: 48 8d 35 4c 4d 0e 00 lea 0xe4d4c(%rip),%rsi # 191ff9 <typeinfo name for TCL8+0x7a>
ad2ad: 49 89 c5 mov %rax,%r13
ad2b0: 48 89 c7 mov %rax,%rdi
ad2b3: 31 c0 xor %eax,%eax
ad2b5: e8 66 64 f8 ff callq 33720 <DohPrintf>
ad2ba: 4d 85 e4 test %r12,%r12
ad2bd: 0f 84 9f 00 00 00 je ad362 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1b2>
ad2c3: 83 7c 24 24 01 cmpl $0x1,0x24(%rsp)
ad2c8: 0f 84 82 00 00 00 je ad350 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x1a0>
ad2ce: 48 8b 7c 24 28 mov 0x28(%rsp),%rdi
ad2d3: e8 c8 3f f8 ff callq 312a0 <DohCopy>
ad2d8: 48 89 c5 mov %rax,%rbp
ad2db: 48 8b 54 24 10 mov 0x10(%rsp),%rdx
ad2e0: 48 89 ef mov %rbp,%rdi
ad2e3: b9 01 00 00 00 mov $0x1,%ecx
ad2e8: 48 8d 35 47 23 0c 00 lea 0xc2347(%rip),%rsi # 16f636 <typeinfo name for GO+0xb93>
ad2ef: e8 1c 4e f8 ff callq 32110 <DohReplace>
ad2f4: 4c 89 e2 mov %r12,%rdx
ad2f7: 48 89 ef mov %rbp,%rdi
ad2fa: b9 01 00 00 00 mov $0x1,%ecx
ad2ff: 48 8d 35 2a 23 0c 00 lea 0xc232a(%rip),%rsi # 16f630 <typeinfo name for GO+0xb8d>
ad306: e8 05 4e f8 ff callq 32110 <DohReplace>
ad30b: 4c 89 ea mov %r13,%rdx
ad30e: 48 89 ef mov %rbp,%rdi
ad311: b9 01 00 00 00 mov $0x1,%ecx
ad316: 48 8d 35 e9 69 0c 00 lea 0xc69e9(%rip),%rsi # 173d06 <typeinfo name for V8Emitter+0x586>
ad31d: e8 ee 4d f8 ff callq 32110 <DohReplace>
ad322: 48 8b 54 24 08 mov 0x8(%rsp),%rdx
ad327: 48 89 ef mov %rbp,%rdi
ad32a: b9 01 00 00 00 mov $0x1,%ecx
ad32f: 48 8d 35 d4 69 0c 00 lea 0xc69d4(%rip),%rsi # 173d0a <typeinfo name for V8Emitter+0x58a>
ad336: e8 d5 4d f8 ff callq 32110 <DohReplace>
ad33b: 48 89 ea mov %rbp,%rdx
ad33e: 4c 89 fe mov %r15,%rsi
ad341: 4c 89 f7 mov %r14,%rdi
ad344: 31 c0 xor %eax,%eax
ad346: e8 d5 63 f8 ff callq 33720 <DohPrintf>
ad34b: e9 c2 fe ff ff jmpq ad212 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x62>
ad350: 48 8b 7c 24 30 mov 0x30(%rsp),%rdi
ad355: e8 46 3f f8 ff callq 312a0 <DohCopy>
ad35a: 48 89 c5 mov %rax,%rbp
ad35d: e9 79 ff ff ff jmpq ad2db <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x12b>
ad362: 48 8b 7c 24 38 mov 0x38(%rsp),%rdi
ad367: e8 34 3f f8 ff callq 312a0 <DohCopy>
ad36c: 4c 89 ea mov %r13,%rdx
ad36f: b9 01 00 00 00 mov $0x1,%ecx
ad374: 48 8d 35 8b 69 0c 00 lea 0xc698b(%rip),%rsi # 173d06 <typeinfo name for V8Emitter+0x586>
ad37b: 48 89 c7 mov %rax,%rdi
ad37e: 49 89 c4 mov %rax,%r12
ad381: e8 8a 4d f8 ff callq 32110 <DohReplace>
ad386: 48 8b 54 24 08 mov 0x8(%rsp),%rdx
ad38b: b9 01 00 00 00 mov $0x1,%ecx
ad390: 4c 89 e7 mov %r12,%rdi
ad393: 48 8d 35 70 69 0c 00 lea 0xc6970(%rip),%rsi # 173d0a <typeinfo name for V8Emitter+0x58a>
ad39a: e8 71 4d f8 ff callq 32110 <DohReplace>
ad39f: e9 1f ff ff ff jmpq ad2c3 <format_paramlist(void*, void*, void*, void*, void*, void*, void*)+0x113>
ad3a4: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
ad3ab: 00 00 00 00
ad3af: 90 nop
Starting program: /home/user/.local/bin/swig -v -matlab -DSWIG_TYPE_TABLE=casadi -fvirtual -DWITH_DEPRECATED_FEATURES -outdir swig/matlab -c++ -I.. -I. -o swig/casadiMATLAB_wrap.cxx ../swig/casadi.i
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Language subdirectory: matlab
Search paths:
./
../
./
./swig_lib/matlab/
/home/user/.local/share/swig/3.0.11/matlab/
./swig_lib/
/home/user/.local/share/swig/3.0.11/
Preprocessing...
Starting language-specific parse...
Processing types...
C++ analysis...
Processing nested classes...
Generating wrappers...
swig: DOH/list.c:167: List_get: Assertion `!((n < 0) || (n >= l->nitems))' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff7a402e5 in raise () from /lib/libc.so.6
(gdb)
(gdb) bt
#0 0x00007ffff7a402e5 in raise () from /lib/libc.so.6
#1 0x00007ffff7a29853 in abort () from /lib/libc.so.6
#2 0x00007ffff7a29727 in __assert_fail_base.cold () from /lib/libc.so.6
#3 0x00007ffff7a38936 in __assert_fail () from /lib/libc.so.6
#4 0x0000555555588c74 in List_get (lo=<optimized out>, n=<optimized out>) at DOH/list.c:161
#5 List_get (lo=<optimized out>, n=<optimized out>) at DOH/list.c:161
#6 0x00005555555fee3d in format_paramlist (f=f@entry=0x55555c9d1580, paramlist=0x55555c9d14e0,
normal_entry=normal_entry@entry=0x555555bc8370, only_entry=only_entry@entry=0x555555bc80f0, no_name=no_name@entry=0x0,
self=self@entry=0x555555bc8430, separator=0x555555bc81b0) at Modules/lang.cxx:3961
#7 0x00005555555ff1e9 in Language::Swig_prototype (this=<optimized out>, n=0x555555bc7fd0, f=<optimized out>, style=<optimized out>)
at Modules/lang.cxx:4051
#8 0x00005555555ff3ff in Language::Swig_document_function (this=0x55555571ab80, n=0x555555bc7fd0) at Modules/lang.cxx:4154
#9 0x000055555560afcf in MATLAB::process_autodoc (this=0x55555571ab80, n=0x555555bc7fd0) at Modules/matlab.cxx:657
#10 0x000055555560d4d9 in MATLAB::autodoc_to_m (this=this@entry=0x55555571ab80, f=0x55555c9d0d60, n=n@entry=0x555555bc7fd0)
at Modules/matlab.cxx:3001
#11 0x00005555556106de in MATLAB::autodoc_to_m (n=0x555555bc7fd0, f=<optimized out>, this=0x55555571ab80) at Modules/matlab.cxx:2999
#12 MATLAB::classHandler (this=0x55555571ab80, n=0x555555bc7fd0) at Modules/matlab.cxx:2173
#13 0x00005555555fbc8a in Language::classDeclaration (this=0x55555571ab80, n=0x555555bc7fd0) at Modules/lang.cxx:2498
#14 0x00005555555f4cc1 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc7fd0) at Modules/lang.cxx:127
#15 0x00005555555f7556 in Language::emit_one (n=0x555555bc7fd0, this=0x55555571ab80) at Modules/lang.cxx:399
#16 Language::emit_one (this=0x55555571ab80, n=0x555555bc7fd0) at Modules/lang.cxx:376
#17 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#18 0x00005555555f7481 in Language::namespaceDeclaration (n=0x555555bc43f0, this=0x55555571ab80) at Modules/lang.cxx:2937
#19 Language::namespaceDeclaration (this=0x55555571ab80, n=0x555555bc43f0) at Modules/lang.cxx:2932
#20 0x00005555555f4dbf in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc43f0) at Modules/lang.cxx:139
#21 0x00005555555f7556 in Language::emit_one (n=0x555555bc43f0, this=0x55555571ab80) at Modules/lang.cxx:399
#22 Language::emit_one (this=0x55555571ab80, n=0x555555bc43f0) at Modules/lang.cxx:376
#23 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#24 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#25 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc3db0) at Modules/lang.cxx:165
#26 0x00005555555f7556 in Language::emit_one (n=0x555555bc3db0, this=0x55555571ab80) at Modules/lang.cxx:399
#27 Language::emit_one (this=0x55555571ab80, n=0x555555bc3db0) at Modules/lang.cxx:376
#28 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#29 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#30 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc3cd0) at Modules/lang.cxx:165
#31 0x00005555555f7556 in Language::emit_one (n=0x555555bc3cd0, this=0x55555571ab80) at Modules/lang.cxx:399
#32 Language::emit_one (this=0x55555571ab80, n=0x555555bc3cd0) at Modules/lang.cxx:376
#33 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#34 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#35 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc3c50) at Modules/lang.cxx:165
#36 0x00005555555f7556 in Language::emit_one (n=0x555555bc3c50, this=0x55555571ab80) at Modules/lang.cxx:399
#37 Language::emit_one (this=0x55555571ab80, n=0x555555bc3c50) at Modules/lang.cxx:376
#38 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#39 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#40 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc3bd0) at Modules/lang.cxx:165
#41 0x00005555555f7556 in Language::emit_one (n=0x555555bc3bd0, this=0x55555571ab80) at Modules/lang.cxx:399
#42 Language::emit_one (this=0x55555571ab80, n=0x555555bc3bd0) at Modules/lang.cxx:376
#43 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#44 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#45 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bc39d0) at Modules/lang.cxx:165
#46 0x00005555555f7556 in Language::emit_one (n=0x555555bc39d0, this=0x55555571ab80) at Modules/lang.cxx:399
#47 Language::emit_one (this=0x55555571ab80, n=0x555555bc39d0) at Modules/lang.cxx:376
#48 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#49 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#50 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bae1b0) at Modules/lang.cxx:165
#51 0x00005555555f7556 in Language::emit_one (n=0x555555bae1b0, this=0x55555571ab80) at Modules/lang.cxx:399
#52 Language::emit_one (this=0x55555571ab80, n=0x555555bae1b0) at Modules/lang.cxx:376
#53 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#54 0x00005555555f495a in Language::includeDirective (this=<optimized out>, n=<optimized out>) at Modules/lang.cxx:649
#55 0x00005555555f4f37 in Dispatcher::emit_one (this=this@entry=0x55555571ab80, n=n@entry=0x555555bab9d0) at Modules/lang.cxx:165
#56 0x00005555555f7556 in Language::emit_one (n=0x555555bab9d0, this=0x55555571ab80) at Modules/lang.cxx:399
#57 Language::emit_one (this=0x55555571ab80, n=0x555555bab9d0) at Modules/lang.cxx:376
#58 0x00005555555f510c in Dispatcher::emit_children (this=0x55555571ab80, n=<optimized out>) at Modules/lang.cxx:211
#59 0x000055555560e477 in MATLAB::top (this=0x55555571ab80, n=0x7ffff795df30) at Modules/matlab.cxx:427
#60 0x0000555555607dfe in SWIG_main (argc=<optimized out>, argv=<optimized out>, l=<optimized out>) at Modules/main.cxx:1303
#61 0x000055555556e156 in main (margc=<optimized out>, margv=<optimized out>) at Modules/swigmain.cxx:207
# https://github.com/jaeandersson/swig/blob/matlab-customdoc/Source/Modules/lang.cxx#L3955
int format_paramlist(String* f, List* paramlist, String* normal_entry, String* only_entry, String* no_name, String* self, String* separator) {
int n = Len(paramlist);
int i;
bool print_sep = false;
for (i=0;i<n;++i) {
Hash *node = Getitem(paramlist, i);
if (i>0) Printf(f, "%s", separator);
if (Getattr(node, "self")) {
Printf(f, "%s", self);
continue;
}
String* name = Getattr(node, "name");
String* type = Getattr(node, "type");
String* s_i = NewString("");
Printf(s_i, "%d", i);
String* s_ip = NewString("");
Printf(s_ip, "%d", i+1);
if (! name) {
name = Copy(no_name);
Replaceall(name,"$ip",s_ip);
Replaceall(name,"$i",s_i);
}
String* t_entry = n==1? Copy(only_entry) : Copy(normal_entry);
Replaceall(t_entry, "$type", type);
Replaceall(t_entry, "$name", name);
Replaceall(t_entry, "$ip", s_ip);
Replaceall(t_entry, "$i", s_i);
Printf(f, "%s", t_entry);
}
}
# https://github.com/jaeandersson/swig/blob/matlab/Source/DOH/list.c#L161
static DOH *List_get(DOH *lo, int n) {
List *l = (List *) ObjData(lo);
if (n == DOH_END)
n = l->nitems - 1;
if (n == DOH_BEGIN)
n = 0;
assert(!((n < 0) || (n >= l->nitems)));
return l->items[n];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment