Issue #17794 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED to 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: DONE

ruby_3_0 8e4ed4ed00e8346029953c14dd414a996e37a437 merged revision(s) d795f494a89e0d9498dfedc54b8a98acc2bc4d7b.

----------------------------------------
Bug #17794: addr2line.c can free(3) an invalid pointer without zlib
https://bugs.ruby-lang.org/issues/17794#change-93600

* Author: xtkoba (Tee KOBAYASHI)
* Status: Closed
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: DONE
----------------------------------------
When built without zlib (`./configure ac_cv_lib_z_uncompress=no`), `ruby` aborts immediately after C level backtrace information is printed.

```
$ ruby -e 'Process.kill :SEGV, $$'
-e:1: [BUG] Segmentation fault at 0x000003e8000052ac
(...snip...)
-- C level backtrace information -------------------------------------------
/var/tmp/build.debug/x86_64-linux-gcc/lib/libruby.so.3.1(0x7f8abe871147) [0x7f8abe871147]
[0x7f8abe871179]
(...snip...)
[0x7f8abe65b5fa]
/var/tmp/build.debug/x86_64-linux-gcc/bin/ruby(main+0x7f) [0x55d1e2fd1234] ../main.c:47
free(): invalid pointer
Aborted
```

This happens because at [addr2line.c:2344](https://github.com/ruby/ruby/blob/799ea1d1540aca03542ee31647052343507a4b41/addr2line.c#L2344) `s->ptr` can be an invalid pointer.

A patch is attached for a workaround that makes `s->ptr` either valid or `NULL`.

---Files--------------------------------
ruby-addr2line-free-invalid-pointer.patch (490 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>