Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless loop when CsvParser parser $ sign enclosed in quotes #8490

Closed
exalate-issue-sync bot opened this issue May 12, 2023 · 2 comments
Closed

Endless loop when CsvParser parser $ sign enclosed in quotes #8490

exalate-issue-sync bot opened this issue May 12, 2023 · 2 comments

Comments

@exalate-issue-sync
Copy link

This bug originates at StackOverflow: [https://stackoverflow.com/questions/59309659/as-h2o-fails-when-there-is-a-dollar-sign-cannot-determine-file-type|https://stackoverflow.com/questions/59309659/as-h2o-fails-when-there-is-a-dollar-sign-cannot-determine-file-type]

To quote StackOverflow question:

Here is a reproducible example:

{noformat}library(h2o)

h2o.init()

tmp <- data.frame(text = "$", stringsAsFactors = FALSE)
data <- as.h2o(tmp){noformat}

And the error:

{noformat}ERROR: Unexpected HTTP Status code: 412 Precondition Failed (url = http://localhost:54321/3/ParseSetup)

water.exceptions.H2OIllegalArgumentException
[1] "water.exceptions.H2OIllegalArgumentException: Cannot determine file type. for /tmp/RtmpseoDZt/file36123d495362.csv_sid_ae2a_2"
[2] " water.api.ParseSetupHandler.guessSetup(ParseSetupHandler.java:46)"
[3] " sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
[4] " sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)"
[5] " sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
[6] " java.lang.reflect.Method.invoke(Method.java:498)"
[7] " water.api.Handler.handle(Handler.java:60)"
[8] " water.api.RequestServer.serve(RequestServer.java:462)"
[9] " water.api.RequestServer.doGeneric(RequestServer.java:295)"
[10] " water.api.RequestServer.doPost(RequestServer.java:221)"
[11] " javax.servlet.http.HttpServlet.service(HttpServlet.java:755)"
[12] " javax.servlet.http.HttpServlet.service(HttpServlet.java:848)"
[13] " org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)"
[14] " org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)"
[15] " org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)"
[16] " org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:427)"
[17] " org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)"
[18] " org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)"
[19] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"
[20] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"
[21] " water.webserver.jetty8.Jetty8ServerAdapter$LoginHandler.handle(Jetty8ServerAdapter.java:119)"
[22] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"
[23] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"
[24] " org.eclipse.jetty.server.Server.handle(Server.java:370)"
[25] " org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)"
[26] " org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)"
[27] " org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:984)"
[28] " org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1045)"
[29] " org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)"
[30] " org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:236)"
[31] " org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)"
[32] " org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)"
[33] " org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)"
[34] " org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)"
[35] " java.lang.Thread.run(Thread.java:748)"

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page, :

ERROR MESSAGE:

Cannot determine file type. for /tmp/RtmpseoDZt/file36123d495362.csv_sid_ae2a_2{noformat}

@exalate-issue-sync
Copy link
Author

Pavel Pscheidl commented: The problem seems to be easily solvable:

If the parser is in state of POSSIBLE_CURRENCY and the parser hits a quote, instead of jumping into the COND_QUOTE state without incrementing offset and reading new character, it will do exactly that - increment the offset and read new character. After that action, it will finally reach the COND_QUOTE state, but with different character evaluated - and will end up in endless loop.

Solution seems to be to break into MAIN_LOOP and prevent offset incrementation, instead of
{{if (c == quotes) { state = COND_QUOTE; break MAIN_LOOP;}}}
instead of
{{if (c == quotes) { state = COND_QUOTE; break;}}}

@h2o-ops
Copy link
Collaborator

h2o-ops commented May 14, 2023

JIRA Issue Migration Info

Jira Issue: PUBDEV-7149
Assignee: Pavel Pscheidl
Reporter: Pavel Pscheidl
State: Closed
Fix Version: 3.28.0.2
Attachments: N/A
Development PRs: Available

Linked PRs from JIRA

#4160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant