Skip to contentSkip to conversation

block: replace fprintf(stderr, ...) with error_report()

PATCH In review Le Tan 5 participants 7 messages May 26, 2014 – May 27, 2014 Block layer

lore
Share & tools
lore

Le Tan

author
#0 lore raw

PATCH v4 1/1 block: replace fprintf(stderr, ...) with error_report()

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c          |  129 ++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
block-migration.c +3 -3
index 56951e0..9cab084 100644
@@ -790,8 +790,8 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
 
             bs = bdrv_find(device_name);
             if (!bs) {
-                fprintf(stderr, "Error unknown block device %s\n",
-                        device_name);
+                error_report("Error unknown block device %s",
+                             device_name);
                 return -EINVAL;
             }
 
@@ -833,7 +833,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
                    (addr == 100) ? '\n' : '\r');
             fflush(stdout);
         } else if (!(flags & BLK_MIG_FLAG_EOS)) {
-            fprintf(stderr, "Unknown block migration flags: %#x\n", flags);
+            error_report("Unknown block migration flags: %#x", flags);
             return -EINVAL;
         }
         ret = qemu_file_get_error(f);
block.c +2 -2
index c90c71a..725c46a 100644
@@ -2698,8 +2698,8 @@ static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
      * if it has been enabled.
      */
     if (bs->io_limits_enabled) {
-        fprintf(stderr, "Disabling I/O throttling on '%s' due "
-                        "to synchronous I/O.\n", bdrv_get_device_name(bs));
+        error_report("Disabling I/O throttling on '%s' due "
+                     "to synchronous I/O.\n", bdrv_get_device_name(bs));
         bdrv_io_limits_disable(bs);
     }
 
block/qcow2-refcount.c +58 -57

255 lines not on this page · raw message

block/qcow2.c +7 -9
index a4b97e8..e66447a 100644
@@ -2225,12 +2225,12 @@ static int qcow2_amend_options(BlockDriverState *bs,
             } else if (!strcmp(options[i].value.s, "1.1")) {
                 new_version = 3;
             } else {
-                fprintf(stderr, "Unknown compatibility level %s.\n",
-                        options[i].value.s);
+                error_report("Unknown compatibility level %s.",
+                             options[i].value.s);
                 return -EINVAL;
             }
         } else if (!strcmp(options[i].name, "preallocation")) {
-            fprintf(stderr, "Cannot change preallocation mode.\n");
+            error_report("Cannot change preallocation mode.");
             return -ENOTSUP;
         } else if (!strcmp(options[i].name, "size")) {
             new_size = options[i].value.n;
@@ -2240,14 +2240,12 @@ static int qcow2_amend_options(BlockDriverState *bs,
             backing_format = options[i].value.s;
         } else if (!strcmp(options[i].name, "encryption")) {
             if ((options[i].value.n != !!s->crypt_method)) {
-                fprintf(stderr, "Changing the encryption flag is not "
-                        "supported.\n");
+                error_report("Changing the encryption flag is not supported.");
                 return -ENOTSUP;
             }
         } else if (!strcmp(options[i].name, "cluster_size")) {
             if (options[i].value.n != s->cluster_size) {
-                fprintf(stderr, "Changing the cluster size is not "
-                        "supported.\n");
+                error_report("Changing the cluster size is not supported.");
                 return -ENOTSUP;
             }
         } else if (!strcmp(options[i].name, "lazy_refcounts")) {
@@ -2287,8 +2285,8 @@ static int qcow2_amend_options(BlockDriverState *bs,
     if (s->use_lazy_refcounts != lazy_refcounts) {
         if (lazy_refcounts) {
             if (s->qcow_version < 3) {
-                fprintf(stderr, "Lazy refcounts only supported with compatibility "
-                        "level 1.1 and above (use compat=1.1 or greater)\n");
+                error_report("Lazy refcounts only supported with compatibility "
+                             "level 1.1 and above (use compat=1.1 or greater)");
                 return -EINVAL;
             }
             s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS;
block/raw-posix.c +3 -5
index 6586a0c..fceb8eb 100644
@@ -190,8 +190,7 @@ static int raw_normalize_devicepath(const char **filename)
     fname = *filename;
     dp = strrchr(fname, '/');
     if (lstat(fname, &sb) < 0) {
-        fprintf(stderr, "%s: stat failed: %s\n",
-            fname, strerror(errno));
+        error_report("%s: stat failed: %s", fname, strerror(errno));
         return -errno;
     }
 
@@ -205,9 +204,8 @@ static int raw_normalize_devicepath(const char **filename)
         snprintf(namebuf, PATH_MAX, "%.*s/r%s",
             (int)(dp - fname), fname, dp + 1);
     }
-    fprintf(stderr, "%s is a block device", fname);
     *filename = namebuf;
-    fprintf(stderr, ", using %s\n", *filename);
+    error_report("%s is a block device, using %s", fname, *filename);
 
     return 0;
 }
@@ -945,7 +943,7 @@ static int aio_worker(void *arg)
         ret = handle_aiocb_write_zeroes(aiocb);
         break;
     default:
-        fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type);
+        error_report("invalid aio request (0x%x)", aiocb->aio_type);
         ret = -EINVAL;
         break;
     }
block/raw-win32.c +3 -3
index 064ea31..5f67285 100644
@@ -131,7 +131,7 @@ static int aio_worker(void *arg)
         }
         break;
     default:
