Bug 52936 - Race condition in cairo-trace
Summary: Race condition in cairo-trace
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.12.2
Hardware: All Linux (All)
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-30 04:31 UTC by Seongwon Cho
Modified: 2018-08-25 13:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Seongwon Cho 2012-07-30 04:31:12 UTC
There is a race condition in _init_logfile() in trace.c

If a application fork and execute child process by execl()
value of CAIRO_TRACE_FD is also duplicated and the value of CAIRO_TRACE_FD will be -1 in child process.

In that case child process doesn,t create new log file and we can,t get trace file of child process.

Thanks.
Comment 1 Chris Wilson 2012-07-30 08:08:48 UTC
You can see the reason why it has to be like that? The trace file is a sequential stream and can't handle multiple processes simultaneously.

To handle such tracing, the idea was to specify a directory and for each trace to be written to a separate file (in CAIRO_TRACE_OUTDIR). However, looks like that's broken if the child is spawned after the logfile is open. Can you please try:

diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index da7d2f0..f7945e7 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -832,7 +832,7 @@ _init_logfile (void)
                filename, name, getpid());
 
        filename = buf;
-
+    } else {
        setenv ("CAIRO_TRACE_FD", "-1", 1);
     }
Comment 2 Seongwon Cho 2012-07-30 08:27:59 UTC
Hi, Chris

If I block setenv() I can get trace from both Parent and Child process.
Actually I already got trace by workaround but I just want to let you know the problem.

Thank you.
Comment 3 Chris Wilson 2012-07-30 08:32:48 UTC
In general, that will lead to an unreplayable trace.
Comment 4 Seongwon Cho 2012-07-30 08:51:04 UTC
If Parent and Child don't share any resources (context, surface, pattern etc) each other
Do I still get unreplayable trace ?
Comment 5 Chris Wilson 2012-07-30 09:23:57 UTC
You will get a broken trace if the parent and child ever call into cairo concurrently - that is if A sets up some state then B performs a fill assuming its own earlier state was still valid.
Comment 6 GitLab Migration User 2018-08-25 13:50:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/227.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.