You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "shashbha14 (via GitHub)" <gi...@apache.org> on 2026/01/14 10:21:40 UTC

[PR] GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute [arrow]

shashbha14 opened a new pull request, #48854:
URL: https://github.com/apache/arrow/pull/48854

   ### Rationale for this change
   Fixes crash when writing zero-length POSIXct vectors with empty tzone attributes to Parquet in R 4.5.2.
   
   ### What changes are included in this PR?
   - Added length check for tzone attribute in [InferArrowTypeFromVector](cci:1://file:///C:/Users/ishwet/.gemini/antigravity/scratch/arrow/r/src/type_infer.cpp:44:0-47:1) (both INTSXP and REALSXP specializations)
   - Added regression test in [test-issue-48832.R](cci:7://file:///C:/Users/ishwet/.gemini/antigravity/scratch/arrow/r/tests/testthat/test-issue-48832.R:0:0-0:0)
   
   ### Are these changes tested?
   Yes, new test case reproduces the issue and verifies the fix.
   
   Closes #48832
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute [arrow]

Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic closed pull request #48854: GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute
URL: https://github.com/apache/arrow/pull/48854


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute [arrow]

Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic commented on PR #48854:
URL: https://github.com/apache/arrow/pull/48854#issuecomment-4155508241

   Thanks for submitting this PR @shashbha14, but I'm afraid that when I took a closer look, it doesn't fix the underlying cause of the original issue as we hadn't fully triaged it before the PR.  
   
   I've found the actual source of the issue, so I'm closing this PR as I've written one which does fix it.  FWIW, one small thing that might help in future is prompting the LLM to more closely replicate the bug report from the original issue - that was were the difference was.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute [arrow]

Posted by "jonkeane (via GitHub)" <gi...@apache.org>.
jonkeane commented on code in PR #48854:
URL: https://github.com/apache/arrow/pull/48854#discussion_r2691330675


##########
r/tests/testthat/test-issue-48832.R:
##########
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+test_that("zero-length POSIXct with empty tzone attribute handled safely", {
+  x <- as.POSIXct(character(0))
+  attr(x, "tzone") <- character(0)
+  
+  # Should not crash or error
+  expect_error(type(x), NA)
+  
+  # Should default to no timezone (or empty string which effectively means local/no-tz behavior in arrow)
+  # When sys.timezone is picked up it might vary, but we just check it doesn't crash.
+  # If it picks up Sys.timezone(), checking exact equality might be flaky across environments if not mocked.
+  # So we primarily check for no error.
+  
+  # Also check write_parquet survival
+  tf <- tempfile() 
+  on.exit(unlink(tf))
+  expect_error(write_parquet(data.frame(x = x), tf), NA)
+  expect_true(file.exists(tf))
+})

Review Comment:
   Would you mind putting this test in somewhere around  https://github.com/apache/arrow/blob/962d051254dbe084d30cad23346f8cf460ff5115/r/tests/testthat/test-Array.R#L279-L325
   
   and possibly for the parquet section, put it somewhere near https://github.com/apache/arrow/blob/962d051254dbe084d30cad23346f8cf460ff5115/r/tests/testthat/test-parquet.R#L119-L153
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org