-        fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type);
+        error_report("invalid aio request (0x%x)", aiocb->aio_type);
         ret = -EINVAL;
         break;
     }
@@ -410,11 +410,11 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset)
      */
     dwPtrLow = SetFilePointer(s->hfile, low, &high, FILE_BEGIN);
     if (dwPtrLow == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
-        fprintf(stderr, "SetFilePointer error: %lu\n", GetLastError());
+        error_report("SetFilePointer error: %lu", GetLastError());
         return -EIO;
     }
     if (SetEndOfFile(s->hfile) == 0) {
-        fprintf(stderr, "SetEndOfFile error: %lu\n", GetLastError());
+        error_report("SetEndOfFile error: %lu", GetLastError());
         return -EIO;
     }
     return 0;
block/ssh.c +1 -1
index aa63c9d..6932905 100644
@@ -1060,7 +1060,7 @@ static void bdrv_ssh_init(void)
 
     r = libssh2_init(0);
     if (r != 0) {
-        fprintf(stderr, "libssh2 initialization failed, %d\n", r);
+        error_report("libssh2 initialization failed, %d", r);
         exit(EXIT_FAILURE);
     }
 
block/vdi.c +7 -7
index 27737af..3bf0757 100644
@@ -305,21 +305,21 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res,
                 if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {
                     bmap[bmap_entry] = bmap_entry;
                 } else {
-                    fprintf(stderr, "ERROR: block index %" PRIu32
-                            " also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry);
+                    error_report("ERROR: block index %" PRIu32 " also used by %"
+                                 PRIu32, bmap[bmap_entry], bmap_entry);
                     res->corruptions++;
                 }
             } else {
-                fprintf(stderr, "ERROR: block index %" PRIu32
-                        " too large, is %" PRIu32 "\n", block, bmap_entry);
+                error_report("ERROR: block index %" PRIu32 " too large, is %"
+                             PRIu32, block, bmap_entry);
                 res->corruptions++;
             }
         }
     }
     if (blocks_allocated != s->header.blocks_allocated) {
-        fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32
-               ", should be %" PRIu32 "\n",
-               blocks_allocated, s->header.blocks_allocated);
+        error_report("ERROR: allocated blocks mismatch, is %" PRIu32
+                     ", should be %" PRIu32,
+                     blocks_allocated, s->header.blocks_allocated);
         res->corruptions++;
     }
 
block/vmdk.c +6 -9
index 480ea37..fe6fd74 100644
@@ -2018,24 +2018,21 @@ static int vmdk_check(BlockDriverState *bs, BdrvCheckResult *result,
         }
         extent = find_extent(s, sector_num, extent);
         if (!extent) {
-            fprintf(stderr,
-                    "ERROR: could not find extent for sector %" PRId64 "\n",
-                    sector_num);
+            error_report("ERROR: could not find extent for sector %" PRId64,
+                         sector_num);
             break;
         }
         ret = get_cluster_offset(bs, extent, NULL,
                                  sector_num << BDRV_SECTOR_BITS,
                                  0, &cluster_offset);
         if (ret == VMDK_ERROR) {
-            fprintf(stderr,
-                    "ERROR: could not get cluster_offset for sector %"
-                    PRId64 "\n", sector_num);
+            error_report("ERROR: could not get cluster_offset for sector %"
+                         PRId64, sector_num);
             break;
         }
         if (ret == VMDK_OK && cluster_offset >= bdrv_getlength(extent->file)) {
-            fprintf(stderr,
-                    "ERROR: cluster offset for sector %"
-                    PRId64 " points after EOF\n", sector_num);
+            error_report("ERROR: cluster offset for sector %"
+                         PRId64 " points after EOF", sector_num);
             break;
         }
         sector_num += extent->cluster_sectors;
