Skip to content

Instantly share code, notes, and snippets.

@brainpower
Last active October 20, 2020 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainpower/d85cc63d6820dd2fb65d12ca52f5f957 to your computer and use it in GitHub Desktop.
Save brainpower/d85cc63d6820dd2fb65d12ca52f5f957 to your computer and use it in GitHub Desktop.
PHP 8.0 jit gdb session stepping through dasm_setup() PHP BUG #80243
./configure \
--prefix=${instdir} \
--with-libdir=lib/x86_64-linux-gnu \
--with-config-file-path=${instdir}/etc \
--with-config-file-scan-dir=${instdir}/etc/conf.d \
--localstatedir=/var \
--with-layout=GNU \
\
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-fpm \
--enable-ftp \
--enable-gd \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
\
--with-bz2 \
--with-curl \
--with-freetype \
--with-gettext \
--with-gmp \
--with-imap-ssl \
--with-imap \
--with-jpeg \
--with-kerberos \
--with-ldap \
--with-mhash \
--with-mysql-sock=/run/mysqld/mysqld.sock \
--with-mysqli=mysqlnd \
--with-openssl \
--with-password-argon2 \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql \
--with-pdo-sqlite \
--with-pgsql \
--with-readline \
--with-sodium \
--with-sqlite3 \
--with-tidy \
--with-webp \
--with-xsl \
--with-zip \
--with-zlib \
\
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-fpm-systemd \
|| return 1
Breakpoint 1, zend_jit_make_stubs () at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit.c:3998
3998 dasm_setup(&dasm_state, dasm_actions);
(gdb) step
dasm_setup (Dst=Dst@entry=0x7fffffffcc00, actionlist=actionlist@entry=0x7ffff35c9d60 <dasm_actions>) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:143
143 dasm_State *D = Dst_REF;
(gdb) print D
$1 = <optimized out>
(gdb) print dasm_actions
$2 = "M\213\276\347\377\370\n\377M\211\276\347\377\306\004%\353\000\377H\270\353\353\306\000\000\377\200<%\353\000\377H\270\353\353\200\070\000\377\017\204\362\367\377\374\350\361\377H\307\300\353\377H\270\353\353\377\374\377\320\377\370\001\377L\211\374\367\377L\213\064%\353\377H\270\353\353L\213\060\377H\203\304\020\377A\374\377'\377H\213\207\347\374\377 \377H\203\304\030\377L\213t$\030L\213|$ H\203\304(H\307\300\001\000\000\000\303\377\370\v\377\374\351\361\377\374\377\340\377L\213t$\030L\213|$ H\203\304(\205\300\017\214\362\367H\307\300\001\000\000\000\370\001\303\377L\211\374\367L\213t$\030L\213|$ H\203\304(\377\370\f\377H\213\004%"...
(gdb) step
145 D->actionlist = (dasm_ActList)actionlist;
(gdb) step
146 D->status = DASM_S_OK;
(gdb) print D->actionlist
$3 = (dasm_ActList) 0x7ffff35c9d60 <dasm_actions> "M\213\276\347\377\370\n\377M\211\276\347\377\306\004", <incomplete sequence \353>
(gdb) step
147 D->section = &D->sections[0];
(gdb) step
148 memset((void *)D->lglabels, 0, D->lgsize);
(gdb) print D->section
$4 = (dasm_Section *) 0x7ffff3608150
(gdb) step
__memset_avx2_unaligned () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:109
109 ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S: Datei oder Verzeichnis nicht gefunden.
(gdb) step
115 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb) step
116 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb) step
117 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb) step
118 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb) step
__memset_avx2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:188
188 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb) step
189 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
199 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
200 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
201 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
202 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
203 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
204 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
205 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
206 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
207 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
208 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
209 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
210 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
211 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
212 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
214 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
215 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
216 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
217 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
218 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
219 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
220 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
221 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
__memset_avx2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:222
222 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
dasm_setup (Dst=Dst@entry=0x7fffffffcc00, actionlist=actionlist@entry=0x7ffff35c9d60 <dasm_actions>) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:149
149 if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
(gdb) print D->section
$5 = (dasm_Section *) 0x0
(gdb) print D->actionlist
$6 = (dasm_ActList) 0x0
Breakpoint 1, zend_jit_make_stubs () at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit.c:3998
3998 dasm_setup(&dasm_state, dasm_actions);
(gdb) step
dasm_setup (Dst=Dst@entry=0x7fffffffcc00, actionlist=actionlist@entry=0x7ffff35c9d60 <dasm_actions>) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:143
143 dasm_State *D = Dst_REF;
(gdb) step
145 D->actionlist = (dasm_ActList)actionlist;
(gdb) step
146 D->status = DASM_S_OK;
(gdb) step
147 D->section = &D->sections[0];
(gdb) step
148 memset((void *)D->lglabels, 0, D->lgsize);
(gdb) print D->section
$1 = (dasm_Section *) 0x7ffff3608150
(gdb) print D->actionlist
$2 = (dasm_ActList) 0x7ffff35c9d60 <dasm_actions> "M\213\276\347\377\370\n\377M\211\276\347\377\306\004", <incomplete sequence \353>
(gdb) print D->lglabels
$3 = (int *) 0x7ffff3608100
(gdb) print D->lgsize
$4 = 256
(gdb) print D
$5 = (dasm_State *) 0x7ffff3608100
(gdb) step
step stepi stepping
(gdb) step
__memset_avx2_unaligned () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:109
109 ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S: Datei oder Verzeichnis nicht gefunden.
(gdb)
115 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
116 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
117 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
118 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
__memset_avx2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:188
188 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
189 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
199 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
200 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
201 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
202 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
203 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
204 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
205 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
206 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
207 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
208 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
209 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
210 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
211 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
212 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
214 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
215 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
216 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
217 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
218 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
219 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
220 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
221 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
__memset_avx2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:222
222 in ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(gdb)
dasm_setup (Dst=Dst@entry=0x7fffffffcc00, actionlist=actionlist@entry=0x7ffff35c9d60 <dasm_actions>) at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:149
149 if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
(gdb) print D->actionlist
$6 = (dasm_ActList) 0x0
(gdb) print D->section
$7 = (dasm_Section *) 0x0
(gdb)
Breakpoint 1, dasm_setupglobal (Dst=Dst@entry=0x7fffffffcc00, gl=gl@entry=0x7ffff35f6fe0 <dasm_labels>, maxgl=maxgl@entry=36)
at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/dynasm/dasm_x86.h:126
126 dasm_State *D = Dst_REF;
(gdb) step
127 D->globals = gl - 10; /* Negative bias to compensate for locals. */
(gdb) print D
$1 = (dasm_State *) 0x7ffff3608100
(gdb) print D->lglabels
$2 = (int *) 0x0
(gdb) print D->lgsize
$3 = 0
(gdb) step
128 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
(gdb) print D->lglabels
$4 = (int *) 0x0
(gdb) step
_erealloc (ptr=0x0, size=256) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:2557
2557 if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) {
(gdb) step
2561 return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb) step
zend_mm_realloc_heap (copy_size=256, use_copy_size=false, size=<optimized out>, ptr=0x0, heap=0x7ffff3600040) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:2561
2561 return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb) step
1525 if (EXPECTED(ptr == NULL)) {
(gdb) step
_erealloc (ptr=0x0, size=256) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1526
1526 return _zend_mm_alloc(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb) step
_zend_mm_alloc (heap=0x7ffff3600040, size=256) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:2328
2328 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb)
zend_mm_alloc_heap (size=256, heap=0x7ffff3600040) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:2328
2328 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb)
1326 ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb)
zend_mm_small_size_to_bin (size=256) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1326
1326 ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb)
1174 t1 = size - 1;
(gdb)
1175 t2 = zend_mm_small_size_to_bit(t1) - 3;
(gdb)
zend_mm_small_size_to_bit (size=255) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1175
1175 t2 = zend_mm_small_size_to_bit(t1) - 3;
(gdb)
zend_mm_small_size_to_bin (size=<optimized out>) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1179
1179 return (int)(t1 + t2);
(gdb)
zend_mm_alloc_heap (size=<optimized out>, heap=0x7ffff3600040) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1326
1326 ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
(gdb)
zend_mm_alloc_small (bin_num=15, heap=0x7ffff3600040) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1246
1246 size_t size = heap->size + bin_data_size[bin_num];
(gdb)
1247 size_t peak = MAX(heap->peak, size);
(gdb)
1248 heap->size = size;
(gdb)
1249 heap->peak = peak;
(gdb)
1253 if (EXPECTED(heap->free_slot[bin_num] != NULL)) {
(gdb)
1255 heap->free_slot[bin_num] = p->next_free_slot;
(gdb)
_zend_mm_alloc (heap=0x7ffff3600040, size=<optimized out>) at /root/shmbuild/src/php-8.0.0RC2/Zend/zend_alloc.c:1256
1256 return p;
(gdb)
zend_jit_make_stubs () at /root/shmbuild/src/php-8.0.0RC2/ext/opcache/jit/zend_jit.c:3997
3997 for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) {
(gdb) print D->lglabels
No symbol "D" in current context.
(gdb) print dasm_state->lglabels
$5 = (int *) 0x7ffff3608100
(gdb) print dasm_state
$6 = (dasm_State *) 0x7ffff3608100
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment