Title: coredump in `TryCopyLastError` · Issue #759 · apache/arrow-java · GitHub
Open Graph Title: coredump in `TryCopyLastError` · Issue #759 · apache/arrow-java
X Title: coredump in `TryCopyLastError` · Issue #759 · apache/arrow-java
Description: Describe the bug, including details regarding any error messages, version, and platform. If Consumer throws exception, TryCopyLastError would copy exception message to C buffer. TryCopyLastError assume the string(byte[]) returned by last...
Open Graph Description: Describe the bug, including details regarding any error messages, version, and platform. If Consumer throws exception, TryCopyLastError would copy exception message to C buffer. TryCopyLastError as...
X Description: Describe the bug, including details regarding any error messages, version, and platform. If Consumer throws exception, TryCopyLastError would copy exception message to C buffer. TryCopyLastError as...
Opengraph URL: https://github.com/apache/arrow-java/issues/759
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"coredump in `TryCopyLastError`","articleBody":"### Describe the bug, including details regarding any error messages, version, and platform.\n\nIf `Consumer` throws exception, `TryCopyLastError` would copy exception message to C buffer. `TryCopyLastError` assume the string(byte[]) returned by `lastError` is '\\0' terminated and test the length of the string by `strlen` which result in invalid memory access. In actually, `lastError` is a UTF8 encoded buffer(byte[]).\n\nThe code of `TryCopyLastError`:\n\n```c\n jobject error_data =\n env-\u003eGetObjectField(private_data-\u003ej_private_data_, kPrivateDataLastErrorField);\n ...\n auto arr = reinterpret_cast\u003cjbyteArray\u003e(error_data);\n jbyte* error_bytes = env-\u003eGetByteArrayElements(arr, nullptr);\n if (!error_bytes) {\n private_data-\u003elast_error_.clear();\n return;\n }\n\n char* error_str = reinterpret_cast\u003cchar*\u003e(error_bytes);\n private_data-\u003elast_error_ = std::string(error_str, std::strlen(error_str));\n```\n\nThe code below shows how `lastError` be setted:\n```java\nprivate int setLastError(Throwable err) {\n // Do not let exceptions propagate up to JNI\n try {\n StringWriter buf = new StringWriter();\n PrintWriter writer = new PrintWriter(buf);\n err.printStackTrace(writer);\n lastError = buf.toString().getBytes(StandardCharsets.UTF_8);\n } catch (Throwable e) {\n // Bail out of setting the error message - we'll still return an error code\n lastError = null;\n }\n return 5; // = EIO\n }\n```","author":{"url":"https://github.com/hnwyllmm","@type":"Person","name":"hnwyllmm"},"datePublished":"2025-05-20T03:57:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/759/arrow-java/issues/759"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d92b9024-a657-3326-a889-14e6134f9759 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB58:2371E7:1DDA786:294149F:6A502341 |
| html-safe-nonce | 777ef3ae6261c439381feda2d5334c54dfeefd0affc351a71632116db3575843 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjU4OjIzNzFFNzoxRERBNzg2OjI5NDE0OUY6NkE1MDIzNDEiLCJ2aXNpdG9yX2lkIjoiNTQ4OTE2MDU5OTEzMTY2MTEyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0baf1b2e00747a2b327e527b61e47d665d2fa9ba34434aad6892f2c07d49eb3e |
| hovercard-subject-tag | issue:3075553143 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/arrow-java/759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f146d60b6247e1083e1d7e988347598975e5b84315b5d9dc154e16de0c950c57/apache/arrow-java/issues/759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f146d60b6247e1083e1d7e988347598975e5b84315b5d9dc154e16de0c950c57/apache/arrow-java/issues/759 |
| og:image:alt | Describe the bug, including details regarding any error messages, version, and platform. If Consumer throws exception, TryCopyLastError would copy exception message to C buffer. TryCopyLastError as... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hnwyllmm |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/arrow-java git https://github.com/apache/arrow-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 893682219 |
| octolytics-dimension-repository_nwo | apache/arrow-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 893682219 |
| octolytics-dimension-repository_network_root_nwo | apache/arrow-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width