block/vpc.c +2 -2
index 2e25f57..8828d35 100644
@@ -203,8 +203,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
     checksum = be32_to_cpu(footer->checksum);
     footer->checksum = 0;
     if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum)
-        fprintf(stderr, "block-vpc: The header checksum of '%s' is "
-            "incorrect.\n", bs->filename);
+        error_report("block-vpc: The header checksum of '%s' is incorrect.",
+                     bs->filename);
 
     /* Write 'checksum' back to footer, or else will leave it with zero. */
     footer->checksum = be32_to_cpu(checksum);
block/vvfat.c +64 -65

247 lines not on this page · raw message

blockdev.c +3 -3
index 7810e9f..e9ab5fe 100644
@@ -698,9 +698,9 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
 
     /* Deprecated option boot=[on|off] */
     if (qemu_opt_get(legacy_opts, "boot") != NULL) {
-        fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be "
-                "ignored. Future versions will reject this parameter. Please "
-                "update your scripts.\n");
+        error_report("qemu-kvm: boot=on|off is deprecated and will be ignored. "
+                     "Future versions will reject this parameter. Please "
+                     "update your scripts.");
     }
 
     /* Media type */
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

Quoted 14 lines
---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c          |  129 ++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

For the time being, I prefer keeping the fprintf(). In the long term we need to decide:
1. Some functions should use Error * to report errors.
2. Some functions really produce their own output but it probably shouldn't go to the monitor.
3. The remaining functions may really be error_report() candidates.

Stefan

#2 lore raw
Quoted 22 lines · Stefan Hajnoczi
Quoted 5 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

Quoted 15 lines
---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c | 129
++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
Quoted 4 lines

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

Global variable cur_mon, non-null while we're executing a monitor command.

Quoted 3 lines

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

error_report() reports to the current monitor when "in monitor context", i.e. while executing a monitor command, i.e. while cur_mon isn't null.

Can we ever be in monitor context (cur_mon not null) without holding the global mutex?

Quoted 6 lines

For the time being, I prefer keeping the fprintf(). In the long term we need to decide:
1. Some functions should use Error * to report errors.
2. Some functions really produce their own output but it probably shouldn't go to the monitor.
3. The remaining functions may really be error_report() candidates.

0. Figure out what rules apply to cur_mon with respect to the global mutex.

#3 lore raw

Am 26.05.2014 um 17:02 hat Markus Armbruster geschrieben:

Quoted 24 lines
Quoted 22 lines · Stefan Hajnoczi
Quoted 20 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c | 129
++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
Quoted 7 lines
Quoted 4 lines

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

Global variable cur_mon, non-null while we're executing a monitor command.

The important part here is that it's indeed global and not thread-local.

Quoted 9 lines
Quoted 3 lines

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

error_report() reports to the current monitor when "in monitor context", i.e. while executing a monitor command, i.e. while cur_mon isn't null.

Can we ever be in monitor context (cur_mon not null) without holding the global mutex?

The right question is: Can a thread (= the main loop thread) ever be in monitor context while another thread (= dataplane thread) is executing block driver code and doesn't hold the global mutex?

If I understand dataplane correctly, the whole point of it is that the answer to this is yes.

Kevin

Quoted 9 lines
Quoted 6 lines

For the time being, I prefer keeping the fprintf(). In the long term we need to decide:
1. Some functions should use Error * to report errors.
2. Some functions really produce their own output but it probably shouldn't go to the monitor.
3. The remaining functions may really be error_report() candidates.

0. Figure out what rules apply to cur_mon with respect to the global mutex.

#4 lore raw
Quoted 46 lines · Kevin Wolf

Am 26.05.2014 um 17:02 hat Markus Armbruster geschrieben:

Quoted 25 lines
Quoted 23 lines · Stefan Hajnoczi
Quoted 21 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c | 129
++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
Quoted 7 lines
Quoted 4 lines

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

Global variable cur_mon, non-null while we're executing a monitor command.

The important part here is that it's indeed global and not thread-local.

Quoted 9 lines
Quoted 3 lines

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

error_report() reports to the current monitor when "in monitor context", i.e. while executing a monitor command, i.e. while cur_mon isn't null.

Can we ever be in monitor context (cur_mon not null) without holding the global mutex?

Quoted 6 lines

The right question is: Can a thread (= the main loop thread) ever be in monitor context while another thread (= dataplane thread) is executing block driver code and doesn't hold the global mutex?

