fsatrace icon indicating copy to clipboard operation
fsatrace copied to clipboard

segfault in emiting op

Open woody77 opened this issue 2 years ago • 8 comments

Hello, I'm seeing a segfault in the traced app, when it's trying to write to the shared memory buffer back to fsatrace:

<segv>
#4  emitOp (oc=oc@entry=114, op1=<optimized out>, p2=p2@entry=0x0) at src/emit.c:118
#5  0x00007f6fa63525f3 in fdemit (c=c@entry=114, fd=fd@entry=16) at src/unix/fsatraceso.c:118
#6  0x00007f6fa6352937 in openat64 (fd=-100, p=<optimized out>, f=<optimized out>, m=<optimized out>) at src/unix/fsatraceso.c:269

I don't have much more info at this time, but from looking at the source, is this likely to be running past the end of the buffer?

From my reading of main(), all accesses are buffered in the shared memory buffer until the process is complete, and then written, correct? (no concurrent access) https://github.com/jacereda/fsatrace/blob/master/src/fsatrace.c#L193-L203

And the default logsize is 1MB of text? https://github.com/jacereda/fsatrace/blob/master/src/fsatrace.h#L4

Which can be overridden by setting the env var FSAT_BUF_SIZE?

woody77 avatar Feb 28 '22 20:02 woody77

I see this even if I set the buffer to larger and larger sizes, up to a size large enough that fsatrace fails to allocate the buffer.

woody77 avatar Feb 28 '22 20:02 woody77

Hi, thanks for the report.

Can you reproduce this? Can you share how?

From my reading of main(), all accesses are buffered in the shared memory buffer until the process is complete, and then written, correct? (no concurrent access) https://github.com/jacereda/fsatrace/blob/master/src/fsatrace.c#L193-L203

Right.

And the default logsize is 1MB of text? https://github.com/jacereda/fsatrace/blob/master/src/fsatrace.h#L4

Which can be overridden by setting the env var FSAT_BUF_SIZE?

Right.

jacereda avatar Mar 01 '22 11:03 jacereda

The issue that I linked to this: https://github.com/dart-lang/sdk/issues/48413 has the setup where we found it.

It's a pretty deeply nested conglomeration of processes to setup the issue. I haven't been able to reproduce it outside of that context.

woody77 avatar Mar 02 '22 21:03 woody77

Can you generate a coredump? Also, the buffer is stack-allocated, can you replace that by a malloc() and increase the FSAT_BUF_SIZE?

jacereda avatar Mar 02 '22 21:03 jacereda

Also can you try the current master? That one gets rid of FSAT_BUF_SIZE and has a static 16MB buffer.

jacereda avatar Mar 04 '22 13:03 jacereda

@fangism - I don't know how to update and rebuild fsatrace within the Fuchsia build, can you help with this? (if you push a new binary to CIPD, I can snag it locally and test on my workstation that's seeing this issue).

woody77 avatar Mar 04 '22 17:03 woody77

Looks like we're getting different results, now:

fsatrace(87243): error: freeing shared memory (4)

woody77 avatar Mar 28 '22 22:03 woody77

I found this error in 41b02a0 (2020-10-10), which is currently packaged in Nixpkgs, but it seems to work in the latest commit c031f8da (2022-03-30).

charmoniumQ avatar Sep 23 '23 23:09 charmoniumQ