summaryrefslogtreecommitdiff
path: root/ext
AgeCommit message (Collapse)Author
4 days[ruby/json] Update method docs for JSON.load and JSON.unsafe_load to show ↵Robin Miller
the correct use of proc argument. https://github.com/ruby/json/commit/92654cd99b
4 days[ruby/json] Added testing for JSON.unsafe_load. Fixes NoMethodErrorRobin Miller
when passing proc to JSON.unsafe_load, matching the changes made in https://github.com/ruby/json/commit/73d2137fd3ad. https://github.com/ruby/json/commit/77292cbc9b
4 days[ruby/json] Fix a -Wreturn-type warningJean Boussier
Fix: https://github.com/ruby/json/pull/843 https://github.com/ruby/json/commit/d3f7f0452b Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>
5 daysext/-test-/tracepoint/gc_hook.c: Fix GC safety issueAlan Wu
TestTracepointObj#test_teardown_with_active_GC_end_hook was failing on some platforms due to a Proc that is not marked being passed around. Neither rb_tracepoint_new() nor rb_postponed_job_preregister() promise to mark their callback `void *data`. https://rubyci.s3.amazonaws.com/osx1300arm/ruby-master/log/20250902T154504Z.fail.html.gz Add a GC.start to make the test a better detector for this safety issue and fix it by getting the Proc from an ivar on the rooted module.
11 daysReplace ROBJECT_EMBED by ROBJECT_HEAPJean Boussier
The embed layout is way more common than the heap one, especially since WVA. I think it makes for more readable code to inverse the flag.
12 daysJSON.generate: warn or raise on duplicated keyJean Boussier
Because both strings and symbols keys are serialized the same, it always has been possible to generate documents with duplicated keys: ```ruby >> puts JSON.generate({ foo: 1, "foo" => 2 }) {"foo":1,"foo":2} ``` This is pretty much always a mistake and can cause various issues because it's not guaranteed how various JSON parsers will handle this. Until now I didn't think it was possible to catch such case without tanking performance, hence why I only made the parser more strict. But I finally found a way to check for duplicated keys cheaply enough.
12 daysFix `JSON::Coder` to cast non-string keys.Jean Boussier
12 daysFix `JSON.generate` `strict: true` mode to also restrict hash keysJean Boussier
12 days[ruby/json] Improve generation options documentationJean Boussier
https://github.com/ruby/json/commit/3187c88c06
12 days[ruby/json] Remove reference to fast_generateJean Boussier
https://github.com/ruby/json/commit/19bcfdd8d8
12 days[ruby/json] Optimize `fbuffer_append_str_repeat`Jean Boussier
Helps with pretty printting performance: ``` == Encoding activitypub.json (52595 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 1.746k i/100ms Calculating ------------------------------------- after 17.481k (± 1.0%) i/s (57.20 μs/i) - 89.046k in 5.094341s Comparison: before: 16038.4 i/s after: 17481.1 i/s - 1.09x faster == Encoding citm_catalog.json (500298 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 60.000 i/100ms Calculating ------------------------------------- after 608.157 (± 2.3%) i/s (1.64 ms/i) - 3.060k in 5.034238s Comparison: before: 525.3 i/s after: 608.2 i/s - 1.16x faster == Encoding twitter.json (466906 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 160.000 i/100ms Calculating ------------------------------------- after 1.606k (± 0.5%) i/s (622.70 μs/i) - 8.160k in 5.081406s Comparison: before: 1410.3 i/s after: 1605.9 i/s - 1.14x faster ``` https://github.com/ruby/json/commit/f0dda861c5
12 days[ruby/json] parser.c: Remove useless dereferenceJean Boussier
https://github.com/ruby/json/commit/2d63648c0a
12 days[ruby/json] Extract `fbuffer_append_str_repeat` functionJean Boussier
https://github.com/ruby/json/commit/12656777dc
13 daysCast down to socklen_t explicitly in rb_getnameinfoJean Boussier
Similar to 19f3793a4bd6974cd66cc058fc6d2ae733337745 Fixes: ``` ../../../ext/socket/raddrinfo.c:755:60: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'socklen_t' (aka 'unsigned int') [-Wshorten-64-to-32] 755 | return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); | ~~~~~~~~~~~ ^~~~~~~ ../../../ext/socket/raddrinfo.c:755:45: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'socklen_t' (aka 'unsigned int') [-Wshorten-64-to-32] 755 | return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); | ~~~~~~~~~~~ ^~~~~~~ ```
14 daysCast down to `socklen_t` explicitlyNobuyoshi Nakada
2025-08-20Avoid spawning thread for trivial getnameinfo callsJohn Hawthorn
When calling getnameinfo we spawn a thread because it may do a slow, blocking reverse-DNS lookup. Spawning a thread is relatively fast (~20µs on my Linux machine) but still an order of magnitude slower than when getnameinfo is simply translating to a numeric IP or port, which, at least in my tests on Linux, doesn't even make a syscall. This commit adds a fast path for when reverse DNS isn't required: either host isn't being fetched or NI_NUMERICHOST is set AND either the service name isn't required or NI_NUMERICSERV is set. The service name should only need to read /etc/services, which should be fast-ish, but is still I/O so I kept the existing behaviour (it could be on a network fs I guess). I tested with: s = TCPSocket.open("www.ruby-lang.org", 80) 500_000.times { Socket.unpack_sockaddr_in(s.getpeername) } Before: 12.935s After: 0.338s
2025-08-19[ruby/openssl] Add missing write barriers in X509John Hawthorn
Both the X509 store and X509 store context were missing write barriers. To the callback object being stored in the ex data. These values were also being stored as an IV, however in Ruby HEAD we're now storing the IVs for T_DATA (generic IVs) on a separate object. So we need an additional write barrier. I believe this was always necessary, because we could have done incremental marking ahead of compaction, and without the write barrier the mark function could have been run before @verify_callback was assigned. This was detected by wbcheck https://github.com/ruby/openssl/commit/1fda3a99ef
2025-08-18Fix typosDouglas Eichelberger
2025-08-18[ruby/json] Append newline at EOF [ci skip]Nobuyoshi Nakada
https://github.com/ruby/json/commit/72e231f929
2025-08-18[ruby/json] Remove trailing spaces [ci skip]Nobuyoshi Nakada
https://github.com/ruby/json/commit/2d2e0d403d
2025-08-13[ruby/resolv] win32/resolv: add headers to GetNetworkParams check.Jeremy Drake
On 32-bit Cygwin at least, it was failing to find that function, presumably due to it being stdcall. Signed-off-by: Jeremy Drake <github@jdrake.com> https://github.com/ruby/resolv/commit/bceafef74b
2025-08-09[ruby/stringio] Adjust indent [ci skip]Nobuyoshi Nakada
https://github.com/ruby/stringio/commit/ac6292c17f
2025-08-09[ruby/stringio] Fix SEGV at read/pread on null StringIONobuyoshi Nakada
https://github.com/ruby/stringio/commit/113dd5a55e
2025-08-09[ruby/stringio] fix: prevent segfault in StringIO#seek with SEEK_ENDkoh-sh
on null device (https://github.com/ruby/stringio/pull/137) Fixes segmentation fault when calling `seek` with `SEEK_END` on null device StringIO created by `StringIO.new(nil)`. ```bash ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)" ``` I tested with below versions. ```bash [koh@Kohs-MacBook-Pro] ~ % ruby -v;gem info stringio;sw_vers ruby 3.4.5 (2025-07-16 revision https://github.com/ruby/stringio/commit/20cda200d3) +PRISM [arm64-darwin24] *** LOCAL GEMS *** stringio (3.1.2) Authors: Nobu Nakada, Charles Oliver Nutter Homepage: https://github.com/ruby/stringio Licenses: Ruby, BSD-2-Clause Installed at (default): /Users/koh/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0 Pseudo IO on String ProductName: macOS ProductVersion: 15.5 BuildVersion: 24F74 [koh@Kohs-MacBook-Pro] ~ % ``` https://github.com/ruby/stringio/commit/9399747bf9
2025-08-06Ensure ObjectSpace.dump won't call cc_cme on invalidated CCJohn Hawthorn
2025-08-04Only define `String.json_create` & al when `json/add` is requiredJean Boussier
All the `json/add` related methods for string were always defined unconditionally from the generators. It's preferable to only define them if `json/add` is actually used.
2025-08-01[ruby/openssl] pkcs7: make PKCS7#add_recipient actually usefulKazuki Yamaguchi
Add a simple test case that creates an enveloped-data structure without using the shorthand method, and fix two issues preventing this from working correctly. First, OpenSSL::PKey::PKCS7#add_recipient currently inserts an incomplete PKCS7_RECIP_INFO object into the PKCS7 object. When duplicating an unfinalized PKCS7_RECIP_INFO, the internal X509 reference must also be copied, as it is later used by #add_data to fill the rest. A similar issue with #add_signer was fixed in commit https://github.com/ruby/openssl/commit/20ca7a27a86e (pkcs7: keep private key when duplicating PKCS7_SIGNER_INFO, 2021-03-24). Second, #add_data calls PKCS7_dataFinal(), which for enveloped-data appears to require the BIO to be flushed explicitly with BIO_flush(). Without this, the last block of the encrypted data would be missing. https://github.com/ruby/openssl/commit/9595ecf643
2025-08-01[ruby/openssl] pkcs7: refactor error handling in PKCS7#add_dataKazuki Yamaguchi
Raise an exception right after an OpenSSL function returns an error. Checking ERR_peek_error() is not reliable way to see if an error has occurred or not, as OpenSSL functions do not always populate the error queue. https://github.com/ruby/openssl/commit/cc3f1af73e
2025-08-01[ruby/openssl] pkcs7: fix error queue leak in OpenSSL::PKCS7#detachedKazuki Yamaguchi
Only call PKCS7_get_detached() if the PKCS7 object is a signed-data. This is only useful for the content type, and leaves an error entry if called on a PKCS7 object with a different content type. https://github.com/ruby/openssl/commit/8997f6d5e6
2025-07-31Get rid of RSHAPE_PARENT in favor of RSHAPE_DIRECT_CHILD_PJean Boussier
`RSHAPE_PARENT` is error prone because it returns a raw untagged shape_id. To check if a shape is a direct parent of another, tags should be discarded. So providing a comparison function is better than exposing untagged ids.
2025-07-31[ruby/openssl] pkcs7: only set error_string in the error pathKazuki Yamaguchi
Set the error_string attribute to nil if PKCS7_verify() succeeds, since the error queue should be empty in that case. With AWS-LC, OpenSSL::PKCS#verify currently sets error_string to "invalid library (0)" when the verification succeeds, whereas with OpenSSL and LibreSSL, it becomes nil. ERR_reason_error_string() appears to behave differently when an invalid error code is passed. The branch to raise OpenSSL::PKCS7::PKCS7Error is removed because it does not appear to be reachable. https://github.com/ruby/openssl/commit/c11c6631fa
2025-07-31Reapply "[ruby/openssl] x509: disallow ↵Kazuki Yamaguchi
ossl_x509{,attr,crl,ext,revoked,name}*_new(NULL)" This reverts commit ec01cd9bbbaf3e6f324e0a6769b8383857d2bc07. This should no longer break the tests, now that the following changes have been applied: - RubyGems change: 32977f3869ba1c44950f484ddbf3a12889c0b20b - ruby/openssl change: e8261963c79ba61453f7f0dae281c33a1287b351
2025-07-31[ruby/openssl] x509store: fix StoreContext#current_certKazuki Yamaguchi
Commit https://github.com/ruby/openssl/commit/ef277083ba76 overlooked a caller of ossl_x509_new() with NULL argument. OpenSSL::X509::StoreContext#current_cert may not have a certificate to return if StoreContext#verify has not been called. https://github.com/ruby/openssl/commit/4149b43890
2025-07-29Get rid of imemo_astJean Boussier
It has been marked as obsolete for a while and I see no reason to keep it.
2025-07-29Fix ext/-test-/namespace/yay{1,2} for mswinNobuyoshi Nakada
Visual C: ``` compiling ../../../../../src/ext/-test-/namespace/yay1/yay1.c yay1.c ../../../../../src/ext/-test-/namespace/yay1/yay1.c(4): warning C4273: 'yay_value': inconsistent dll linkage C:\a\ruby\ruby\src\ext\-test-\namespace\yay1\yay1.h(4): note: see previous definition of 'yay_value' linking shared-object -test-/namespace/yay1.so Creating library yay1-arm64-mswin64_140.lib and object yay1-arm64-mswin64_140.exp yay1-arm64-mswin64_140.exp : warning LNK4070: /OUT:yay1.dll directive in .EXP differs from output filename '..\..\..\..\.ext\arm64-mswin64_140\-test-\namespace\yay1.so'; ignoring directive compiling ../../../../../src/ext/-test-/namespace/yay2/yay2.c yay2.c ../../../../../src/ext/-test-/namespace/yay2/yay2.c(4): warning C4273: 'yay_value': inconsistent dll linkage C:\a\ruby\ruby\src\ext\-test-\namespace\yay2\yay2.h(4): note: see previous definition of 'yay_value' linking shared-object -test-/namespace/yay2.so Creating library yay2-arm64-mswin64_140.lib and object yay2-arm64-mswin64_140.exp yay2-arm64-mswin64_140.exp : warning LNK4070: /OUT:yay2.dll directive in .EXP differs from output filename '..\..\..\..\.ext\arm64-mswin64_140\-test-\namespace\yay2.so'; ignoring directive ``` From MinGW gcc: ``` ../../../../../src/ext/-test-/namespace/yay1/yay1.c:4:1: warning: 'yay_value' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] 4 | yay_value(void) | ^~~~~~~~~ ../../../../../src/ext/-test-/namespace/yay2/yay2.c:4:1: warning: 'yay_value' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] 4 | yay_value(void) | ^~~~~~~~~ ```
2025-07-29[ruby/json] Release 2.13.2Jean Boussier
https://github.com/ruby/json/commit/9e3efbfa22
2025-07-28[ruby/json] Improve deprecation warning location detectionJean Boussier
https://github.com/ruby/json/commit/132049bde2
2025-07-28[ruby/json] Fix duplicated key warning locationJean Boussier
Followup: https://github.com/ruby/json/pull/818 Now the warning should point at the `JSON.parse` caller, and not inside the json gem itself. https://github.com/ruby/json/commit/cd51557387
2025-07-28[ruby/json] Improve duplicate key warning and errors to include the key nameJean Boussier
Followup: https://github.com/ruby/json/pull/818 https://github.com/ruby/json/commit/e3de4cc59c
2025-07-27Revert "[ruby/openssl] x509: disallow ↵Kazuki Yamaguchi
ossl_x509{,attr,crl,ext,revoked,name}*_new(NULL)" This reverts commit 4e8bbb07dd4936b97a6b39d54a6977a107518e1f. It broke RubyGems tests: https://rubyci.s3.amazonaws.com/debian/ruby-master/log/20250727T123003Z.fail.html.gz OpenSSL::X509::StoreContext#current_cert incorrectly calls ossl_x509_new() with NULL to create a bogus Certificate object, and a test case in RubyGems relies on it. This will be reapplied when both are fixed.
2025-07-27[ruby/openssl] pkey: rename ossl_pkey_new() to ossl_pkey_wrap()Kazuki Yamaguchi
Among functions named ossl_*_new(), ossl_pkey_new() is now the only one that takes ownership of the passed OpenSSL object instead of making a copy or incrementing its reference counter. Rename it to make this behavior easier to understand. https://github.com/ruby/openssl/commit/54c1c26eb5
2025-07-27[ruby/openssl] ocsp: refactor ossl_ocspcertid_new()Kazuki Yamaguchi
Likewise, let it take a const pointer and not the ownership of the OpenSSL object. This fixes potential memory leak in OpenSSL::OCSP::BasicResponse#status. https://github.com/ruby/openssl/commit/7e0288ebbd
2025-07-27[ruby/openssl] ocsp: refactor ossl_ocspsres_new()Kazuki Yamaguchi
Similar to most of the other ossl_*_new() functions, let it take a const pointer and make a copy of the object. This also fixes a potential memory leak when the wrapper object allocation fails. https://github.com/ruby/openssl/commit/eaabf6d8a3
2025-07-27[ruby/openssl] pkcs7: disallow ossl_pkcs7{si,ri}_new(NULL)Kazuki Yamaguchi
These functions are not actually called with NULL. https://github.com/ruby/openssl/commit/c089301e56
2025-07-27[ruby/openssl] x509: disallow ossl_x509{,attr,crl,ext,revoked,name}*_new(NULL)Kazuki Yamaguchi
These functions are not actually called with NULL. It also doesn't make sense to do so, so let's simplify the definitions. https://github.com/ruby/openssl/commit/ef277083ba
2025-07-27[ruby/openssl] bn: avoid ossl_bn_new(NULL)Kazuki Yamaguchi
Currently, calling ossl_bn_new() with a NULL argument allocates a new OpenSSL::BN instance representing 0. This behavior is confusing. Raise an exception if this is attempted, instead. https://github.com/ruby/openssl/commit/6fa793d997
2025-07-27[ruby/openssl] lib/openssl.rb: require files in alphabetical orderKazuki Yamaguchi
This list was originally in alphabetical order. Sort it again. This change should be safe since the .rb sources should only depend on the extension and not each other. https://github.com/ruby/openssl/commit/eb3998728a
2025-07-27[ruby/json] Keep indentation consistent across functions [ci skip]Nobuyoshi Nakada
https://github.com/ruby/json/commit/1988a3ae4c
2025-07-27[ruby/json] Functions defined in headers should be `static inline`Nobuyoshi Nakada
If `load_uint8x16_4` has an external linkage, it is defined in both `generator` and `parser` extension libraries. This duplicate symbol causes a linker error when `--with-static-linked-ext` is given, on some platforms. https://github.com/ruby/json/commit/020693b17a
2025-07-25[ruby/json] Release 2.13.1Jean Boussier
https://github.com/ruby/json/commit/cfe9337eda