If I understand dataplane correctly, the whole point of it is that the answer to this is yes.

Well, the answer used to be "no". Once upon a time because there was just a single thread, later on because only one thread ever executed "interesting" code.

I'm *not* saying this should remain the case. I'm trying to find out what needs to be done around cur_mon when we break the assumption behind it.

Would making cur_mon thread-local suffice?

#5 lore raw
Quoted 59 lines · Markus Armbruster
Quoted 46 lines · Kevin Wolf

Am 26.05.2014 um 17:02 hat Markus Armbruster geschrieben:

Quoted 25 lines
Quoted 23 lines · Stefan Hajnoczi
Quoted 21 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c, block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument have been removed because @fmt of error_report() should not contain newline.

---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c |  115 +++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c | 129
++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
Quoted 7 lines
Quoted 4 lines

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

Global variable cur_mon, non-null while we're executing a monitor command.

The important part here is that it's indeed global and not thread-local.

Quoted 9 lines
Quoted 3 lines

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

error_report() reports to the current monitor when "in monitor context", i.e. while executing a monitor command, i.e. while cur_mon isn't null.

Can we ever be in monitor context (cur_mon not null) without holding the global mutex?

Quoted 6 lines

The right question is: Can a thread (= the main loop thread) ever be in monitor context while another thread (= dataplane thread) is executing block driver code and doesn't hold the global mutex?

If I understand dataplane correctly, the whole point of it is that the answer to this is yes.

Well, the answer used to be "no". Once upon a time because there was just a single thread, later on because only one thread ever executed "interesting" code.

Quoted 5 lines

I'm *not* saying this should remain the case. I'm trying to find out what needs to be done around cur_mon when we break the assumption behind it.

Would making cur_mon thread-local suffice?

It would suffice.

I think there is no code that invokes error_report() from another thread on purpose (i.e. it knows the main thread is waiting), so making it thread-local should not introduce a regression.

Stefan

#6 lore raw
Quoted 67 lines · Stefan Hajnoczi
Quoted 66 lines · Markus Armbruster
Quoted 49 lines · Kevin Wolf

Am 26.05.2014 um 17:02 hat Markus Armbruster geschrieben:

Quoted 28 lines
Quoted 26 lines · Stefan Hajnoczi
Quoted 24 lines · On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote:

Replace fprintf(stderr,...) with error_report() in files block/*, block.c,
block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument
have been removed because @fmt of error_report() should not contain newline.

---
 block-migration.c      |    6 +--
 block.c                |    4 +-
 block/qcow2-refcount.c | 115
+++++++++++++++++++++---------------------
 block/qcow2.c          |   16 +++---
 block/raw-posix.c      |    8 ++-
 block/raw-win32.c      |    6 +--
 block/ssh.c            |    2 +-
 block/vdi.c            |   14 +++---
 block/vmdk.c           |   15 +++---
 block/vpc.c            |    4 +-
 block/vvfat.c | 129
++++++++++++++++++++++++------------------------
 blockdev.c             |    6 +--
 12 files changed, 159 insertions(+), 166 deletions(-)
Quoted 7 lines
Quoted 4 lines

There is one thing that worries me about this:

error_report() assumes that the QEMU global mutex is held in order to access the "current monitor".

Global variable cur_mon, non-null while we're executing a monitor command.

The important part here is that it's indeed global and not thread-local.

Quoted 9 lines
Quoted 3 lines

This is problematic for code in the read/write/flush path (like qcow2 refcount allocation) since it can be invoked from a virtio-blk data-plane thread (where the QEMU global mutex is not held).

error_report() reports to the current monitor when "in monitor context", i.e. while executing a monitor command, i.e. while cur_mon isn't null.

Can we ever be in monitor context (cur_mon not null) without holding the global mutex?

Quoted 6 lines

The right question is: Can a thread (= the main loop thread) ever be in monitor context while another thread (= dataplane thread) is executing block driver code and doesn't hold the global mutex?

If I understand dataplane correctly, the whole point of it is that the answer to this is yes.

Well, the answer used to be "no". Once upon a time because there was just a single thread, later on because only one thread ever executed "interesting" code.

I'm *not* saying this should remain the case. I'm trying to find out what needs to be done around cur_mon when we break the assumption behind it.

Quoted 7 lines
Quoted 1 line

Would making cur_mon thread-local suffice?

It would suffice.

I think there is no code that invokes error_report() from another thread on purpose (i.e. it knows the main thread is waiting), so making it thread-local should not introduce a regression.

So, who's going to cook up the patch to make it thread-local?