Closed swamp-agr closed 3 years ago
@swamp-agr any example of an XML giving this? It doesn't look to me that high rps could have anything to do with out of bounds access at the linked sites.
@qrilka, let me reproduce the case with enabled dump of entire bytestring. I will come back once will be able to obtain such example.
4s
since start. They contain some sensitive data I cannot share.
I will try to reproduce the issue on some sample/open datasets.
Hi @swamp-agr , any updates on this?
@swamp-agr Can I please have an XML document to reproduce the issue?
@ocramz @mgajda thank you for reaching me out.
There are two components required in order to reproduce the case:
While previously I was receiving different XMLs via http-client
concurrently with explicit ResponseTimeout
, currently I am able to emulate the case and reproduce segmentation fault via reading and parsing the parts of the same file in async mode.
I set up the repository which you could clone and try to reproduce by yourselves: https://github.com/swamp-agr/xeno-issue-43
Issue reproduced with both stack
(GHC 8.8) and cabal
(GHC 8.10).
Stack:
stack build
stack exec -- xeno-runner
[1] 29950 segmentation fault stack exec -- xeno-runner
Cabal:
cabal v2-build
cabal v2-exec -- xeno-runner
[1] 30266 segmentation fault cabal v2-exec -- xeno-runner
I also noticed that minor tweaks in example2.xml
(i.e. removing some nodes from it) without any changes in code could make segfault gone.
@swamp-agr what are those tweaks?
//Tracking@event="firstQuartile"
(whole line).//Tracking@event="thirdQuartile"
(whole line).Output will become:
stack exec -- xeno-runner
errors: 10970
good: 422
@ocramz @mgajda Did you have a time to confirm the case with information provided in this comment above? Could you please share techniques on how to debug segmentation faults in order to help with resolving this issue?
Hi, currently I have no bandwidth to investigate this issue. sorry!
On Wed, 3 Mar 2021 at 23:02, Andrey Prokopenko notifications@github.com wrote:
@ocramz https://github.com/ocramz @mgajda https://github.com/mgajda Did you have a time to confirm the case with information provided in this comment above https://github.com/ocramz/xeno/issues/43#issuecomment-784567243?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ocramz/xeno/issues/43#issuecomment-790094332, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNBDKHCL3LUZL2FIJT6A33TB2WVVANCNFSM4S7VWUEA .
Hi there!
By accident I've stumbled upon strange xeno's segfaulting issue and I seem to have stable static XML payload with which parse
is segfaulting - https://gist.github.com/ingarsjekabsons/5061bd84e0abc30aa78de5b59ecf9259
Seems that any tiny change to this xml makes segfault gone. Add some random characters in the comment section at the end - gone, remove some random element from the document - gone, etc.
Not sure I'm hitting exactly the same issue as reported here initially, though, since I'm using DOM parser, not SAX.
Will try to spend some time digging into more details.
I changed all the unsafe*
functions to their safe variants and found that we we're calling unsafeGrow
with a negative length, this caused the problem. https://github.com/ocramz/xeno/pull/48 should fix this, please give it a spin @ingarsjekabsons, @swamp-agr.
@adamse With following cabal.project
packages: .
source-repository-package
type: git
location: https://github.com/adamse/xeno.git
tag: f4a6f9f23415ed24aae8dd2529ea3788234044e1
I cannot reproduce the issue (segmentation fault):
cabal v2-exec -- xeno-runner
errors: 11514
good: 432
Can confirm, no more segfaults with known payload.
xeno@master:
*Xeno.SAX IO BS Xeno.DOM> d <- IO.openFile "bad.xml" ReadMode >>= BS.hGetContents
*Xeno.SAX IO BS Xeno.DOM> parse d
cabal: repl failed for xeno-0.4.2. The build process segfaulted (i.e.
SIGSEGV).
xeno@pull/43:
*Xeno.SAX IO BS Xeno.DOM> d <- IO.openFile "bad.xml" ReadMode >>= BS.hGetContents
*Xeno.SAX IO BS Xeno.DOM>
*Xeno.SAX IO BS Xeno.DOM> parse d
Right (Node "Package" [("name","cs.bc.ebpp"),("version","")] [Text "\n ",Element (Node "Dependency" [("name","cs.bc.ebpp_db"),("version","1.3.2")] []),Text "\n ",Element (Node "Dependency" [("name","cs.bc.libutils"),("version","")] []),Text "\n ",Element (Node "Dependency" [("name","cs.bc.libutilstux"),("version","")] []),Text "\n ",Element (Node "Dependency" [("name","cs.bc.liborasql"),("version","")] []),Text "\n ",Element (Node "Dependency" [("name","cs.ext.libxercesc"),("version","")] []),Text "\n ",Eleme
...
...
...
Thank you everyone, xeno-0.4.3 with the fix is on Hackage ^^
xeno
as a parser for them.const 500 rps
application started to crash unexpectedly after 1-5 minutes uptime with a segmentation fault.xeno
SAX parser.tagsoup
the problem has gone, application stopped to crash.xeno
parser should be used with care, different trade-offs should be considered.Here are some details:
8.4.3
,8.4.4
.0.4.2
.I guess, some unsafe functions are producing this unexpected effect, e.g.